]> granicus.if.org Git - graphviz/commitdiff
update CMake Cairo discovery to match PangoCairo
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 23 Aug 2020 18:30:08 +0000 (11:30 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 27 Aug 2020 14:24:43 +0000 (07:24 -0700)
This does the equivalent of the previous commit, to now use pkg-config to
discover Cairo on non-Windows platforms and to suppress the CMake warning:

  CMake Warning (dev) at ...FindPackageHandleStandardArgs.cmake:272 (message):
    The package name passed to `find_package_handle_standard_args` (CAIRO) does
    not match the name of the calling package (Cairo).  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/FindCairo.cmake:12 (find_package_handle_standard_args)
    CMakeLists.txt:81 (find_package)
  This warning is for project developers.  Use -Wno-dev to suppress it.

cmake/FindCairo.cmake
plugin/pango/CMakeLists.txt

index bd7f9b56b9f090fa80d306a09cf10d6fee43d5dc..bd51494720c93b6f905a0ac508c41719ee46c1f2 100644 (file)
@@ -1,52 +1,45 @@
-find_path(CAIRO_INCLUDE_DIR cairo/cairo.h)
+include(FindPackageHandleStandardArgs)
 
-find_library(CAIRO_LIBRARY NAMES cairo)
+if (WIN32)
+    find_path(Cairo_INCLUDE_DIR cairo/cairo.h)
 
-find_file(CAIRO_RUNTIME_LIBRARY NAMES cairo.dll)
-find_file(EXPAT_RUNTIME_LIBRARY NAMES expat.dll)
-find_file(FONTCONFIG_RUNTIME_LIBRARY NAMES fontconfig.dll)
-find_file(PIXMAN_RUNTIME_LIBRARY NAMES pixman-1.dll)
+    find_library(Cairo_LIBRARY NAMES cairo)
 
-include(FindPackageHandleStandardArgs)
-if (WIN32)
-    find_package_handle_standard_args(CAIRO DEFAULT_MSG
-        CAIRO_INCLUDE_DIR
+    find_file(Cairo_RUNTIME_LIBRARY NAMES cairo.dll)
+    find_file(EXPAT_RUNTIME_LIBRARY NAMES expat.dll)
+    find_file(FONTCONFIG_RUNTIME_LIBRARY NAMES fontconfig.dll)
+    find_file(PIXMAN_RUNTIME_LIBRARY NAMES pixman-1.dll)
 
-        CAIRO_LIBRARY
+    find_package_handle_standard_args(Cairo DEFAULT_MSG
+        Cairo_INCLUDE_DIR
 
-        CAIRO_RUNTIME_LIBRARY
+        Cairo_LIBRARY
+
+        Cairo_RUNTIME_LIBRARY
         EXPAT_RUNTIME_LIBRARY
         FONTCONFIG_RUNTIME_LIBRARY
         PIXMAN_RUNTIME_LIBRARY
     )
-else()
-    find_package_handle_standard_args(CAIRO DEFAULT_MSG
-        CAIRO_INCLUDE_DIR
-
-        CAIRO_LIBRARY
-    )
-endif()
 
-mark_as_advanced(
-    CAIRO_INCLUDE_DIR
+    set(Cairo_INCLUDE_DIRS ${Cairo_INCLUDE_DIR})
 
-    CAIRO_LIBRARY
+    set(Cairo_LIBRARIES ${Cairo_LIBRARY})
 
-    CAIRO_RUNTIME_LIBRARY
-    EXPAT_RUNTIME_LIBRARY
-    FONTCONFIG_RUNTIME_LIBRARY
-    PIXMAN_RUNTIME_LIBRARY
-)
+    set(Cairo_LINK_LIBRARIES ${Cairo_LIBRARY})
 
-set(CAIRO_INCLUDE_DIRS ${CAIRO_INCLUDE_DIR})
-
-set(CAIRO_LIBRARIES
-    ${CAIRO_LIBRARY}
-)
+    set(Cairo_RUNTIME_LIBRARIES
+        ${Cairo_RUNTIME_LIBRARY}
+        ${EXPAT_RUNTIME_LIBRARY}
+        ${FONTCONFIG_RUNTIME_LIBRARY}
+        ${PIXMAN_RUNTIME_LIBRARY}
+    )
+else()
+    find_package(PkgConfig)
+    pkg_check_modules(Cairo cairo)
 
-set(CAIRO_RUNTIME_LIBRARIES
-    ${CAIRO_RUNTIME_LIBRARY}
-    ${EXPAT_RUNTIME_LIBRARY}
-    ${FONTCONFIG_RUNTIME_LIBRARY}
-    ${PIXMAN_RUNTIME_LIBRARY}
-)
+    find_package_handle_standard_args(Cairo DEFAULT_MSG
+        Cairo_INCLUDE_DIRS
+        Cairo_LIBRARIES
+        Cairo_LINK_LIBRARIES
+    )
+endif()
index d4048e288145ba730d027c0d0e5a4282611974ae..093cb8e5cf26477997e65df83d3a025925440760 100644 (file)
@@ -1,4 +1,4 @@
-if(CAIRO_FOUND AND PangoCairo_FOUND)
+if(Cairo_FOUND AND PangoCairo_FOUND)
 
 include_directories(
     ${CMAKE_CURRENT_SOURCE_DIR}
@@ -8,7 +8,7 @@ include_directories(
     ${GRAPHVIZ_LIB_DIR}/common
     ${GRAPHVIZ_LIB_DIR}/gvc
     ${GRAPHVIZ_LIB_DIR}/pathplan
-    ${CAIRO_INCLUDE_DIRS}/cairo
+    ${Cairo_INCLUDE_DIRS}/cairo
     ${PangoCairo_INCLUDE_DIRS}
 )
 
@@ -27,7 +27,7 @@ add_library(gvplugin_pango SHARED
 
 target_link_libraries(gvplugin_pango
     gvc
-    ${CAIRO_LIBRARIES}
+    ${Cairo_LINK_LIBRARIES}
     ${PangoCairo_LINK_LIBRARIES}
 )
 
@@ -43,7 +43,7 @@ install(
 if (WIN32)
     install(
         FILES
-            ${CAIRO_RUNTIME_LIBRARIES}
+            ${Cairo_RUNTIME_LIBRARIES}
             ${PangoCairo_RUNTIME_LIBRARIES}
         DESTINATION ${BINARY_INSTALL_DIR}
     )