diff --git a/CMakeLists.txt b/CMakeLists.txt index 881aa04..a702c11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 1c798cf..f217de4 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -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)