From 39c58aed0007a897edfc1c7d570860c827d47a53 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 20 Jun 2019 01:01:30 +0300 Subject: [PATCH] Build gc_cpp.cc as gccpp library by CMake script 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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bc3f55..59b4915 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() -- 2.7.4