summaryrefslogtreecommitdiff
path: root/Modules/FortranCInterface
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-11-09 14:05:43 -0500
committerBrad King <brad.king@kitware.com>2020-11-10 09:33:27 -0500
commit15e77fbd40e324fd0be394a73ed94800bb47ad2e (patch)
tree88f90e5bdd1bde57cb2e09e91da33b921ad3ba5a /Modules/FortranCInterface
parentcaed98d77137b868fdd7b87a837969667e3e6f51 (diff)
downloadcmake-15e77fbd40e324fd0be394a73ed94800bb47ad2e.tar.gz
FortranCInterface: Honor CMAKE_EXE_LINKER_FLAGS under CMP0056
Policy CMP0056 determines whether `CMAKE_EXE_LINKER_FLAGS` are passed into the test project used by the source-file signature of `try_compile`. That affects how implicit link directories are detected, so we need to also honor the policy for the source-directory signature of `try_compile` used in FortranCInterface in order to get matching link directories. Fixes: #21408
Diffstat (limited to 'Modules/FortranCInterface')
-rw-r--r--Modules/FortranCInterface/Detect.cmake10
1 files changed, 10 insertions, 0 deletions
diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake
index c75067b32e..998faf1ecc 100644
--- a/Modules/FortranCInterface/Detect.cmake
+++ b/Modules/FortranCInterface/Detect.cmake
@@ -26,6 +26,14 @@ unset(FortranCInterface_VERIFIED_CXX CACHE)
set(_result)
+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}")
+else()
+ set(_FortranCInterface_EXE_LINKER_FLAGS "")
+endif()
+unset(_FortranCInterface_CMP0056)
+
# Build a sample project which reports symbols.
set(CMAKE_TRY_COMPILE_CONFIGURATION Release)
try_compile(FortranCInterface_COMPILED
@@ -38,9 +46,11 @@ 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_EXE_LINKER_FLAGS}
OUTPUT_VARIABLE FortranCInterface_OUTPUT)
set(FortranCInterface_COMPILED ${FortranCInterface_COMPILED})
unset(FortranCInterface_COMPILED CACHE)
+unset(_FortranCInterface_EXE_LINKER_FLAGS)
# Locate the sample project executable.
set(FortranCInterface_EXE)