diff --git a/CMakeLists.txt b/CMakeLists.txt index 06761947b..7c4d8ad8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,9 +8,10 @@ project(nlohmann_json VERSION 3.9.1 LANGUAGES CXX) ## ## MAIN_PROJECT CHECK +## determine if nlohmann_json is built as a subproject (using add_subdirectory) or if it is the main project ## set(MAIN_PROJECT OFF) -if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) +if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(MAIN_PROJECT ON) endif()