From: Nehal J Wani Date: Mon, 2 Jan 2023 14:04:33 +0000 (+0000) Subject: CMake: Similar to 3fcf0968, use gdlib.pc if available X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=refs%2Fheads%2Fsmattr%2Fd853834a-1c51-4437-988c-b92e1587fc31;p=graphviz CMake: Similar to 3fcf0968, use gdlib.pc if available The gdlib-config program is no longer installed with the newer versions of the library as it is deprecated. The CMake build on CI for Fedora prints the following, which is no longer the case with this patch: CMake Warning at cmake/FindGD.cmake:63 (message): gdlib-config not found; skipping feature checks Call Stack (most recent call first): contrib/diffimg/CMakeLists.txt:1 (find_package) xref: https://github.com/libgd/libgd/issues/376#issuecomment-276138975 Edits from Matthew Fernandez: - Wrap CMake line - Adjust #1786 work arounds Gitlab: #1786 --- diff --git a/ci/tests.py b/ci/tests.py index e2167a2a8..c8bc1f8ce 100644 --- a/ci/tests.py +++ b/ci/tests.py @@ -166,8 +166,8 @@ def check_that_tool_does_not_exist(tool, os_id): assert which(tool) is None, f"{tool} has been resurrected in the " \ f'{os.getenv("build_system")} build on {os_id}. Please remove skip.' -@pytest.mark.xfail(is_cmake() and not is_centos() - and not platform.system() == "Darwin", +@pytest.mark.xfail(is_cmake() and platform.system() == "Windows" + and not is_mingw(), reason="png:gd unavailable when built with CMake", strict=True) # FIXME def test_1786(): diff --git a/cmake/FindGD.cmake b/cmake/FindGD.cmake index d7e0cc968..0deb5e681 100644 --- a/cmake/FindGD.cmake +++ b/cmake/FindGD.cmake @@ -18,6 +18,11 @@ set(GD_INCLUDE_DIRS ${GD_INCLUDE_DIR}) set(GD_LIBRARIES ${GD_LIBRARY}) set(GD_RUNTIME_LIBRARIES ${GD_RUNTIME_LIBRARY}) +find_package(PkgConfig) +if(PkgConfig_FOUND) + pkg_check_modules(GDLIB gdlib>=2.0.33) +endif() + if(GD_LIBRARY) find_program(GDLIB_CONFIG gdlib-config) if(GDLIB_CONFIG) @@ -50,7 +55,7 @@ if(GD_LIBRARY) set(HAVE_GD_GIF 1) endif() else() - if(APPLE) + if(APPLE OR GDLIB_FOUND) # At time of writing, Macports does not package libgd. So assume the user # obtained this through Homebrew and hard code the options the Homebrew # package enables. @@ -60,7 +65,9 @@ if(GD_LIBRARY) set(HAVE_GD_FREETYPE 1) set(HAVE_GD_GIF 1) else() - message(WARNING "gdlib-config not found; skipping feature checks") + message( + WARNING + "gdlib-config/gdlib pkgconfig not found; skipping feature checks") endif() endif() endif()