From ab513cdb5002bbb31956e06e86eee490e8bb5498 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 6 Apr 2022 17:49:56 -0700 Subject: [PATCH] CMake: enable Rsvg plugin Gitlab: #1836 --- CMakeLists.txt | 5 ++++ cmake/config_checks.cmake | 1 + plugin/CMakeLists.txt | 1 + plugin/rsvg/CMakeLists.txt | 49 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 plugin/rsvg/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 16f6ad94a..28e8283a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,6 +202,11 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/graphviz_version.h DESTINATION ${HEADE message(STATUS "Graphviz version: ${GRAPHVIZ_VERSION_FULL}") +find_package(PkgConfig) +if(PkgConfig_FOUND) + pkg_check_modules(SVG_2_36 librsvg-2.0>=2.36.0 cairo>=1.0.0) +endif() + include(config_checks) if(NOT HAVE_GETOPT_H) find_package(GETOPT REQUIRED) diff --git a/cmake/config_checks.cmake b/cmake/config_checks.cmake index 97b03cc90..78a490086 100644 --- a/cmake/config_checks.cmake +++ b/cmake/config_checks.cmake @@ -42,6 +42,7 @@ set( HAVE_ANN ${ANN_FOUND} ) set( HAVE_EXPAT ${EXPAT_FOUND} ) set( HAVE_LIBGD ${GD_FOUND} ) set( HAVE_ZLIB ${ZLIB_FOUND} ) +set( HAVE_SVG_2_36 ${SVG_2_36_FOUND} ) if(LTDL_FOUND) set(ENABLE_LTDL 1) diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index 42c13d6c4..c4608aa7e 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -8,5 +8,6 @@ add_subdirectory(glitz) add_subdirectory(gs) add_subdirectory(neato_layout) add_subdirectory(pango) +add_subdirectory(rsvg) add_subdirectory(webp) add_subdirectory(xlib) diff --git a/plugin/rsvg/CMakeLists.txt b/plugin/rsvg/CMakeLists.txt new file mode 100644 index 000000000..f95fcfdae --- /dev/null +++ b/plugin/rsvg/CMakeLists.txt @@ -0,0 +1,49 @@ +find_package(PANGOCAIRO) +find_package(PkgConfig) +if(PkgConfig_FOUND) + pkg_check_modules(RSVG librsvg-2.0) + pkg_check_modules(XRENDER xrender) +endif() + +if(PANGOCAIRO_FOUND AND RSVG_FOUND AND XRENDER_FOUND) + + add_library(gvplugin_rsvg SHARED + gvloadimage_rsvg.c + gvplugin_rsvg.c + ) + + target_include_directories(gvplugin_rsvg PRIVATE + ../../lib + ../../lib/cdt + ../../lib/cgraph + ../../lib/common + ../../lib/gvc + ../../lib/pathplan + ) + + target_include_directories(gvplugin_rsvg SYSTEM PRIVATE + ${PANGOCAIRO_LIBRARIES} + ${RSVG_LIBRARIES} + ${XRENDER_LIBRARIES} + ) + + install( + TARGETS gvplugin_rsvg + RUNTIME DESTINATION ${BINARY_INSTALL_DIR} + LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} + ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR} + ) + + set_target_properties(gvplugin_rsvg PROPERTIES + VERSION ${GRAPHVIZ_PLUGIN_VERSION}.0.0 + SOVERSION ${GRAPHVIZ_PLUGIN_VERSION} + ) + + if(MINGW) + # work around https://gitlab.kitware.com/cmake/cmake/-/issues/21716 + set_target_properties(gvplugin_rsvg PROPERTIES + RUNTIME_OUTPUT_NAME gvplugin_rsvg-${GRAPHVIZ_PLUGIN_VERSION} + ) + endif() + +endif() -- 2.40.0