diff options
author | Brad King <brad.king@kitware.com> | 2022-02-14 14:59:39 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-02-14 14:59:45 (GMT) |
commit | 59da8629cc289df77ac376968db482b1d43fcf47 (patch) | |
tree | 0aadfae355662f411a5886836a2cf810645377a7 | |
parent | 2adea60f45a991e1b0a0c67470db6f444931f253 (diff) | |
parent | 58af150a74d8da81255689dd4981aed8f45fff03 (diff) | |
download | CMake-59da8629cc289df77ac376968db482b1d43fcf47.zip CMake-59da8629cc289df77ac376968db482b1d43fcf47.tar.gz CMake-59da8629cc289df77ac376968db482b1d43fcf47.tar.bz2 |
Merge topic 'FortranCInterface-macos-arch' into release-3.23
58af150a74 FortranCInterface: Fix mangling detection for x86_64 on arm64 macOS
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6974
-rw-r--r-- | Modules/FortranCInterface.cmake | 9 | ||||
-rw-r--r-- | Modules/FortranCInterface/Detect.cmake | 10 |
2 files changed, 19 insertions, 0 deletions
diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index 733c723..53df01a 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -343,6 +343,14 @@ function(FortranCInterface_VERIFY) set(_desc "Verifying Fortran/${lang} Compiler Compatibility") message(CHECK_START "${_desc}") + # Perform verification with only one architecture. + # FIXME: Add try_compile whole-project option to forward architectures. + if(CMAKE_OSX_ARCHITECTURES MATCHES "^([^;]+)(;|$)") + set(_FortranCInterface_OSX_ARCH "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_MATCH_1}") + else() + set(_FortranCInterface_OSX_ARCH "") + endif() + cmake_policy(GET CMP0056 _FortranCInterface_CMP0056) if(_FortranCInterface_CMP0056 STREQUAL "NEW") set(_FortranCInterface_EXE_LINKER_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}") @@ -365,6 +373,7 @@ function(FortranCInterface_VERIFY) "-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}" "-DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}" "-DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}" + ${_FortranCInterface_OSX_ARCH} ${_FortranCInterface_EXE_LINKER_FLAGS} OUTPUT_VARIABLE _output) file(WRITE "${FortranCInterface_BINARY_DIR}/Verify${lang}/output.txt" "${_output}") diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index 4d3cb00..72e5544 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -28,6 +28,14 @@ unset(FortranCInterface_VERIFIED_CXX CACHE) set(_result) +# Perform detection with only one architecture so that +# the info strings are not repeated. +if(CMAKE_OSX_ARCHITECTURES MATCHES "^([^;]+)(;|$)") + set(_FortranCInterface_OSX_ARCH "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_MATCH_1}") +else() + set(_FortranCInterface_OSX_ARCH "") +endif() + cmake_policy(GET CMP0056 _FortranCInterface_CMP0056) if(_FortranCInterface_CMP0056 STREQUAL "NEW") set(_FortranCInterface_EXE_LINKER_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}") @@ -48,11 +56,13 @@ try_compile(FortranCInterface_COMPILED "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" "-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}" "-DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}" + ${_FortranCInterface_OSX_ARCH} ${_FortranCInterface_EXE_LINKER_FLAGS} OUTPUT_VARIABLE FortranCInterface_OUTPUT) set(FortranCInterface_COMPILED ${FortranCInterface_COMPILED}) unset(FortranCInterface_COMPILED CACHE) unset(_FortranCInterface_EXE_LINKER_FLAGS) +unset(_FortranCInterface_OSX_ARCH) # Locate the sample project executable. set(FortranCInterface_EXE) |