We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e82b5b8 commit 476d65fCopy full SHA for 476d65f
CMakeLists.txt
@@ -35,9 +35,20 @@ add_subdirectory(src/lib)
35
# ENABLE TESTING
36
#################################################################
37
38
-option(BUILD_TESTING "Build the testing tree." OFF)
39
-if(BUILD_TESTING)
40
- include(CTest)
+if(${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
+ set(main_project TRUE)
+else()
41
+ set(main_project FALSE)
42
+endif()
43
+
44
+include(CMakeDependentOption)
45
+cmake_dependent_option(BUILD_TESTING_${PROJECT_NAME}
46
+ "Build the testing tree for project ${PROJECT_NAME}." OFF
47
+ "BUILD_TESTING;NOT main_project" OFF
48
+)
49
50
+if(main_project OR BUILD_TESTING_${PROJECT_NAME})
51
+ enable_testing()
52
add_subdirectory(src/tests)
53
endif()
54
0 commit comments