From 09e8fd25b1a5411472564e599ad15059bbf9e8d6 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 20 Feb 2025 12:38:35 +0000 Subject: [PATCH] build: Don't override CMake's default try_compile target CMake assumes the default value internally, so overriding this causes problems. The minimal speedup of skipping the linker isn't worth the complexity of setting it to static. --- cmake/module/CheckSourceCompilesAndLinks.cmake | 13 ++----------- cmake/module/TestAppendRequiredLibraries.cmake | 4 ++-- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/cmake/module/CheckSourceCompilesAndLinks.cmake b/cmake/module/CheckSourceCompilesAndLinks.cmake index 88c897d5243..53d0617a905 100644 --- a/cmake/module/CheckSourceCompilesAndLinks.cmake +++ b/cmake/module/CheckSourceCompilesAndLinks.cmake @@ -6,15 +6,6 @@ include_guard(GLOBAL) include(CheckCXXSourceCompiles) include(CMakePushCheckState) -# This avoids running the linker. -set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) - -macro(check_cxx_source_links source) - set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE) - check_cxx_source_compiles("${source}" ${ARGN}) - set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) -endmacro() - macro(check_cxx_source_compiles_with_flags flags source) cmake_push_check_state(RESET) set(CMAKE_REQUIRED_FLAGS ${flags}) @@ -27,13 +18,13 @@ macro(check_cxx_source_links_with_flags flags source) cmake_push_check_state(RESET) set(CMAKE_REQUIRED_FLAGS ${flags}) list(JOIN CMAKE_REQUIRED_FLAGS " " CMAKE_REQUIRED_FLAGS) - check_cxx_source_links("${source}" ${ARGN}) + check_cxx_source_compiles("${source}" ${ARGN}) cmake_pop_check_state() endmacro() macro(check_cxx_source_links_with_libs libs source) cmake_push_check_state(RESET) set(CMAKE_REQUIRED_LIBRARIES "${libs}") - check_cxx_source_links("${source}" ${ARGN}) + check_cxx_source_compiles("${source}" ${ARGN}) cmake_pop_check_state() endmacro() diff --git a/cmake/module/TestAppendRequiredLibraries.cmake b/cmake/module/TestAppendRequiredLibraries.cmake index 5352102c7a4..c1030a641fe 100644 --- a/cmake/module/TestAppendRequiredLibraries.cmake +++ b/cmake/module/TestAppendRequiredLibraries.cmake @@ -26,7 +26,7 @@ function(test_append_socket_library target) ") include(CheckSourceCompilesAndLinks) - check_cxx_source_links("${check_socket_source}" IFADDR_LINKS_WITHOUT_LIBSOCKET) + check_cxx_source_compiles("${check_socket_source}" IFADDR_LINKS_WITHOUT_LIBSOCKET) if(NOT IFADDR_LINKS_WITHOUT_LIBSOCKET) check_cxx_source_links_with_libs(socket "${check_socket_source}" IFADDR_NEEDS_LINK_TO_LIBSOCKET) if(IFADDR_NEEDS_LINK_TO_LIBSOCKET) @@ -78,7 +78,7 @@ function(test_append_atomic_library target) ") include(CheckSourceCompilesAndLinks) - check_cxx_source_links("${check_atomic_source}" STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC) + check_cxx_source_compiles("${check_atomic_source}" STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC) if(STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC) return() endif()