]> granicus.if.org Git - graphviz/commitdiff
Fix lib/common objs not included in lib/gvc lib for CMake builds
authorMagnus Jacobsson <magnus.jacobsson@berotec.se>
Mon, 14 Sep 2020 13:18:42 +0000 (15:18 +0200)
committerMagnus Jacobsson <magnus.jacobsson@berotec.se>
Wed, 23 Sep 2020 06:37:52 +0000 (08:37 +0200)
This is what the autotools builds do.

For some reason this was not a problem on Windows.

Without this, the rtest/test_examples.py gave errors like this for e.g. demo.c:

demo.c:(.text+0x29): undefined reference to `gvParseArgs'

lib/common/CMakeLists.txt
lib/gvc/CMakeLists.txt

index b96b3e99df3e5e70bc0046e364031d50e9ec7455..75918df5f015d97edefba8a66c421f9aef50ef1d 100644 (file)
@@ -49,7 +49,7 @@ add_custom_command(
                                >> ${CMAKE_CURRENT_BINARY_DIR}/ps_font_equiv.h
 )
 
-add_library(common STATIC
+add_library(common_obj OBJECT
     # Header files
     arith.h
     color.h
@@ -105,7 +105,7 @@ add_library(common STATIC
     ${BISON_HTMLparse_OUTPUTS}
 )
 
-target_include_directories(common PRIVATE
+target_include_directories(common_obj PRIVATE
     ${GRAPHVIZ_LIB_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
@@ -120,14 +120,18 @@ target_include_directories(common PRIVATE
 )
 
 if (WIN32)
-    target_include_directories(common PRIVATE ${WINDOWS_DEPENDENCY_DIR}/include)
+    target_include_directories(common_obj PRIVATE ${WINDOWS_DEPENDENCY_DIR}/include)
 endif()
 
 # From https://gitlab.com/graphviz/graphviz/-/issues/1613 @mdwies 20093010
 if(APPLE)
-    target_compile_options(common PRIVATE "-fno-common")
+    target_compile_options(common_obj PRIVATE "-fno-common")
 endif(APPLE)
 
+add_library(common STATIC
+    $<TARGET_OBJECTS:common_obj>
+)
+
 # Specify headers to be installed
 install(
     FILES
index 156cceafd472a3f16e9ad140ba418d33491ff216..ed4cbab2e60d638244041ad9f2afd53792474f58 100644 (file)
@@ -49,10 +49,13 @@ target_include_directories(gvc PRIVATE
     ${RxSpencer_INCLUDE_DIRS}
 )
 
-target_link_libraries(gvc
+target_link_libraries(gvc PRIVATE
+    $<TARGET_OBJECTS:common_obj>
+)
+
+target_link_libraries(gvc PUBLIC
     cdt
     cgraph
-    common
     label
     pack
     pathplan
@@ -64,11 +67,11 @@ target_link_libraries(gvc
 )
 
 if (NOT WIN32)
-    target_link_libraries(gvc ${LTDL_LIBRARIES})
+    target_link_libraries(gvc PUBLIC ${LTDL_LIBRARIES})
 endif()
 
 if (${with_ortho})
-    target_link_libraries(gvc ortho)
+    target_link_libraries(gvc PUBLIC ortho)
 endif()
 
 # Installation location of library files