From 4cd0de67de9cc64b72abc11489a29959ac4e18ec Mon Sep 17 00:00:00 2001 From: Victor Romero Date: Thu, 6 Jun 2019 10:24:28 +0300 Subject: [PATCH] Do not build the tests by default (CMake) 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 | 11 +++++++++-- cord/CMakeLists.txt | 26 ++++++++++++++------------ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d386ca..4175e07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,9 @@ include(CTest) cmake_minimum_required(VERSION 3.1) +# Customize the build by passing "-D=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() diff --git a/cord/CMakeLists.txt b/cord/CMakeLists.txt index 1fb27e9..a0a8a7b 100644 --- a/cord/CMakeLists.txt +++ b/cord/CMakeLists.txt @@ -13,17 +13,19 @@ # 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() -- 2.7.4