File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -29,11 +29,27 @@ endmacro()
29
29
# Add each flag in the list to LIBCXX_COMPILE_FLAGS and LIBCXX_LINK_FLAGS
30
30
# if that flag is supported by the current compiler.
31
31
macro (add_flags_if_supported )
32
+
33
+ # Disable linker for CMake flag compatibility checks
34
+ #
35
+ # Due to https://gitlab.kitware.com/cmake/cmake/-/issues/23454, we need to
36
+ # disable CMAKE_REQUIRED_LINK_OPTIONS (c.f. CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG),
37
+ # for static targets; cache the target type here, and reset it after the various
38
+ # checks have been performed.
39
+ set (_previous_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE} )
40
+ set (_previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS} )
41
+ set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY )
42
+ set (CMAKE_REQUIRED_LINK_OPTIONS )
43
+
32
44
foreach (flag ${ARGN} )
33
45
mangle_name ("${flag} " flagname )
34
46
check_cxx_compiler_flag ("${flag} " "CXX_SUPPORTS_${flagname} _FLAG" )
35
47
add_flags_if (CXX_SUPPORTS_${flagname}_FLAG ${flag} )
36
48
endforeach ()
49
+
50
+ # reset CMAKE_TRY_COMPILE_TARGET_TYPE & CMAKE_REQUIRED_LINK_OPTIONS after flag checks
51
+ set (CMAKE_TRY_COMPILE_TARGET_TYPE ${_previous_CMAKE_TRY_COMPILE_TARGET_TYPE} )
52
+ set (CMAKE_REQUIRED_LINK_OPTIONS ${_previous_CMAKE_REQUIRED_LINK_OPTIONS} )
37
53
endmacro ()
38
54
39
55
# Add a list of flags to 'LIBCXX_LINK_FLAGS'.
Original file line number Diff line number Diff line change @@ -29,11 +29,27 @@ endmacro()
29
29
# Add each flag in the list to LIBCXXABI_COMPILE_FLAGS and LIBCXXABI_LINK_FLAGS
30
30
# if that flag is supported by the current compiler.
31
31
macro (add_flags_if_supported )
32
+
33
+ # Disable linker for CMake flag compatibility checks
34
+ #
35
+ # Due to https://gitlab.kitware.com/cmake/cmake/-/issues/23454, we need to
36
+ # disable CMAKE_REQUIRED_LINK_OPTIONS (c.f. CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG),
37
+ # for static targets; cache the target type here, and reset it after the various
38
+ # checks have been performed.
39
+ set (_previous_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE} )
40
+ set (_previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS} )
41
+ set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY )
42
+ set (CMAKE_REQUIRED_LINK_OPTIONS )
43
+
32
44
foreach (flag ${ARGN} )
33
45
mangle_name ("${flag} " flagname )
34
46
check_cxx_compiler_flag ("${flag} " "CXX_SUPPORTS_${flagname} _FLAG" )
35
47
add_flags_if (CXX_SUPPORTS_${flagname}_FLAG ${flag} )
36
48
endforeach ()
49
+
50
+ # reset CMAKE_TRY_COMPILE_TARGET_TYPE & CMAKE_REQUIRED_LINK_OPTIONS after flag checks
51
+ set (CMAKE_TRY_COMPILE_TARGET_TYPE ${_previous_CMAKE_TRY_COMPILE_TARGET_TYPE} )
52
+ set (CMAKE_REQUIRED_LINK_OPTIONS ${_previous_CMAKE_REQUIRED_LINK_OPTIONS} )
37
53
endmacro ()
38
54
39
55
# Add a list of flags to 'LIBCXXABI_COMPILE_FLAGS'.
You can’t perform that action at this time.
0 commit comments