Allow building tool, example, and tests from upper cmake projects (#63)

Now a subdirectory will by default only build the library, a standalone build will build everything.
This commit is contained in:
Manu Sánchez 2018-07-13 11:03:12 +02:00 committed by Jonathan Müller
commit 8d77d011ac

View file

@ -14,25 +14,25 @@ endif()
option(CPPAST_ENABLE_ASSERTIONS "whether or not to enable internal assertions for the cppast library" ${default_assertions})
option(CPPAST_ENABLE_PRECONDITION_CHECKS "whether or not to enable precondition checks" ON)
option(CPPAST_BUILD_TEST "whether or not to build the tests" ON)
option(CPPAST_BUILD_EXAMPLE "whether or not to build the examples" ON)
option(CPPAST_BUILD_TOOL "whether or not to build the tool" ON)
option(CPPAST_BUILD_TEST "whether or not to build the tests" OFF)
option(CPPAST_BUILD_EXAMPLE "whether or not to build the examples" OFF)
option(CPPAST_BUILD_TOOL "whether or not to build the tool" OFF)
option(BUILD_TESTING "build test" OFF) # The ctest variable for building tests
if((${CPPAST_BUILD_TEST} OR ${BUILD_TESTING}) AND (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
if((${CPPAST_BUILD_TEST} OR ${BUILD_TESTING}) OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
set(build_test ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # for the self integration test
else()
set(build_test OFF)
endif()
if(${CPPAST_BUILD_EXAMPLE} AND (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
if(${CPPAST_BUILD_EXAMPLE} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
set(build_example ON)
else()
set(build_example OFF)
endif()
if(${CPPAST_BUILD_TOOL} AND (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
if(${CPPAST_BUILD_TOOL} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
set(build_tool ON)
else()
set(build_tool OFF)