mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-17 20:50:43 -06:00
FindPkgConfig: Avoid finding Strawberry Perl's pkg-config
Strawberry Perl may be in the `PATH` to provide `perl`, but it also
comes with a `pkg-config` tool that is unrelated to normal MinGW
distributions. Since commit c6efbd78d8 (MSVC: Teach find_library to
consider the 'libfoo.a' naming convention, 2024-01-19, v3.29.0-rc1~91^2)
we need to avoid searching Strawberry Perl's `.../c/lib` directory, so
do not let its `pkg-config` point us there.
Fixes: #25820
Issue: #23975
This commit is contained in:
@@ -56,14 +56,29 @@ endif()
|
||||
set(PKG_CONFIG_NAMES "pkg-config")
|
||||
if(CMAKE_HOST_WIN32)
|
||||
list(PREPEND PKG_CONFIG_NAMES "pkg-config.bat")
|
||||
set(_PKG_CONFIG_VALIDATOR VALIDATOR __FindPkgConfig_EXECUTABLE_VALIDATOR)
|
||||
function(__FindPkgConfig_EXECUTABLE_VALIDATOR result_var candidate)
|
||||
if(candidate MATCHES "\\.[Ee][Xx][Ee]$")
|
||||
return()
|
||||
endif()
|
||||
# Exclude the pkg-config distributed with Strawberry Perl.
|
||||
execute_process(COMMAND "${candidate}" --help OUTPUT_VARIABLE _output ERROR_VARIABLE _output RESULT_VARIABLE _result)
|
||||
if(NOT _result EQUAL 0 OR _output MATCHES "Pure-Perl")
|
||||
set("${result_var}" FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
else()
|
||||
set(_PKG_CONFIG_VALIDATOR "")
|
||||
endif()
|
||||
list(APPEND PKG_CONFIG_NAMES "pkgconf")
|
||||
|
||||
find_program(PKG_CONFIG_EXECUTABLE
|
||||
NAMES ${PKG_CONFIG_NAMES}
|
||||
NAMES_PER_DIR
|
||||
DOC "pkg-config executable")
|
||||
DOC "pkg-config executable"
|
||||
${_PKG_CONFIG_VALIDATOR})
|
||||
mark_as_advanced(PKG_CONFIG_EXECUTABLE)
|
||||
unset(_PKG_CONFIG_VALIDATOR)
|
||||
|
||||
set(PKG_CONFIG_ARGN "${PKG_CONFIG_ARGN}" CACHE STRING "Arguments to supply to pkg-config")
|
||||
mark_as_advanced(PKG_CONFIG_ARGN)
|
||||
|
||||
Reference in New Issue
Block a user