summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-03-18 13:08:05 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-03-18 13:08:12 (GMT)
commitd9ad00119d9d412f6ab245a11f72209704c74c81 (patch)
tree89da235019d2a0c6f2c48f674bedec17ae6d8c4b /Modules
parent2d3eeffc5df3b24c4159d9a27fb4104b9e0e6fec (diff)
parent1c99f5df288dbc8a79a38b20db9ff319eb456fe8 (diff)
downloadCMake-d9ad00119d9d412f6ab245a11f72209704c74c81.zip
CMake-d9ad00119d9d412f6ab245a11f72209704c74c81.tar.gz
CMake-d9ad00119d9d412f6ab245a11f72209704c74c81.tar.bz2
Merge topic 'FindPkgConfig-broken-pkg-config'
1c99f5df28 FindPkgConfig: Add test for specified pkg-config tool missing b59f36aad8 FindPkgConfig: Unset results when pkg-config is broken Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4451
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindPkgConfig.cmake21
1 files changed, 18 insertions, 3 deletions
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index c79f20f..b7e6442 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -34,16 +34,31 @@ endif()
find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable")
mark_as_advanced(PKG_CONFIG_EXECUTABLE)
+set(_PKG_CONFIG_FAILURE_MESSAGE "")
if (PKG_CONFIG_EXECUTABLE)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --version
- OUTPUT_VARIABLE PKG_CONFIG_VERSION_STRING
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
+ OUTPUT_VARIABLE PKG_CONFIG_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE _PKG_CONFIG_VERSION_ERROR ERROR_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE _PKG_CONFIG_VERSION_RESULT
+ )
+
+ if (NOT _PKG_CONFIG_VERSION_RESULT EQUAL 0)
+ string(REPLACE "\n" "\n " _PKG_CONFIG_VERSION_ERROR " ${_PKG_CONFIG_VERSION_ERROR}")
+ string(APPEND _PKG_CONFIG_FAILURE_MESSAGE
+ "The command\n"
+ " \"${PKG_CONFIG_EXECUTABLE}\" --version\n"
+ " failed with output\n${_PKG_CONFIG_VERSION_ERROR}"
+ )
+ set(PKG_CONFIG_EXECUTABLE "")
+ unset(PKG_CONFIG_VERSION_STRING)
+ endif ()
+ unset(_PKG_CONFIG_VERSION_RESULT)
endif ()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(PkgConfig
REQUIRED_VARS PKG_CONFIG_EXECUTABLE
+ REASON_FAILURE_MESSAGE "${_PKG_CONFIG_FAILURE_MESSAGE}"
VERSION_VAR PKG_CONFIG_VERSION_STRING)
# This is needed because the module name is "PkgConfig" but the name of