@@ -13,18 +13,15 @@ endif()
1313
1414# --- abi check: C++ and Fortran compiler ABI compatibility
1515
16- block()
17-
18- if (dev AND NOT DEFINED abi_compile AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.25)
16+ if (NOT DEFINED abi_compile)
1917
20- message (CHECK_START "checking that C, C++, and Fortran compilers can link" )
21-
22- try_compile (abi_compile
23- PROJECT abi_check
24- SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} /abi_check
25- CMAKE_FLAGS -Dlinker_lang=${linker_lang}
26- )
18+ message (CHECK_START "checking that C, C++, and Fortran compilers can link" )
2719
20+ try_compile (abi_compile
21+ PROJECT abi_check
22+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} /abi_check
23+ CMAKE_FLAGS -Dlinker_lang=${linker_lang} -DCMAKE_LINK_WARNING_AS_ERROR:BOOL =on
24+ )
2825
2926if (abi_compile)
3027 message (CHECK_PASS "OK" )
@@ -39,24 +36,24 @@ endif()
3936# try_run() doesn't adequately detect failed exception handling--it may pass while ctest of the same exe fails
4037
4138message (CHECK_START "checking that C++ exception handling works" )
42- try_compile (exception_compile
39+
40+ try_compile (HAVE_CXX_TRYCATCH
4341 PROJECT exception
4442 SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} /exception_check
45- OUTPUT_VARIABLE abi_output
43+ OUTPUT_VARIABLE _out
44+ CMAKE_FLAGS "-DCMAKE_LINK_WARNING_AS_ERROR:BOOL=on"
4645)
47- if (abi_output MATCHES "ld: warning: could not create compact unwind for" )
46+ # _out is for CMake < 4.0
47+
48+ if (NOT HAVE_CXX_TRYCATCH OR _out MATCHES "ld: warning: could not create compact unwind for" )
4849 message (CHECK_FAIL "no" )
49- set (HAVE_CXX_TRYCATCH false CACHE BOOL "C++ exception handling broken" )
5050 message (WARNING "C++ exception handling will not work reliably due to incompatible compilers" )
5151else ()
5252 message (CHECK_PASS "yes" )
53- set (HAVE_CXX_TRYCATCH true CACHE BOOL "C++ exception handling works" )
5453endif ()
5554
5655endif ()
5756
58- endblock()
59-
6057
6158# --- ISO_Fortran_binding.h header
6259block()
0 commit comments