]> granicus.if.org Git - gc/commitdiff
Turn off C++ API in CMake script by default
authorIvan Maidanski <ivmai@mail.ru>
Wed, 5 Jun 2019 06:53:15 +0000 (09:53 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 5 Jun 2019 06:53:15 +0000 (09:53 +0300)
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
tests/CMakeLists.txt

index 4fac59d1a17355ce8811622bd64ea04d6a3622ae..f15f90efdc7a50c3f0c42a3ce75a3952f94f70f8 100644 (file)
@@ -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.
index 5bdbea74ac8b1b40aaab8dd06c48338a1c6b7319..dd233ec49f90354b78ea5d7aadbddd216dd21c54 100644 (file)
 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()