Skip to content

Commit 11cbf4f

Browse files
committed
[cmake] also do static-vs-linker work-around in libcxx/cmake/config-ix.cmake
1 parent 47e7688 commit 11cbf4f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

libcxx/cmake/config-ix.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ include(CheckCCompilerFlag)
66
include(CheckCXXCompilerFlag)
77
include(CheckCSourceCompiles)
88

9+
# Disable linker for CMake flag compatibility checks
10+
#
11+
# Due to https://gitlab.kitware.com/cmake/cmake/-/issues/23454, we need to
12+
# disable CMAKE_REQUIRED_LINK_OPTIONS (c.f. CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG),
13+
# for static targets; cache the target type here, and reset it after the various
14+
# checks have been performed.
15+
set(_previous_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
16+
set(_previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
17+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
18+
set(CMAKE_REQUIRED_LINK_OPTIONS)
19+
920
# The compiler driver may be implicitly trying to link against libunwind.
1021
# This is normally ok (libcxx relies on an unwinder), but if libunwind is
1122
# built in the same cmake invocation as libcxx and we've got
@@ -98,6 +109,10 @@ int main(void) { return 0; }
98109
cmake_pop_check_state()
99110
endif()
100111

112+
# reset CMAKE_TRY_COMPILE_TARGET_TYPE & CMAKE_REQUIRED_LINK_OPTIONS after flag checks
113+
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_previous_CMAKE_TRY_COMPILE_TARGET_TYPE})
114+
set(CMAKE_REQUIRED_LINK_OPTIONS ${_previous_CMAKE_REQUIRED_LINK_OPTIONS})
115+
101116
check_symbol_exists(__PICOLIBC__ "string.h" PICOLIBC)
102117

103118
# Check libraries

0 commit comments

Comments
 (0)