diff --git a/CMakeLists.txt b/CMakeLists.txt index dbda0d9193c9c3ceabc08ac3af69ba9a057ca792..5ba19e0fb68575f93d5ec122afd807096e1cb614 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,11 +27,10 @@ set(with_tclpkg AUTO CACHE STRING "Build TCL components") set_property(CACHE with_tclpkg PROPERTY STRINGS AUTO ON OFF) if(WIN32) - # Build dynamic-link libraries on Windows, including MinGW. The - # CMake build system does not currently support building static - # libraries, so the GVDLL symbol can be unconditionally set until - # such support is introduced. - add_definitions(-DGVDLL) + if(BUILD_SHARED_LIBS) + # GVDLL definition exports symbols + add_definitions(-DGVDLL) + endif() option(install_win_dependency_dlls "Install 3rd party dependencies" ON) endif() diff --git a/cmd/dot/CMakeLists.txt b/cmd/dot/CMakeLists.txt index 8748e4b4b26aa6e5d8707acb42beb9e048e68f21..1e2982022cf83d8aead42869b1c38c6937a75dfd 100644 --- a/cmd/dot/CMakeLists.txt +++ b/cmd/dot/CMakeLists.txt @@ -1,4 +1,10 @@ -add_definitions(-DDEMAND_LOADING=1) +if(BUILD_SHARED_LIBS) + add_definitions(-DDEMAND_LOADING=1) + set(DOT_TARGET dot) +else() + add_definitions(-DDEMAND_LOADING=0) + set(DOT_TARGET dot_static) +endif() include_directories( ../../lib @@ -10,28 +16,31 @@ include_directories( ../../lib/pathplan ) -add_executable(dot +add_executable(${DOT_TARGET} # Source files dot.c no_builtins.c ) -target_link_libraries(dot PRIVATE +target_link_libraries(${DOT_TARGET} PRIVATE cgraph gvc ) if(APPLE) - set_target_properties(dot PROPERTIES LINK_FLAGS -Wl,-stack_size,0x2000000) + set_target_properties(${DOT_TARGET} PROPERTIES + LINK_FLAGS -Wl,-stack_size,0x2000000) elseif(MINGW) - set_target_properties(dot PROPERTIES LINK_FLAGS -Wl,--stack,0x2000000) + set_target_properties(${DOT_TARGET} PROPERTIES + LINK_FLAGS -Wl,--stack,0x2000000) elseif(WIN32) - set_target_properties(dot PROPERTIES LINK_FLAGS /STACK:"33554432") + set_target_properties(${DOT_TARGET} PROPERTIES + LINK_FLAGS /STACK:"33554432") endif() # Installation location of executables install( - TARGETS dot + TARGETS ${DOT_TARGET} RUNTIME DESTINATION ${BINARY_INSTALL_DIR} LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR} @@ -111,10 +120,10 @@ foreach(cmd_alias IN LISTS dot_aliases) if(WIN32 OR CYGWIN) # Copy dot executable to each alias name then install copies to bindir add_custom_command( - TARGET dot + TARGET ${DOT_TARGET} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ ${DOTCOPY} - COMMENT "Copying dot to ${DOTCOPY}" + COMMAND ${CMAKE_COMMAND} -E copy $ ${DOTCOPY} + COMMENT "Copying ${DOT_TARGET} to ${DOTCOPY}" ) install( PROGRAMS ${DOTCOPY} @@ -128,12 +137,14 @@ foreach(cmd_alias IN LISTS dot_aliases) # ${CMAKE_CURRENT_BINARY_DIR}/dot is installed to ${BINARY_INSTALL_DIR}/dot. # There is a (small?) risk of dangling symlinks add_custom_command( - TARGET dot + TARGET ${DOT_TARGET} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E create_symlink $ + COMMAND ${CMAKE_COMMAND} + -E create_symlink + $ ${cmd_alias} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Linking dot as ${cmd_alias}" + COMMENT "Linking ${DOT_TARGET} as ${cmd_alias}" ) install( FILES ${DOTCOPY} diff --git a/plugin/dot_layout/CMakeLists.txt b/plugin/dot_layout/CMakeLists.txt index 21a2d239044ec9ff6e56e7741160395108162a64..e35560f56001e925ecb1667b35b84ab3a703add3 100644 --- a/plugin/dot_layout/CMakeLists.txt +++ b/plugin/dot_layout/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(gvplugin_dot_layout SHARED +add_library(gvplugin_dot_layout # Source files gvplugin_dot_layout.c gvlayout_dot_layout.c diff --git a/plugin/neato_layout/CMakeLists.txt b/plugin/neato_layout/CMakeLists.txt index 180b7250b48dd4482eb6c80fdba17be6c78bc56d..c92032a5c253c5d90f6b6e7868d98c20269ca674 100644 --- a/plugin/neato_layout/CMakeLists.txt +++ b/plugin/neato_layout/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(gvplugin_neato_layout SHARED +add_library(gvplugin_neato_layout # Source files gvplugin_neato_layout.c gvlayout_neato_layout.c diff --git a/plugin/pango/CMakeLists.txt b/plugin/pango/CMakeLists.txt index 16c6f8d89c6c250adee79765f26734983ffe9713..1502e264aeb3ddf3716ac91d4007f11cad9b273b 100644 --- a/plugin/pango/CMakeLists.txt +++ b/plugin/pango/CMakeLists.txt @@ -1,6 +1,6 @@ if(CAIRO_FOUND AND PANGOCAIRO_FOUND) - add_library(gvplugin_pango SHARED + add_library(gvplugin_pango # Header files gvgetfontlist.h gvplugin_pango.h