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
41 lines
1.8 KiB
CMake
41 lines
1.8 KiB
CMake
if(JWT_DISABLE_BASE64)
|
|
message(FATAL_ERROR "Tests requires the base64 support to be enabled!")
|
|
endif()
|
|
|
|
if(JWT_DISABLE_PICOJSON)
|
|
message(FATAL_ERROR "Tests requires the picojson support to be enabled!")
|
|
endif()
|
|
|
|
enable_testing()
|
|
include(GoogleTest)
|
|
|
|
find_package(GTest REQUIRED)
|
|
|
|
set(TEST_SOURCES
|
|
${CMAKE_CURRENT_SOURCE_DIR}/BaseTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ClaimTest.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Keys.cpp ${CMAKE_CURRENT_SOURCE_DIR}/HelperTest.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/TestMain.cpp ${CMAKE_CURRENT_SOURCE_DIR}/TokenFormatTest.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/TokenTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/NlohmannTest.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/OpenSSLErrorTest.cpp)
|
|
|
|
add_executable(jwt-cpp-test ${TEST_SOURCES})
|
|
|
|
# NOTE: Don't use space inside a generator expression here, because the function prematurely breaks the expression into
|
|
# multiple lines. https://cmake.org/pipermail/cmake/2018-April/067422.html
|
|
set(JWT_TESTER_GCC_FLAGS -Wall -Wextra -Wpedantic)
|
|
set(JWT_TESTER_CLANG_FLAGS -Weverything -Wno-c++98-compat -Wno-global-constructors -Wno-weak-vtables)
|
|
target_compile_options(
|
|
jwt-cpp-test PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/W4> $<$<CXX_COMPILER_ID:GNU>:${JWT_TESTER_GCC_FLAGS}>
|
|
$<$<CXX_COMPILER_ID:Clang>:${JWT_TESTER_CLANG_FLAGS}>)
|
|
target_link_libraries(jwt-cpp-test PRIVATE jwt-cpp GTest::GTest GTest::Main
|
|
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:${CMAKE_DL_LIBS}>)
|
|
|
|
gtest_add_tests(TARGET jwt-cpp-test)
|
|
|
|
if(JWT_ENABLE_COVERAGE)
|
|
include("code-coverage")
|
|
setup_coverage(jwt-cpp-test)
|
|
set(COVERAGE_EXCLUDES "/usr/**" "/home/*/.conan/**" "*test*" "*build*" "*json*")
|
|
setup_target_for_coverage_lcov(NAME coverage EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-test)
|
|
endif()
|