Commit 3292a13718d18e7dd1b32ececc73b534398872dd

Ralf Habacker 2020-11-02T12:50:41

cmake: Let make target 'test' be accessable from topmost build directory The cmake command enable_testing() must be placed in the topmost CMakeLists.txt so that the make target 'test' is available in the topmost build directory.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 321cfd1..ab20340 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,5 +16,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
 add_subdirectory(src)
 
 if (BUILD_TESTS)
-  add_subdirectory(tests)
+    enable_testing()
+    add_subdirectory(tests)
 endif()
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 25e9eea..be1c359 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,4 +1,3 @@
-enable_testing()
 include_directories(../src)
 add_library(testdll SHARED testdll.c)
 set_target_properties(testdll PROPERTIES PREFIX "")