From 0c3880494c4f4e18ad4e508f2070b7654b5cd49f Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 26 Feb 2022 14:25:28 -0800 Subject: [PATCH] CMake: only use 'gdlib-config' if libgd is found This is mostly just over-cautiousness to not accidentally define variables like `HAVE_GD_PNG` if we not have libgd. But it will also ease some upcoming macOS-specific changes. Gitlab: #1786 --- cmake/FindGD.cmake | 64 ++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/cmake/FindGD.cmake b/cmake/FindGD.cmake index d2de4e71f..fddbbb1bf 100644 --- a/cmake/FindGD.cmake +++ b/cmake/FindGD.cmake @@ -18,36 +18,38 @@ set(GD_INCLUDE_DIRS ${GD_INCLUDE_DIR}) set(GD_LIBRARIES ${GD_LIBRARY}) set(GD_RUNTIME_LIBRARIES ${GD_RUNTIME_LIBRARY}) -find_program(GDLIB_CONFIG gdlib-config) -if(GDLIB_CONFIG) - message(STATUS "Found gdlib-config: ${GDLIB_CONFIG}") - execute_process(COMMAND ${GDLIB_CONFIG} --features - RESULT_VARIABLE GDLIB_CONFIG_EXIT_STATUS - OUTPUT_VARIABLE GD_FEATURES - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT GDLIB_CONFIG_EXIT_STATUS EQUAL 0) - message(FATAL_ERROR "Failed to query GD features") +if(GD_LIBRARY) + find_program(GDLIB_CONFIG gdlib-config) + if(GDLIB_CONFIG) + message(STATUS "Found gdlib-config: ${GDLIB_CONFIG}") + execute_process(COMMAND ${GDLIB_CONFIG} --features + RESULT_VARIABLE GDLIB_CONFIG_EXIT_STATUS + OUTPUT_VARIABLE GD_FEATURES + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT GDLIB_CONFIG_EXIT_STATUS EQUAL 0) + message(FATAL_ERROR "Failed to query GD features") + endif() + message(STATUS "Detected GD features: ${GD_FEATURES}") + string(REPLACE " " ";" GD_FEATURES_LIST ${GD_FEATURES}) + if("GD_PNG" IN_LIST GD_FEATURES_LIST) + set(HAVE_GD_PNG 1) + endif() + if("GD_JPEG" IN_LIST GD_FEATURES_LIST) + set(HAVE_GD_JPEG 1) + endif() + if("GD_XPM" IN_LIST GD_FEATURES_LIST) + set(HAVE_GD_XPM 1) + endif() + if("GD_FONTCONFIG" IN_LIST GD_FEATURES_LIST) + set(HAVE_GD_FONTCONFIG 1) + endif() + if("GD_FREETYPE" IN_LIST GD_FEATURES_LIST) + set(HAVE_GD_FREETYPE 1) + endif() + if("GD_GIF" IN_LIST GD_FEATURES_LIST) + set(HAVE_GD_GIF 1) + endif() + else() + message(WARNING "gdlib-config not found; skipping feature checks") endif() - message(STATUS "Detected GD features: ${GD_FEATURES}") - string(REPLACE " " ";" GD_FEATURES_LIST ${GD_FEATURES}) - if("GD_PNG" IN_LIST GD_FEATURES_LIST) - set(HAVE_GD_PNG 1) - endif() - if("GD_JPEG" IN_LIST GD_FEATURES_LIST) - set(HAVE_GD_JPEG 1) - endif() - if("GD_XPM" IN_LIST GD_FEATURES_LIST) - set(HAVE_GD_XPM 1) - endif() - if("GD_FONTCONFIG" IN_LIST GD_FEATURES_LIST) - set(HAVE_GD_FONTCONFIG 1) - endif() - if("GD_FREETYPE" IN_LIST GD_FEATURES_LIST) - set(HAVE_GD_FREETYPE 1) - endif() - if("GD_GIF" IN_LIST GD_FEATURES_LIST) - set(HAVE_GD_GIF 1) - endif() -else() - message(WARNING "gdlib-config not found; skipping feature checks") endif() -- 2.40.0