Skip to content

Commit ac0424b

Browse files
authored
Integrate Hunter package manager support (#163)
* Add initial hunter support
1 parent da4adc3 commit ac0424b

File tree

5 files changed

+599
-8
lines changed

5 files changed

+599
-8
lines changed

.github/workflows/cmake.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,22 @@ jobs:
177177
cd tests/cmake
178178
cmake . -DCMAKE_PREFIX_PATH=/usr/local/cmake -DCMAKE_MODULE_PATH=../../cmake -DTEST:STRING="libressl-is-used"
179179
cmake --build .
180+
181+
with-hunter:
182+
runs-on: ubuntu-latest
183+
steps:
184+
- uses: actions/checkout@v2
185+
- name: install cmake
186+
uses: lukka/get-cmake@latest
187+
188+
- name: setup
189+
run: |
190+
mkdir build
191+
cd build
192+
cmake .. -DJWT_BUILD_TESTS=ON -DJWT_BUILD_EXAMPLES=ON -DJWT_ENABLE_COVERAGE=OFF -DHUNTER_ENABLED=ON
193+
make
194+
195+
- name: test
196+
run: |
197+
cd build
198+
./tests/jwt-cpp-test

CMakeLists.txt

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
cmake_minimum_required(VERSION 3.8)
22

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

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

23-
if(${JWT_SSL_LIBRARY} MATCHES "OpenSSL")
24-
find_package(OpenSSL 1.0.2 REQUIRED)
35+
# If Hunter is enabled, we configure it to resolve OpenSSL and warn
36+
# the user if he selected an option not supported by hunter.
37+
# We fall back to the system library in this case.
38+
if(HUNTER_ENABLED)
39+
if(${JWT_SSL_LIBRARY} MATCHES "OpenSSL")
40+
hunter_add_package(OpenSSL)
41+
elseif(${JWT_SSL_LIBRARY} MATCHES "LibreSSL")
42+
message(WARNING "Hunter does not support LibreSSL yet, the system library will be used (if available)")
43+
endif()
44+
if(JWT_EXTERNAL_PICOJSON)
45+
message(WARNING "Hunter does not support picojson yet, the system library will be used (if available)")
46+
endif()
2547
endif()
26-
27-
if(${JWT_SSL_LIBRARY} MATCHES "LibreSSL")
28-
find_package(LibreSSL 3.0.0 REQUIRED)
48+
if(${JWT_SSL_LIBRARY} MATCHES "OpenSSL")
49+
find_package(OpenSSL 1.0.2 REQUIRED)
50+
elseif(${JWT_SSL_LIBRARY} MATCHES "LibreSSL")
51+
find_package(LibreSSL 3.0.0 REQUIRED)
2952
endif()
3053

3154
if(JWT_EXTERNAL_PICOJSON)

0 commit comments

Comments
 (0)