Do not build the tests by default (CMake)
authorVictor Romero <romerosanchezv@gmail.com>
Thu, 6 Jun 2019 07:24:28 +0000 (10:24 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 6 Jun 2019 07:24:28 +0000 (10:24 +0300)
Issue #281 (bdwgc).

build_cord and build_tests options are introduced in the CMake script.

* CMakeLists.txt (build_cord): Add option (on by default); add comment.
* CMakeLists.txt (build_tests): Add option (off by default).
* CMakeLists.txt (cord): Specify add_subdirectory only if build_cord.
* CMakeLists.txt (tests): Specify add_subdirectory only if build_tests.
* cord/CMakeLists.txt: Skip cordtest and de tests unless build_tests.

CMakeLists.txt
cord/CMakeLists.txt

index 8d386ca..4175e07 100644 (file)
@@ -27,6 +27,9 @@ include(CTest)
 
 cmake_minimum_required(VERSION 3.1)
 
+# Customize the build by passing "-D<option_name>=ON|OFF" in the command line.
+option(build_cord "Build cord library" ON)
+option(build_tests "Build tests" OFF)
 option(enable_threads "TODO" OFF) #TODO Support it
 option(enable_parallel_mark "Parallelize marking and free list construction" ON)
 option(enable_thread_local_alloc "Turn on thread-local allocation optimization" ON)
@@ -253,6 +256,10 @@ set_target_properties(gcmt-lib PROPERTIES
 
 add_library(gcmt-dll SHARED ${SRC})
 
-add_subdirectory(cord)
+if (build_cord)
+  add_subdirectory(cord)
+endif()
 
-add_subdirectory(tests)
+if (build_tests)
+  add_subdirectory(tests)
+endif()
index 1fb27e9..a0a8a7b 100644 (file)
 
 # TODO add_library(cord ...)
 
-add_executable(cordtest cordbscs.c cordprnt.c cordxtra.c
-               tests/cordtest.c)
-set_target_properties(cordtest PROPERTIES COMPILE_DEFINITIONS GC_NOT_DLL)
-target_link_libraries(cordtest gc-lib)
-add_test(NAME cordtest COMMAND cordtest)
+if (build_tests)
+  add_executable(cordtest cordbscs.c cordprnt.c cordxtra.c
+                 tests/cordtest.c)
+  set_target_properties(cordtest PROPERTIES COMPILE_DEFINITIONS GC_NOT_DLL)
+  target_link_libraries(cordtest gc-lib)
+  add_test(NAME cordtest COMMAND cordtest)
 
-if (WIN32)
-  add_executable(de cordbscs.c cordxtra.c
-                 tests/de.c tests/de_win.c)
-  set_target_properties(de PROPERTIES WIN32_EXECUTABLE TRUE)
-  set_target_properties(de PROPERTIES COMPILE_DEFINITIONS GC_NOT_DLL)
-  target_link_libraries(de gc-lib)
-  target_link_libraries(de gdi32)
+  if (WIN32)
+    add_executable(de cordbscs.c cordxtra.c
+                   tests/de.c tests/de_win.c)
+    set_target_properties(de PROPERTIES WIN32_EXECUTABLE TRUE)
+    set_target_properties(de PROPERTIES COMPILE_DEFINITIONS GC_NOT_DLL)
+    target_link_libraries(de gc-lib)
+    target_link_libraries(de gdi32)
+  endif(WIN32)
 endif()