From: Joel Rosdahl Date: Sat, 27 Mar 2021 15:10:31 +0000 (+0100) Subject: Fix probing of faster linker when cross compiling X-Git-Tag: v4.2.1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b60313accf18032d1c8da26083c3c824afcfc158;p=thirdparty%2Fccache.git Fix probing of faster linker when cross compiling --- diff --git a/cmake/UseFastestLinker.cmake b/cmake/UseFastestLinker.cmake index c3c6bdbfe..def8105fc 100644 --- a/cmake/UseFastestLinker.cmake +++ b/cmake/UseFastestLinker.cmake @@ -1,6 +1,3 @@ -include(CMakePushCheckState) -include(CheckCSourceRuns) - # Calls `message(VERBOSE msg)` if and only if VERBOSE is available (since CMake 3.15). # Call CMake with --loglevel=VERBOSE to view those messages. function(message_verbose msg) @@ -13,10 +10,14 @@ function(try_linker linker) string(TOUPPER ${linker} upper_linker) find_program(HAS_LD_${upper_linker} "ld.${linker}") if(HAS_LD_${upper_linker}) - cmake_push_check_state(RESET) set(CMAKE_REQUIRED_LIBRARIES "-fuse-ld=${linker}") - check_c_source_runs("int main() { return 0; }" HAVE_LD_${upper_linker}) - cmake_pop_check_state() + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.c" "int main() { return 0; }") + try_compile( + HAVE_LD_${upper_linker} + ${CMAKE_CURRENT_BINARY_DIR} + "${CMAKE_CURRENT_BINARY_DIR}/main.c" + LINK_LIBRARIES "-fuse-ld=${linker}" + ) endif() endfunction()