Skip to content

Commit 4d3bd22

Browse files
authored
Merge pull request #32436 from kastiglione/dl/build-script-prioritize-sdk-paths-in-cmake-find_-functions
[build-script] Prioritize SDK paths in CMake find_ functions
2 parents 79bdd43 + 562a254 commit 4d3bd22

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

utils/build-script-impl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,17 @@ function set_build_options_for_host() {
584584

585585
cmake_os_sysroot="$(xcrun --sdk ${platform} --show-sdk-path)"
586586

587+
# Customize the CMake `find_*` search paths to search the SDK
588+
# sysroot before searching `pkg-config` paths. This prevents compile
589+
# failures caused when `pkg-config` returns CommandLineTools paths
590+
# instead of Xcode paths.
591+
#
592+
# These search paths can be user customized either by setting the
593+
# `CMAKE_PREFIX_PATH` environment variable, or by setting the same
594+
# CMake variable via the command line (`-DCMAKE_PREFIX_PATH`).
595+
# See https://cmake.org/cmake/help/latest/command/find_path.html
596+
export CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${cmake_os_sysroot}/usr"
597+
587598
cmark_cmake_options=(
588599
-DCMAKE_C_FLAGS="$(cmark_c_flags ${host})"
589600
-DCMAKE_CXX_FLAGS="$(cmark_c_flags ${host})"

0 commit comments

Comments
 (0)