diff --git a/CMakeLists.txt b/CMakeLists.txt index 5988fbe..4baae16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,18 +5,21 @@ project(tracelogging) include(GNUInstallDirs) add_compile_options(-Wall -Wextra -Werror) +set(TRACELOGGING_BUILD_TESTS ON CACHE BOOL "Build tests.") # Include source add_subdirectory(src) # Only include testing stuff if we are the top level -if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) - enable_testing() +if(TRACELOGGING_BUILD_TESTS) + if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) + enable_testing() - if (NOT TARGET Catch2::Catch2) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/external/Catch2/contrib") - add_subdirectory(external/Catch2) + if (NOT TARGET Catch2::Catch2) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/external/Catch2/contrib") + add_subdirectory(external/Catch2) + endif () + + add_subdirectory(test) endif () - - add_subdirectory(test) endif ()