enable tests and examples only if is top project

This commit is contained in:
neargye 2019-04-18 14:27:35 +05:00
parent 513240b698
commit e4b501153c

View file

@ -2,8 +2,14 @@
project(nameof VERSION "0.8.0" LANGUAGES CXX) project(nameof VERSION "0.8.0" LANGUAGES CXX)
option(NAMEOF_OPT_BUILD_EXAMPLES "Build nameof examples" ON) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
option(NAMEOF_OPT_BUILD_TESTS "Build and perform nameof tests" ON) 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) if(NAMEOF_OPT_BUILD_EXAMPLES)
add_subdirectory(example) add_subdirectory(example)