From 3201dd521e1b816dca9caba8792b5a5890546d1c Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 25 Sep 2020 15:44:46 +0200 Subject: FindPkgConfig: Show more info when pkg-config --version fails Fixes: #21239 --- Modules/FindPkgConfig.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 93827d8..6294a4c 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -47,7 +47,9 @@ if (PKG_CONFIG_EXECUTABLE) string(APPEND _PKG_CONFIG_FAILURE_MESSAGE "The command\n" " \"${PKG_CONFIG_EXECUTABLE}\" --version\n" - " failed with output\n${_PKG_CONFIG_VERSION_ERROR}" + " failed with output:\n${PKG_CONFIG_VERSION_STRING}\n" + " stderr: \n${_PKG_CONFIG_VERSION_ERROR}\n" + " result: \n${_PKG_CONFIG_VERSION_RESULT}" ) set(PKG_CONFIG_EXECUTABLE "") unset(PKG_CONFIG_VERSION_STRING) -- cgit v0.12 From ab8bd48352df060c4ead210fe30dc4736646206b Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 25 Sep 2020 15:55:42 +0200 Subject: FindPkgConfig: Search for pkg-config.bat file on a Windows host The strawberry perl distribution ships a pkg-config file and a pkg-config.bat file. find_program() does not usually look for a .bat file program unless explicitly specified in the NAMES argument. This would cause CMake to find the non-bat file, and executing that with execute_process() leads to a '%1 is not a valid Win32 application' error. Prefer to search for pkg-config.bat file when on a Windows host, in additiona to the regular pkg-config file. Fixes: #21239 --- Modules/FindPkgConfig.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 6294a4c..2ad2c7e 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -31,7 +31,13 @@ set(PKG_CONFIG_VERSION 1) if((NOT PKG_CONFIG_EXECUTABLE) AND (NOT "$ENV{PKG_CONFIG}" STREQUAL "")) set(PKG_CONFIG_EXECUTABLE "$ENV{PKG_CONFIG}" CACHE FILEPATH "pkg-config executable") endif() -find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable") + +set(PKG_CONFIG_NAMES "pkg-config") +if(CMAKE_HOST_WIN32) + list(PREPEND PKG_CONFIG_NAMES "pkg-config.bat") +endif() + +find_program(PKG_CONFIG_EXECUTABLE NAMES ${PKG_CONFIG_NAMES} DOC "pkg-config executable") mark_as_advanced(PKG_CONFIG_EXECUTABLE) set(_PKG_CONFIG_FAILURE_MESSAGE "") -- cgit v0.12