summaryrefslogtreecommitdiff
path: root/Modules/CheckFortranSourceRuns.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-02-27 12:02:08 -0500
committerBrad King <brad.king@kitware.com>2020-02-28 10:57:45 -0500
commit1bc521416f12dd319b23d29f4296be7ebc7f42a2 (patch)
tree92f598af2554b354e8ff31aff3c0f9f75fe7951b /Modules/CheckFortranSourceRuns.cmake
parent2a9cf889178dfc202ec84f1fece8a68594cc3566 (diff)
downloadcmake-1bc521416f12dd319b23d29f4296be7ebc7f42a2.tar.gz
CheckFortranSource*: Avoid passing -DVAR to linker
The test project is compiled with a `-DVAR` compiler flag where `VAR` is the result variable. Tell `try_compile` to add the flag through `add_definitions` instead of `CMAKE_Fortran_FLAGS` so that it is not used for linking. Otherwise some Fortran compilers (e.g. XL 15) do not like the flag when used to drive linking.
Diffstat (limited to 'Modules/CheckFortranSourceRuns.cmake')
-rw-r--r--Modules/CheckFortranSourceRuns.cmake6
1 files changed, 2 insertions, 4 deletions
diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake
index a3e5d5dbf1..f858b84a81 100644
--- a/Modules/CheckFortranSourceRuns.cmake
+++ b/Modules/CheckFortranSourceRuns.cmake
@@ -98,8 +98,6 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR)
if(NOT _SRC_EXT)
set(_SRC_EXT F90)
endif()
- set(MACRO_CHECK_FUNCTION_DEFINITIONS
- "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
if(CMAKE_REQUIRED_LINK_OPTIONS)
set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS
LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
@@ -127,10 +125,10 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR)
try_run(${VAR}_EXITCODE ${VAR}_COMPILED
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}
- COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ COMPILE_DEFINITIONS -D${VAR} ${CMAKE_REQUIRED_DEFINITIONS}
${CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS}
${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES}
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
"${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}"
COMPILE_OUTPUT_VARIABLE OUTPUT