From 2841afa2bce6169d0e327ee45bfe55fcf3c56210 Mon Sep 17 00:00:00 2001 From: SandoreX Date: Mon, 26 Nov 2018 12:23:57 +0100 Subject: [PATCH] Disable tests if used as subproject --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a1c188b0..e319994a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,10 @@ else() message(STATUS "Using the single-header code from ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}") endif() +if(NOT "${PROJECT_NAME}" STREQUAL "${CMAKE_PROJECT_NAME}") + set(SUBPROJECT ON) +endif() + ## ## TARGET ## create target and add include path @@ -73,7 +77,7 @@ endif() ## include(CTest) #adds option BUILD_TESTING (default ON) -if(BUILD_TESTING AND JSON_BuildTests) +if(BUILD_TESTING AND JSON_BuildTests AND NOT SUBPROJECT) enable_testing() add_subdirectory(test) endif()