Skip to content

Commit 37bb8e1

Browse files
committed
[cmake] also do static-vs-linker work-around in libcxxabi/cmake/config-ix.cmake
1 parent f34093a commit 37bb8e1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

libcxxabi/cmake/config-ix.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ if (NOT LIBCXXABI_USE_COMPILER_RT)
1414
endif ()
1515
endif ()
1616

17+
# Disable linker for CMake flag compatibility checks
18+
#
19+
# Due to https://gitlab.kitware.com/cmake/cmake/-/issues/23454, we need to
20+
# disable CMAKE_REQUIRED_LINK_OPTIONS (c.f. CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG),
21+
# for static targets; cache the target type here, and reset it after the various
22+
# checks have been performed.
23+
set(_previous_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
24+
set(_previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
25+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
26+
set(CMAKE_REQUIRED_LINK_OPTIONS)
27+
1728
# libc++abi is using -nostdlib++ at the link step when available,
1829
# otherwise -nodefaultlibs is used. We want all our checks to also
1930
# use one of these options, otherwise we may end up with an inconsistency between
@@ -94,6 +105,10 @@ endif()
94105
# Check compiler flags
95106
check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG)
96107

108+
# reset CMAKE_TRY_COMPILE_TARGET_TYPE & CMAKE_REQUIRED_LINK_OPTIONS after flag checks
109+
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_previous_CMAKE_TRY_COMPILE_TARGET_TYPE})
110+
set(CMAKE_REQUIRED_LINK_OPTIONS ${_previous_CMAKE_REQUIRED_LINK_OPTIONS})
111+
97112
# Check libraries
98113
if(FUCHSIA)
99114
set(LIBCXXABI_HAS_DL_LIB NO)

0 commit comments

Comments
 (0)