summaryrefslogtreecommitdiff
path: root/Tests/FortranOnly
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 /Tests/FortranOnly
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 'Tests/FortranOnly')
-rw-r--r--Tests/FortranOnly/CMakeLists.txt50
1 files changed, 23 insertions, 27 deletions
diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt
index d945375df3..4327c2fcbe 100644
--- a/Tests/FortranOnly/CMakeLists.txt
+++ b/Tests/FortranOnly/CMakeLists.txt
@@ -51,40 +51,36 @@ add_custom_target(checksayhello ALL
)
add_dependencies(checksayhello sayhello)
-# Exclude this test on IBM XL for now because the check strangely
-# fails with 'ld: 0706-029 Use a number with the -H flag'.
-if(NOT CMAKE_Fortran_COMPILER_ID STREQUAL XL)
- set(err_log ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log)
- file(REMOVE "${err_log}")
- include(CheckFortranSourceCompiles)
- unset(HAVE_PRINT CACHE)
- CHECK_Fortran_SOURCE_COMPILES([[
+set(err_log ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log)
+file(REMOVE "${err_log}")
+include(CheckFortranSourceCompiles)
+unset(HAVE_PRINT CACHE)
+CHECK_Fortran_SOURCE_COMPILES([[
PROGRAM TEST_HAVE_PRINT
PRINT *, 'Hello'
END
]] HAVE_PRINT)
- if(NOT HAVE_PRINT)
- if(EXISTS "${err_log}")
- file(READ "${err_log}" err)
- endif()
- string(REPLACE "\n" "\n " err " ${err}")
- message(SEND_ERROR "CHECK_Fortran_SOURCE_COMPILES for HAVE_PRINT failed:\n"
- "${err}")
+if(NOT HAVE_PRINT)
+ if(EXISTS "${err_log}")
+ file(READ "${err_log}" err)
endif()
+ string(REPLACE "\n" "\n " err " ${err}")
+ message(SEND_ERROR "CHECK_Fortran_SOURCE_COMPILES for HAVE_PRINT failed:\n"
+ "${err}")
+endif()
- unset(Fortran_BOGUS_FLAG CACHE)
- include(CheckFortranCompilerFlag)
- CHECK_Fortran_COMPILER_FLAG(-_this_is_not_a_flag_ Fortran_BOGUS_FLAG)
- if (Fortran_BOGUS_FLAG)
- message(SEND_ERROR "CHECK_Fortran_COMPILER_FLAG() succeeded, but should have failed")
- endif()
+unset(Fortran_BOGUS_FLAG CACHE)
+include(CheckFortranCompilerFlag)
+CHECK_Fortran_COMPILER_FLAG(-_this_is_not_a_flag_ Fortran_BOGUS_FLAG)
+if (Fortran_BOGUS_FLAG)
+ message(SEND_ERROR "CHECK_Fortran_COMPILER_FLAG() succeeded, but should have failed")
+endif()
- unset(Fortran_RUN_FLAG CACHE)
- include(CheckFortranSourceRuns)
- check_fortran_source_runs("program a; end program" Fortran_RUN_FLAG SRC_EXT F90)
- if(NOT Fortran_RUN_FLAG)
- message(SEND_ERROR "CHECK_Fortran_SOURCE_RUNS() failed")
- endif()
+unset(Fortran_RUN_FLAG CACHE)
+include(CheckFortranSourceRuns)
+check_fortran_source_runs("program a; end program" Fortran_RUN_FLAG SRC_EXT F90)
+if(NOT Fortran_RUN_FLAG)
+ message(SEND_ERROR "CHECK_Fortran_SOURCE_RUNS() failed")
endif()
# Test generation of preprocessed sources.