From b4f998c133566ef9cb416c085d1ce49e539bec30 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 23 Aug 2020 11:30:08 -0700 Subject: [PATCH] update CMake Cairo discovery to match PangoCairo 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 | 69 +++++++++++++++++-------------------- plugin/pango/CMakeLists.txt | 8 ++--- 2 files changed, 35 insertions(+), 42 deletions(-) diff --git a/cmake/FindCairo.cmake b/cmake/FindCairo.cmake index bd7f9b56b..bd5149472 100644 --- a/cmake/FindCairo.cmake +++ b/cmake/FindCairo.cmake @@ -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() diff --git a/plugin/pango/CMakeLists.txt b/plugin/pango/CMakeLists.txt index d4048e288..093cb8e5c 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} @@ -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} ) -- 2.40.0