Build gc_cpp.cc as gccpp library by CMake script
authorIvan Maidanski <ivmai@mail.ru>
Wed, 19 Jun 2019 22:01:30 +0000 (01:01 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 19 Jun 2019 22:01:30 +0000 (01:01 +0300)
Issue #281 (bdwgc).

This matches the behavior of the Automake-based build script.

* CMakeLists.txt [enable_cplusplus] (SRC): Do not add gc_cpp.cc.
* CMakeLists.txt [enable_cplusplus] (gccpp): Specify add_library and
target_link_libraries.
* CMakeLists.txt [build_tests && enable_cplusplus] (test_cpp): Add gccpp
to target_link_libraries.

CMakeLists.txt

index 9bc3f55..59b4915 100644 (file)
@@ -249,10 +249,6 @@ if (enable_single_obj_compilation OR BUILD_SHARED_LIBS)
   endif(CMAKE_USE_PTHREADS_INIT)
 endif()
 
-if (enable_cplusplus)
-  set(SRC ${SRC} gc_cpp.cc)
-endif()
-
 if (BUILD_SHARED_LIBS)
   add_definitions("-DGC_DLL")
 else()
@@ -261,6 +257,11 @@ endif()
 
 add_library(gc ${SRC})
 
+if (enable_cplusplus)
+  add_library(gccpp gc_cpp.cc)
+  target_link_libraries(gccpp PRIVATE gc)
+endif()
+
 if (build_cord)
   set(CORD_SRC cord/cordbscs.c cord/cordprnt.c cord/cordxtra.c)
   add_library(cord ${CORD_SRC})
@@ -350,7 +351,7 @@ if (build_tests)
 
   if (enable_cplusplus)
     add_executable(test_cpp WIN32 tests/test_cpp.cc)
-    target_link_libraries(test_cpp PRIVATE gc)
+    target_link_libraries(test_cpp PRIVATE gc gccpp)
     add_test(NAME test_cpp COMMAND test_cpp)
   endif()