Allow building examples as subproject and build them by default (#84)

This commit is contained in:
Dominik Thalhammer
2020-07-16 11:45:59 +02:00
committed by GitHub
parent d2223db256
commit 312cb9d74c
2 changed files with 8 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ if(CMAKE_TOOLCHAIN_FILE)
endif()
option(BUILD_TESTS "Configure CMake to build tests (or not)" ON)
option(BUILD_EXAMPLES "Configure CMake to build examples (or not)" ON)
option(COVERAGE "Enable code coverage testing" OFF)
option(EXTERNAL_PICOJSON "Use find_package() to locate the picojson header" OFF)
option(DISABLE_JWT_CPP_BASE64
@@ -93,3 +94,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jwt-cpp-config.cmake
if(BUILD_TESTS)
add_subdirectory(tests)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(example)
endif()

View File

@@ -1,7 +1,9 @@
cmake_minimum_required(VERSION 3.8)
project(jwt-cpp-examples)
find_package(jwt-cpp CONFIG REQUIRED)
if(NOT TARGET jwt-cpp)
find_package(jwt-cpp CONFIG REQUIRED)
endif()
add_executable(print-claims print-claims.cpp)
target_link_libraries(print-claims jwt-cpp::jwt-cpp)