]> granicus.if.org Git - graphviz/commitdiff
CMake: add 'dot_builtins'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 11 Nov 2022 16:35:44 +0000 (08:35 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 13 Nov 2022 22:02:49 +0000 (14:02 -0800)
This attempts to replicate how this target is defined in the Autotools build
system, but involved some amount of guesswork because the Autotools build system
is not explicit with _why_ it is adding particular dependencies to link/include
lists.

The rpath tweak in this commit required surprisingly lengthy debugging to arrive
at. I am still not completely confident it is correct nor that this is the right
way to do such things.

Gitlab: #1836

CHANGELOG.md
ci/tests.py
cmd/dot/CMakeLists.txt

index b8a3dba8c51312cd188ee4df45528bed8ba3ad3a..70add55ce0c269f20ed82426aff8ce6c2351959f 100644 (file)
@@ -8,8 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Added
 
-- The `cluster`, `dot2gxl`, `gv2gxl`, and `prune` utilities are now included in
-  the CMake build system. #1836
+- The `cluster`, `dot_builtins`, `dot2gxl`, `gv2gxl`, and `prune` utilities are
+  now included in the CMake build system. #1836
 
 ### Fixed
 
index 3dfa6e05d59b599dc0570dccd7cad55883dc8a12..db90d79cd7bd7642d71ad1bd7fe21240b5e0c325 100644 (file)
@@ -98,7 +98,6 @@ def test_existence(binary: str):
   """
 
   tools_not_built_with_cmake = [
-    "dot_builtins",
     "gvedit",
   ]
 
index cab0cbff72d54d54a51f2e09013313f1cd84971e..e1f8c883a98195b967d4c6099b823ea26b4fe9fc 100644 (file)
@@ -29,6 +29,76 @@ install(
   ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
 )
 
+add_executable(dot_builtins
+  dot.c
+  dot_builtins.cpp
+)
+
+# teach dot_builtins how to find plugins at run time
+if(APPLE)
+  set_target_properties(dot_builtins PROPERTIES
+    INSTALL_RPATH "@executable_path/../${PLUGIN_INSTALL_DIR}")
+else()
+  set_target_properties(dot_builtins PROPERTIES
+    INSTALL_RPATH "\$ORIGIN/../${PLUGIN_INSTALL_DIR}")
+endif()
+
+target_link_libraries(dot_builtins PRIVATE
+  cdt
+  cgraph
+  gvc
+  gvplugin_core
+  gvplugin_dot_layout
+  gvplugin_neato_layout
+  pathplan
+  xdot
+)
+
+if(EXPAT_FOUND)
+  target_include_directories(dot_builtins SYSTEM PRIVATE ${EXPAT_INCLUDE_DIRS})
+  target_link_libraries(dot_builtins PRIVATE ${EXPAT_LIBRARIES})
+endif()
+
+if(GD_FOUND)
+  target_link_libraries(dot_builtins PRIVATE gvplugin_gd)
+endif()
+
+find_package(PkgConfig)
+if(PkgConfig_FOUND)
+  pkg_check_modules(GTS gts)
+  if(GTS_FOUND)
+    target_include_directories(dot_builtins SYSTEM PRIVATE ${GTS_INCLUDE_DIRS})
+    target_link_libraries(dot_builtins PRIVATE ${GTS_LIBRARIES})
+  endif()
+
+  pkg_check_modules(LASI lasi)
+  if(LASI_FOUND)
+    target_link_libraries(dot_builtins PRIVATE gvplugin_lasi)
+  endif()
+endif()
+
+if(PANGOCAIRO_FOUND)
+  target_link_libraries(dot_builtins PRIVATE gvplugin_pango)
+  if(PkgConfig_FOUND)
+    pkg_check_modules(WEBP libwebp)
+    if(WEBP_FOUND)
+      target_link_libraries(dot_builtins PRIVATE gvplugin_webp)
+    endif()
+  endif()
+endif()
+
+find_library(SOCKET socket)
+if(SOCKET)
+  target_link_libraries(dot_builtins PRIVATE ${SOCKET})
+endif()
+
+install(
+  TARGETS dot_builtins
+  RUNTIME DESTINATION ${BINARY_INSTALL_DIR}
+  LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
+  ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
+)
+
 # Aliases to the dot executable (not including '.exe' suffix)
 list(APPEND dot_aliases circo fdp neato osage patchwork sfdp twopi)