From 3ecf2f6206a486fecdea870b7f29ea539345642a Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 18 Aug 2020 17:03:24 -0700 Subject: [PATCH] fix Pango plugin build on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Compiling plugin/pango depends on the discovery of PangoCairo and its dependent libraries which is handled by cmake/FindPangoCairo.cmake. This file was assuming all libraries were available at default system paths, which is not true on e.g. macOS when you install libraries via Homebrew or Macports. We now simply ask pkg-config to find all necessary information for us (unless we are on Windows). This also incidentally cleans up the following warning issued by CMake in CI: CMake Warning (dev) at C:/…/FindPackageHandleStandardArgs.cmake:272 (message): The package name passed to `find_package_handle_standard_args` (PANGOCAIRO) does not match the name of the calling package (PangoCairo). This can lead to problems in calling code that expects `find_package` result variables (e.g., `_FOUND`) to follow a certain pattern. Call Stack (most recent call first): cmake/FindPangoCairo.cmake:20 (find_package_handle_standard_args) CMakeLists.txt:85 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. --- cmake/FindPangoCairo.cmake | 123 ++++++++++++++++-------------------- plugin/pango/CMakeLists.txt | 10 +-- 2 files changed, 60 insertions(+), 73 deletions(-) diff --git a/cmake/FindPangoCairo.cmake b/cmake/FindPangoCairo.cmake index c21b80b3f..d1e3fee9f 100644 --- a/cmake/FindPangoCairo.cmake +++ b/cmake/FindPangoCairo.cmake @@ -1,91 +1,78 @@ -find_path(PANGOCAIRO_INCLUDE_DIR pango/pangocairo.h PATH_SUFFIXES pango-1.0) -find_path(GLIB_INCLUDE_DIR glib.h PATH_SUFFIXES glib-2.0) -find_path(GLIBCONFIG_INCLUDE_DIR glibconfig.h PATH_SUFFIXES glib-2.0/include) +include(FindPackageHandleStandardArgs) -find_library(GLIB_LIBRARY NAMES glib-2.0) -find_library(GOBJECT_LIBRARY NAMES gobject-2.0) -find_library(PANGO_LIBRARY NAMES pango-1.0) -find_library(PANGOCAIRO_LIBRARY NAMES pangocairo-1.0) +if (WIN32) + find_path(PangoCairo_INCLUDE_DIR pango/pangocairo.h PATH_SUFFIXES pango-1.0) + find_path(GLIB_INCLUDE_DIR glib.h PATH_SUFFIXES glib-2.0) + find_path(GLIBCONFIG_INCLUDE_DIR glibconfig.h PATH_SUFFIXES glib-2.0/include) -find_file(GLIB_RUNTIME_LIBRARY NAMES glib-2.dll) -find_file(GOBJECT_RUNTIME_LIBRARY NAMES gobject-2.dll) -find_file(HARFBUZZ_RUNTIME_LIBRARY NAMES libharfbuzz-0.dll) -find_file(PANGO_RUNTIME_LIBRARY NAMES pango-1.dll) -find_file(PANGOCAIRO_RUNTIME_LIBRARY NAMES pangocairo-1.dll) -find_file(PANGOFT_RUNTIME_LIBRARY NAMES pangoft2-1.dll) -find_file(PANGOWIN_RUNTIME_LIBRARY NAMES pangowin32-1.dll) + find_library(GLIB_LIBRARY NAMES glib-2.0) + find_library(GOBJECT_LIBRARY NAMES gobject-2.0) + find_library(PANGO_LIBRARY NAMES pango-1.0) + find_library(PangoCairo_LIBRARY NAMES pangocairo-1.0) -include(FindPackageHandleStandardArgs) -if (WIN32) - find_package_handle_standard_args(PANGOCAIRO DEFAULT_MSG + find_file(GLIB_RUNTIME_LIBRARY NAMES glib-2.dll) + find_file(GOBJECT_RUNTIME_LIBRARY NAMES gobject-2.dll) + find_file(HARFBUZZ_RUNTIME_LIBRARY NAMES libharfbuzz-0.dll) + find_file(PANGO_RUNTIME_LIBRARY NAMES pango-1.dll) + find_file(PangoCairo_RUNTIME_LIBRARY NAMES pangocairo-1.dll) + find_file(PANGOFT_RUNTIME_LIBRARY NAMES pangoft2-1.dll) + find_file(PANGOWIN_RUNTIME_LIBRARY NAMES pangowin32-1.dll) + + find_package_handle_standard_args(PangoCairo DEFAULT_MSG GLIB_INCLUDE_DIR GLIBCONFIG_INCLUDE_DIR - PANGOCAIRO_INCLUDE_DIR + PangoCairo_INCLUDE_DIR GLIB_LIBRARY GOBJECT_LIBRARY PANGO_LIBRARY - PANGOCAIRO_LIBRARY + PangoCairo_LIBRARY GLIB_RUNTIME_LIBRARY GOBJECT_RUNTIME_LIBRARY HARFBUZZ_RUNTIME_LIBRARY PANGO_RUNTIME_LIBRARY - PANGOCAIRO_RUNTIME_LIBRARY + PangoCairo_RUNTIME_LIBRARY PANGOFT_RUNTIME_LIBRARY PANGOWIN_RUNTIME_LIBRARY ) -else() - find_package_handle_standard_args(PANGOCAIRO DEFAULT_MSG - GLIB_INCLUDE_DIR - GLIBCONFIG_INCLUDE_DIR - PANGOCAIRO_INCLUDE_DIR - GLIB_LIBRARY - GOBJECT_LIBRARY - PANGO_LIBRARY - PANGOCAIRO_LIBRARY + set(PangoCairo_INCLUDE_DIRS + ${GLIB_INCLUDE_DIR} + ${GLIBCONFIG_INCLUDE_DIR} + ${PangoCairo_INCLUDE_DIR} ) -endif() - -mark_as_advanced( - GLIB_INCLUDE_DIR - GLIBCONFIG_INCLUDE_DIR - PANGOCAIRO_INCLUDE_DIR - GLIB_LIBRARY - GOBJECT_LIBRARY - PANGO_LIBRARY - PANGOCAIRO_LIBRARY - - GLIB_RUNTIME_LIBRARY - GOBJECT_RUNTIME_LIBRARY - HARFBUZZ_RUNTIME_LIBRARY - PANGO_RUNTIME_LIBRARY - PANGOCAIRO_RUNTIME_LIBRARY - PANGOFT_RUNTIME_LIBRARY - PANGOWIN_RUNTIME_LIBRARY -) + set(PangoCairo_LIBRARIES + glib-2.0 + gobject-2.0 + pango-1.0 + pangocairo-1.0 + ) -set(PANGOCAIRO_INCLUDE_DIRS - ${GLIB_INCLUDE_DIR} - ${GLIBCONFIG_INCLUDE_DIR} - ${PANGOCAIRO_INCLUDE_DIR} -) + set(PangoCairo_LINK_LIBRARIES + ${GLIB_LIBRARY} + ${GOBJECT_LIBRARY} + ${PANGO_LIBRARY} + ${PangoCairo_LIBRARY} + ) -set(PANGOCAIRO_LIBRARIES - ${GLIB_LIBRARY} - ${GOBJECT_LIBRARY} - ${PANGO_LIBRARY} - ${PANGOCAIRO_LIBRARY} -) + set(PangoCairo_RUNTIME_LIBRARIES + ${GLIB_RUNTIME_LIBRARY} + ${GOBJECT_RUNTIME_LIBRARY} + ${HARFBUZZ_RUNTIME_LIBRARY} + ${PANGO_RUNTIME_LIBRARY} + ${PangoCairo_RUNTIME_LIBRARY} + ${PANGOFT_RUNTIME_LIBRARY} + ${PANGOWIN_RUNTIME_LIBRARY} + ) +else() + find_package(PkgConfig) + pkg_check_modules(PangoCairo pangocairo) -set(PANGOCAIRO_RUNTIME_LIBRARIES - ${GLIB_RUNTIME_LIBRARY} - ${GOBJECT_RUNTIME_LIBRARY} - ${HARFBUZZ_RUNTIME_LIBRARY} - ${PANGO_RUNTIME_LIBRARY} - ${PANGOCAIRO_RUNTIME_LIBRARY} - ${PANGOFT_RUNTIME_LIBRARY} - ${PANGOWIN_RUNTIME_LIBRARY} -) + find_package_handle_standard_args(PangoCairo DEFAULT_MSG + PangoCairo_INCLUDE_DIRS + PangoCairo_LIBRARIES + PangoCairo_LINK_LIBRARIES + ) +endif() diff --git a/plugin/pango/CMakeLists.txt b/plugin/pango/CMakeLists.txt index e10fddb06..d4048e288 100644 --- a/plugin/pango/CMakeLists.txt +++ b/plugin/pango/CMakeLists.txt @@ -1,4 +1,4 @@ -if(CAIRO_FOUND AND PANGOCAIRO_FOUND) +if(CAIRO_FOUND AND PangoCairo_FOUND) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} @@ -9,7 +9,7 @@ include_directories( ${GRAPHVIZ_LIB_DIR}/gvc ${GRAPHVIZ_LIB_DIR}/pathplan ${CAIRO_INCLUDE_DIRS}/cairo - ${PANGOCAIRO_INCLUDE_DIRS} + ${PangoCairo_INCLUDE_DIRS} ) add_library(gvplugin_pango SHARED @@ -28,7 +28,7 @@ add_library(gvplugin_pango SHARED target_link_libraries(gvplugin_pango gvc ${CAIRO_LIBRARIES} - ${PANGOCAIRO_LIBRARIES} + ${PangoCairo_LINK_LIBRARIES} ) # Installation location of library files @@ -44,7 +44,7 @@ if (WIN32) install( FILES ${CAIRO_RUNTIME_LIBRARIES} - ${PANGOCAIRO_RUNTIME_LIBRARIES} + ${PangoCairo_RUNTIME_LIBRARIES} DESTINATION ${BINARY_INSTALL_DIR} ) endif() @@ -55,4 +55,4 @@ set_target_properties(gvplugin_pango PROPERTIES SOVERSION ${GRAPHVIZ_PLUGIN_VERSION} ) -endif(CAIRO_FOUND AND PANGOCAIRO_FOUND) +endif() -- 2.40.0