]> granicus.if.org Git - graphviz/commitdiff
fix Pango plugin build on macOS
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 19 Aug 2020 00:03:24 +0000 (17:03 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 27 Aug 2020 14:24:43 +0000 (07:24 -0700)
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
plugin/pango/CMakeLists.txt

index c21b80b3f1a1d9f2c3609455f10729212b7860c8..d1e3fee9f6d13496ef8d25ce01b9ebc9ef5ec184 100644 (file)
@@ -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()
index e10fddb06698e8e7608be22c211404705c709bfb..d4048e288145ba730d027c0d0e5a4282611974ae 100644 (file)
@@ -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()