Ignore `CMAKE_SYSROOT` when cross-compiling (#8318)
authorAndres Noetzli <andres.noetzli@gmail.com>
Wed, 16 Mar 2022 00:10:23 +0000 (17:10 -0700)
committerGitHub <noreply@github.com>
Wed, 16 Mar 2022 00:10:23 +0000 (00:10 +0000)
This commit changes our build system to ignore CMAKE_SYSROOT for
find_file(), find_path(), and find_library() when cross-compiling.
Previously, it could happen that, e.g., when we were cross-compiling a
static build for Windows, CMake would pick up /usr/lib/libgmp.a
instead of cross-compiling GMP. The comments in the Toolchain-*.cmake
files suggest that the new behavior was the intended behavior all along.

cmake/Toolchain-aarch64.cmake
cmake/Toolchain-mingw64.cmake

index cb9e1167ec860d1a0680e33478ba82d16f596ab8..55012c6bed4f59ba0a42cd3193afe7c531be66a8 100644 (file)
@@ -30,5 +30,5 @@ SET(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
 # search headers and libraries in the target environment, search
 # programs in the host environment
 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
index f207875afe8c6d244afb30d6c2d55aa637052aab..f3b6be9dad9752124b1ae374d11f1fb2c00dc706 100644 (file)
@@ -30,6 +30,6 @@ SET(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
 # search headers and libraries in the target environment, search
 # programs in the host environment
 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)