diff --git a/CMakeLists.txt b/CMakeLists.txt index ffde25f..b61479c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,14 @@ project(nameof VERSION "0.8.0" LANGUAGES CXX) -option(NAMEOF_OPT_BUILD_EXAMPLES "Build nameof examples" ON) -option(NAMEOF_OPT_BUILD_TESTS "Build and perform nameof tests" ON) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + set(IS_TOPLEVEL_PROJECT TRUE) +else() + set(IS_TOPLEVEL_PROJECT FALSE) +endif() + +option(NAMEOF_OPT_BUILD_EXAMPLES "Build nameof examples" ${IS_TOPLEVEL_PROJECT}) +option(NAMEOF_OPT_BUILD_TESTS "Build and perform nameof tests" ${IS_TOPLEVEL_PROJECT}) if(NAMEOF_OPT_BUILD_EXAMPLES) add_subdirectory(example)