Skip to content

Commit

Permalink
Integrate Hunter package manager support (#163)
Browse files Browse the repository at this point in the history
* Add initial hunter support
  • Loading branch information
Thalhammer authored Sep 4, 2021
1 parent da4adc3 commit ac0424b
Show file tree
Hide file tree
Showing 5 changed files with 599 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,22 @@ jobs:
cd tests/cmake
cmake . -DCMAKE_PREFIX_PATH=/usr/local/cmake -DCMAKE_MODULE_PATH=../../cmake -DTEST:STRING="libressl-is-used"
cmake --build .
with-hunter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install cmake
uses: lukka/get-cmake@latest

- name: setup
run: |
mkdir build
cd build
cmake .. -DJWT_BUILD_TESTS=ON -DJWT_BUILD_EXAMPLES=ON -DJWT_ENABLE_COVERAGE=OFF -DHUNTER_ENABLED=ON
make
- name: test
run: |
cd build
./tests/jwt-cpp-test
33 changes: 28 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
cmake_minimum_required(VERSION 3.8)

# HUNTER_ENABLED is always set if this package is included in a project using hunter (HunterGate sets it)
# In this case we will use hunter as well to stay consistent. If not the use can supply it on configure
# to force using hunter.
if(HUNTER_ENABLED)
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.23.314.tar.gz"
SHA1 "95c47c92f68edb091b5d6d18924baabe02a6962a"
)
message(STATUS "jwt-cpp: using hunter for dependency resolution")
endif()

project(jwt-cpp)

option(JWT_BUILD_EXAMPLES "Configure CMake to build examples (or not)" ON)
Expand All @@ -20,12 +32,23 @@ if(NOT JWT_SSL_LIBRARY IN_LIST JWT_SSL_LIBRARY_OPTIONS)
message(FATAL_ERROR "JWT_SSL_LIBRARY must be one of ${JWT_SSL_LIBRARY_OPTIONS}")
endif()

if(${JWT_SSL_LIBRARY} MATCHES "OpenSSL")
find_package(OpenSSL 1.0.2 REQUIRED)
# If Hunter is enabled, we configure it to resolve OpenSSL and warn
# the user if he selected an option not supported by hunter.
# We fall back to the system library in this case.
if(HUNTER_ENABLED)
if(${JWT_SSL_LIBRARY} MATCHES "OpenSSL")
hunter_add_package(OpenSSL)
elseif(${JWT_SSL_LIBRARY} MATCHES "LibreSSL")
message(WARNING "Hunter does not support LibreSSL yet, the system library will be used (if available)")
endif()
if(JWT_EXTERNAL_PICOJSON)
message(WARNING "Hunter does not support picojson yet, the system library will be used (if available)")
endif()
endif()

if(${JWT_SSL_LIBRARY} MATCHES "LibreSSL")
find_package(LibreSSL 3.0.0 REQUIRED)
if(${JWT_SSL_LIBRARY} MATCHES "OpenSSL")
find_package(OpenSSL 1.0.2 REQUIRED)
elseif(${JWT_SSL_LIBRARY} MATCHES "LibreSSL")
find_package(LibreSSL 3.0.0 REQUIRED)
endif()

if(JWT_EXTERNAL_PICOJSON)
Expand Down
Loading

0 comments on commit ac0424b

Please sign in to comment.