summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-02-27 17:02:08 (GMT)
committerBrad King <brad.king@kitware.com>2020-02-28 15:57:45 (GMT)
commit1bc521416f12dd319b23d29f4296be7ebc7f42a2 (patch)
tree92f598af2554b354e8ff31aff3c0f9f75fe7951b /Modules
parent2a9cf889178dfc202ec84f1fece8a68594cc3566 (diff)
downloadCMake-1bc521416f12dd319b23d29f4296be7ebc7f42a2.zip
CMake-1bc521416f12dd319b23d29f4296be7ebc7f42a2.tar.gz
CMake-1bc521416f12dd319b23d29f4296be7ebc7f42a2.tar.bz2
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')
-rw-r--r--Modules/CheckFortranSourceCompiles.cmake6
-rw-r--r--Modules/CheckFortranSourceRuns.cmake6
2 files changed, 4 insertions, 8 deletions
diff --git a/Modules/CheckFortranSourceCompiles.cmake b/Modules/CheckFortranSourceCompiles.cmake
index f0fde8d..3354bfb 100644
--- a/Modules/CheckFortranSourceCompiles.cmake
+++ b/Modules/CheckFortranSourceCompiles.cmake
@@ -103,8 +103,6 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
if(NOT _SRC_EXT)
set(_SRC_EXT F)
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})
@@ -132,10 +130,10 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
try_compile(${VAR}
${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}
"${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake
index a3e5d5d..f858b84 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