mirror of https://github.com/nlohmann/json.git
Add MAIN_PROJECT check for test and install options
parent
d8d8cbf6e0
commit
5c589dd138
|
@ -6,6 +6,13 @@ cmake_minimum_required(VERSION 3.1)
|
||||||
##
|
##
|
||||||
project(nlohmann_json VERSION 3.9.1 LANGUAGES CXX)
|
project(nlohmann_json VERSION 3.9.1 LANGUAGES CXX)
|
||||||
|
|
||||||
|
##
|
||||||
|
## MAIN_PROJECT CHECK
|
||||||
|
##
|
||||||
|
if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||||
|
set(MAIN_PROJECT ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
##
|
##
|
||||||
## INCLUDE
|
## INCLUDE
|
||||||
##
|
##
|
||||||
|
@ -21,8 +28,8 @@ if (POLICY CMP0077)
|
||||||
cmake_policy(SET CMP0077 NEW)
|
cmake_policy(SET CMP0077 NEW)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ON)
|
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ${MAIN_PROJECT})
|
||||||
option(JSON_Install "Install CMake targets during install step." ON)
|
option(JSON_Install "Install CMake targets during install step." ${MAIN_PROJECT})
|
||||||
option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF)
|
option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF)
|
||||||
option(JSON_ImplicitConversions "Enable implicit conversions." ON)
|
option(JSON_ImplicitConversions "Enable implicit conversions." ON)
|
||||||
|
|
||||||
|
@ -101,9 +108,8 @@ CONFIGURE_FILE(
|
||||||
## TESTS
|
## TESTS
|
||||||
## create and configure the unit test target
|
## create and configure the unit test target
|
||||||
##
|
##
|
||||||
include(CTest) #adds option BUILD_TESTING (default ON)
|
if (JSON_BuildTests)
|
||||||
|
include(CTest) #adds option BUILD_TESTING (default ON)
|
||||||
if(BUILD_TESTING AND JSON_BuildTests)
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue