From 486bd5a12ae9505ef484935abd6eae6d9b2495c2 Mon Sep 17 00:00:00 2001 From: Andres Noetzli Date: Tue, 15 Mar 2022 17:10:23 -0700 Subject: [PATCH] Ignore `CMAKE_SYSROOT` when cross-compiling (#8318) 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 | 4 ++-- cmake/Toolchain-mingw64.cmake | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/Toolchain-aarch64.cmake b/cmake/Toolchain-aarch64.cmake index cb9e1167e..55012c6be 100644 --- a/cmake/Toolchain-aarch64.cmake +++ b/cmake/Toolchain-aarch64.cmake @@ -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) diff --git a/cmake/Toolchain-mingw64.cmake b/cmake/Toolchain-mingw64.cmake index f207875af..f3b6be9da 100644 --- a/cmake/Toolchain-mingw64.cmake +++ b/cmake/Toolchain-mingw64.cmake @@ -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) -- 2.30.2