mirror of
https://github.com/allankoechke/jwt-cpp.git
synced 2026-11-30 10:18:40 +00:00
* exclude any folder prefixed with build * seeing how far generator expresstion will go * refactor cmake + outline some tests * adding missing install destiniation * rolling back some changes since the workflow was no support by CMake * adding missing include * fixing old variable names being used * using target_compile_definitions instead of options * correct options for CI + reporting errors for consumer * using sudo to install * fix bad variable * trying CMAKE_PREFIX_PATH * removing recursive call * remove options from generators + dedicated exports target * remove pthread link lib (unused) * install targets files + include * add missing main * remove install prefix * revive CMAKE_PREFIX_PATH it's really needed * fix collision on DISABLE_BASE64 + more cmake tests * bump cmake version + test minimum * fix job names * fix bad replace * fix bad permissions * fix install of picojson * adding missing ifndef and overload for pico and no base64 * linting * test for version * trying to find version * [test] remove semver prerelase from CMake * fixing some documentation issues * limit cmake test to only related files * touch up docs * making sure new helper supports no base64 mode * some doc fixes * Update cmake.yml * Update .github/workflows/cmake.yml * Update .gitignore
70 lines
2.9 KiB
CMake
70 lines
2.9 KiB
CMake
cmake_minimum_required(VERSION 3.8)
|
|
|
|
project(jwt-cpp)
|
|
|
|
option(JWT_BUILD_EXAMPLES "Configure CMake to build examples (or not)" ON)
|
|
option(JWT_BUILD_TESTS "Configure CMake to build tests (or not)" OFF)
|
|
option(JWT_ENABLE_COVERAGE "Enable code coverage testing" OFF)
|
|
|
|
option(JWT_EXTERNAL_PICOJSON "Use find_package() to locate picojson, provided to integrate with package managers" OFF)
|
|
option(JWT_DISABLE_BASE64 "Do not include the base64 implementation from this library" OFF)
|
|
option(JWT_DISABLE_PICOJSON "Do not provide the picojson template specialiaze" OFF)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
|
|
|
find_package(OpenSSL 1.0.2 REQUIRED)
|
|
|
|
if(JWT_EXTERNAL_PICOJSON)
|
|
find_package(picojson 1.3.0 REQUIRED)
|
|
endif()
|
|
|
|
set(JWT_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
set(JWT_HEADER_FILES ${JWT_INCLUDE_PATH}/jwt-cpp/jwt.h)
|
|
if(NOT JWT_DISABLE_BASE64)
|
|
list(APPEND JWT_HEADER_FILES ${JWT_INCLUDE_PATH}/jwt-cpp/base.h)
|
|
endif()
|
|
|
|
add_library(jwt-cpp INTERFACE)
|
|
add_library(jwt-cpp::jwt-cpp ALIAS jwt-cpp) # To match export
|
|
target_compile_features(jwt-cpp INTERFACE cxx_std_11)
|
|
if(JWT_DISABLE_BASE64)
|
|
target_compile_definitions(jwt-cpp INTERFACE JWT_DISABLE_BASE64)
|
|
endif()
|
|
if(JWT_DISABLE_PICOJSON)
|
|
target_compile_definitions(jwt-cpp INTERFACE JWT_DISABLE_PICOJSON)
|
|
endif()
|
|
target_include_directories(jwt-cpp INTERFACE $<BUILD_INTERFACE:${JWT_INCLUDE_PATH}>
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
|
target_link_libraries(jwt-cpp INTERFACE OpenSSL::SSL OpenSSL::Crypto)
|
|
|
|
if(JWT_EXTERNAL_PICOJSON)
|
|
target_link_libraries(jwt-cpp INTERFACE picojson::picojson>)
|
|
endif()
|
|
|
|
include(GNUInstallDirs)
|
|
include(CMakePackageConfigHelpers)
|
|
set(JWT_CMAKE_FILES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/cmake/jwt-cpp)
|
|
configure_package_config_file(
|
|
${CMAKE_CURRENT_LIST_DIR}/cmake/jwt-cpp-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-config.cmake
|
|
INSTALL_DESTINATION ${JWT_CMAKE_FILES_INSTALL_DIR} PATH_VARS JWT_EXTERNAL_PICOJSON)
|
|
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-config-version.cmake VERSION 0.5.0
|
|
COMPATIBILITY ExactVersion)
|
|
|
|
install(TARGETS jwt-cpp EXPORT jwt-cpp-targets PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
install(EXPORT jwt-cpp-targets NAMESPACE jwt-cpp:: FILE jwt-cpp-targets.cmake
|
|
DESTINATION ${JWT_CMAKE_FILES_INSTALL_DIR})
|
|
install(FILES ${JWT_HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/jwt-cpp)
|
|
if(NOT JWT_EXTERNAL_PICOJSON AND NOT JWT_DISABLE_PICOJSON)
|
|
install(FILES ${JWT_INCLUDE_PATH}/picojson/picojson.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/picojson)
|
|
endif()
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-config-version.cmake
|
|
DESTINATION ${JWT_CMAKE_FILES_INSTALL_DIR})
|
|
|
|
if(JWT_BUILD_EXAMPLES)
|
|
add_subdirectory(example)
|
|
endif()
|
|
|
|
if(JWT_BUILD_TESTS)
|
|
add_subdirectory(tests)
|
|
endif()
|