Skip to content

Commit 8d238c1

Browse files
committed
cmake: Delete check_cxx_source_links* macros
1 parent 71bf829 commit 8d238c1

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

cmake/module/CheckSourceCompilesAndLinks.cmake

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# file COPYING or https://opensource.org/license/mit/.
44

55
include_guard(GLOBAL)
6-
include(CheckCXXSourceCompiles)
7-
include(CMakePushCheckState)
86

97
#[=[
108
Check once if C++ source code can be compiled.
@@ -34,10 +32,3 @@ function(check_cxx_source_compiles_with_flags source result_var)
3432
check_cxx_source_compiles("${source}" ${result_var})
3533
set(${result_var} ${${result_var}} PARENT_SCOPE)
3634
endfunction()
37-
38-
macro(check_cxx_source_links_with_libs libs source)
39-
cmake_push_check_state(RESET)
40-
set(CMAKE_REQUIRED_LIBRARIES "${libs}")
41-
check_cxx_source_compiles("${source}" ${ARGN})
42-
cmake_pop_check_state()
43-
endmacro()

cmake/module/TestAppendRequiredLibraries.cmake

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ function(test_append_socket_library target)
2525
}
2626
")
2727

28-
include(CheckSourceCompilesAndLinks)
28+
include(CheckCXXSourceCompiles)
2929
check_cxx_source_compiles("${check_socket_source}" IFADDR_LINKS_WITHOUT_LIBSOCKET)
3030
if(NOT IFADDR_LINKS_WITHOUT_LIBSOCKET)
31-
check_cxx_source_links_with_libs(socket "${check_socket_source}" IFADDR_NEEDS_LINK_TO_LIBSOCKET)
31+
include(CheckSourceCompilesAndLinks)
32+
check_cxx_source_compiles_with_flags("${check_socket_source}" IFADDR_NEEDS_LINK_TO_LIBSOCKET
33+
LINK_LIBRARIES socket
34+
)
3235
if(IFADDR_NEEDS_LINK_TO_LIBSOCKET)
3336
target_link_libraries(${target} INTERFACE socket)
3437
else()
@@ -77,16 +80,17 @@ function(test_append_atomic_library target)
7780
}
7881
")
7982

80-
include(CheckSourceCompilesAndLinks)
83+
include(CheckCXXSourceCompiles)
8184
check_cxx_source_compiles("${check_atomic_source}" STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC)
82-
if(STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC)
83-
return()
84-
endif()
85-
86-
check_cxx_source_links_with_libs(atomic "${check_atomic_source}" STD_ATOMIC_NEEDS_LINK_TO_LIBATOMIC)
87-
if(STD_ATOMIC_NEEDS_LINK_TO_LIBATOMIC)
88-
target_link_libraries(${target} INTERFACE atomic)
89-
else()
90-
message(FATAL_ERROR "Cannot figure out how to use std::atomic.")
85+
if(NOT STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC)
86+
include(CheckSourceCompilesAndLinks)
87+
check_cxx_source_compiles_with_flags("${check_atomic_source}" STD_ATOMIC_NEEDS_LINK_TO_LIBATOMIC
88+
LINK_LIBRARIES atomic
89+
)
90+
if(STD_ATOMIC_NEEDS_LINK_TO_LIBATOMIC)
91+
target_link_libraries(${target} INTERFACE atomic)
92+
else()
93+
message(FATAL_ERROR "Cannot figure out how to use std::atomic.")
94+
endif()
9195
endif()
9296
endfunction()

0 commit comments

Comments
 (0)