]> granicus.if.org Git - graphviz/commitdiff
CMake: Similar to 3fcf0968, use gdlib.pc if available smattr/d853834a-1c51-4437-988c-b92e1587fc31
authorNehal J Wani <nehaljw.kkd1@gmail.com>
Mon, 2 Jan 2023 14:04:33 +0000 (14:04 +0000)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 8 Jan 2023 19:43:44 +0000 (11:43 -0800)
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

ci/tests.py
cmake/FindGD.cmake

index e2167a2a80e54a31f55a10267ef3f696a45282ac..c8bc1f8cef3525aa997da43b1a29fa5c55cfa4b1 100644 (file)
@@ -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():
index d7e0cc968814d790e93b3a0707bbc29a192b3601..0deb5e6818bf1d7216caa3b9a52b13cb65f56de4 100644 (file)
@@ -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()