From 7804427d649d5850c3bc4bd71298eaff504a5a1c Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 5 Jun 2019 09:53:15 +0300 Subject: [PATCH] Turn off C++ API in CMake script by default Issue #281 (bdwgc). This is to match the behavior of configure script. Now, -Denable_cplusplus=ON should be passed to cmake to enable C++ API. * CMakeLists.txt (enable_cplusplus): Add option (off by default); remove TODO. * CMakeLists.txt (SRC): Add gc_cpp.cc only if enable_cplusplus. * tests/CMakeLists.txt (leak_test.c, test.c): Set CXX langunage property only if enable_cplusplus. * tests/CMakeLists.txt [enable_cplusplus]: Add TODO to add test_cpp as a test. --- CMakeLists.txt | 6 ++++-- tests/CMakeLists.txt | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fac59d..f15f90e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ 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) option(enable_threads_discovery "Enable threads discovery in GC" ON) -#TODO Support OPTION(enable_cplusplus "install C++ support" OFF) +option(enable_cplusplus "C++ support" OFF) option(enable_gcj_support "Support for gcj" ON) option(enable_sigrt_signals "Use SIGRTMIN-based signals for thread suspend/resume" OFF) option(enable_gc_debug "Support for pointer back-tracing" OFF) @@ -87,7 +87,9 @@ endif() # MESSAGE("Parallel mark requires enable_threads ON" ) #ENDIF(Threads_FOUND) -set(SRC ${SRC} gc_cpp.cc) +if (enable_cplusplus) + set(SRC ${SRC} gc_cpp.cc) +endif() set(_HOST ${CMAKE_HOST_SYSTEM_PROCESSOR}--${CMAKE_SYSTEM}) #FIXME missing the vendor field. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5bdbea7..dd233ec 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -17,10 +17,10 @@ add_definitions("-DGC_NOT_DLL") # Compile some tests as C++ to test extern "C" in header files. -set_source_files_properties( - leak_test.c - test.c - PROPERTIES LANGUAGE CXX) +if (enable_cplusplus) + set_source_files_properties(leak_test.c test.c + PROPERTIES LANGUAGE CXX) +endif() add_executable(gctest WIN32 test.c) target_link_libraries(gctest gc-lib) @@ -45,3 +45,9 @@ add_test(NAME realloc_test COMMAND realloc_test) add_executable(smashtest smash_test.c) target_link_libraries(smashtest gc-lib) add_test(NAME smashtest COMMAND smashtest) + +if (enable_cplusplus) + # TODO add_executable(test_cpp test_cpp.cc) + # target_link_libraries(test_cpp gc-lib) + # add_test(NAME test_cpp COMMAND test_cpp) +endif() -- 2.7.4