Skip to content

Commit 09e8fd2

Browse files
committed
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.
1 parent a5b0a44 commit 09e8fd2

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

cmake/module/CheckSourceCompilesAndLinks.cmake

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ include_guard(GLOBAL)
66
include(CheckCXXSourceCompiles)
77
include(CMakePushCheckState)
88

9-
# This avoids running the linker.
10-
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
11-
12-
macro(check_cxx_source_links source)
13-
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
14-
check_cxx_source_compiles("${source}" ${ARGN})
15-
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
16-
endmacro()
17-
189
macro(check_cxx_source_compiles_with_flags flags source)
1910
cmake_push_check_state(RESET)
2011
set(CMAKE_REQUIRED_FLAGS ${flags})
@@ -27,13 +18,13 @@ macro(check_cxx_source_links_with_flags flags source)
2718
cmake_push_check_state(RESET)
2819
set(CMAKE_REQUIRED_FLAGS ${flags})
2920
list(JOIN CMAKE_REQUIRED_FLAGS " " CMAKE_REQUIRED_FLAGS)
30-
check_cxx_source_links("${source}" ${ARGN})
21+
check_cxx_source_compiles("${source}" ${ARGN})
3122
cmake_pop_check_state()
3223
endmacro()
3324

3425
macro(check_cxx_source_links_with_libs libs source)
3526
cmake_push_check_state(RESET)
3627
set(CMAKE_REQUIRED_LIBRARIES "${libs}")
37-
check_cxx_source_links("${source}" ${ARGN})
28+
check_cxx_source_compiles("${source}" ${ARGN})
3829
cmake_pop_check_state()
3930
endmacro()

cmake/module/TestAppendRequiredLibraries.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function(test_append_socket_library target)
2626
")
2727

2828
include(CheckSourceCompilesAndLinks)
29-
check_cxx_source_links("${check_socket_source}" IFADDR_LINKS_WITHOUT_LIBSOCKET)
29+
check_cxx_source_compiles("${check_socket_source}" IFADDR_LINKS_WITHOUT_LIBSOCKET)
3030
if(NOT IFADDR_LINKS_WITHOUT_LIBSOCKET)
3131
check_cxx_source_links_with_libs(socket "${check_socket_source}" IFADDR_NEEDS_LINK_TO_LIBSOCKET)
3232
if(IFADDR_NEEDS_LINK_TO_LIBSOCKET)
@@ -78,7 +78,7 @@ function(test_append_atomic_library target)
7878
")
7979

8080
include(CheckSourceCompilesAndLinks)
81-
check_cxx_source_links("${check_atomic_source}" STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC)
81+
check_cxx_source_compiles("${check_atomic_source}" STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC)
8282
if(STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC)
8383
return()
8484
endif()

0 commit comments

Comments
 (0)