diff options
author | Andrew Paprocki <andrew@ishiboo.com> | 2019-01-14 14:12:38 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-01-18 13:56:13 (GMT) |
commit | a080914274b32ac53f2449602811aebca7cc7d29 (patch) | |
tree | f0b8f3fc84fcbedb23bb3e8afa5657effa773495 /Tests/CompileOptions/CMakeLists.txt | |
parent | a61c061b6143cb6d8920b1b5796a867c0f104556 (diff) | |
download | CMake-a080914274b32ac53f2449602811aebca7cc7d29.zip CMake-a080914274b32ac53f2449602811aebca7cc7d29.tar.gz CMake-a080914274b32ac53f2449602811aebca7cc7d29.tar.bz2 |
Fortran: Add compiler ID/Version generator expressions
Adds `Fortran_COMPILER_ID` and `Fortran_COMPILER_VERSION` generator
expression support to match equivalent `C_COMPILER_ID`,
`CXX_COMPILER_ID`, `C_COMPILER_VERSION`, and `CXX_COMPILER_VERSION`
support.
This is very helpful in the case where the C/C++ compiler suite is a
different type of compiler from the platform Fortran compiler and
projects use generator expressions to assign compiler flags and
definitions. (e.g. `GNU` C/C++ and `SunPro` Fortran on Linux)
Diffstat (limited to 'Tests/CompileOptions/CMakeLists.txt')
-rw-r--r-- | Tests/CompileOptions/CMakeLists.txt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt index c9f1710..15a993c 100644 --- a/Tests/CompileOptions/CMakeLists.txt +++ b/Tests/CompileOptions/CMakeLists.txt @@ -4,6 +4,10 @@ project(CompileOptions) add_library(testlib other.cpp) +if(TEST_FORTRAN) + enable_language(Fortran) +endif() + add_executable(CompileOptions main.cpp) macro(get_compiler_test_genex lst lang) @@ -13,6 +17,9 @@ endmacro() get_compiler_test_genex(c_tests C) get_compiler_test_genex(cxx_tests CXX) +if(TEST_FORTRAN) + get_compiler_test_genex(fortran_tests Fortran) +endif() set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "-DTEST_DEFINE" @@ -21,6 +28,7 @@ set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "SHELL:" # produces no options ${c_tests} ${cxx_tests} + ${fortran_tests} ) if(BORLAND OR WATCOM) # these compilers do not support separate -D flags @@ -54,3 +62,12 @@ target_compile_definitions(CompileOptions "EXPECTED_C_COMPILER_VERSION=\"${CMAKE_C_COMPILER_VERSION}\"" "EXPECTED_CXX_COMPILER_VERSION=\"${CMAKE_CXX_COMPILER_VERSION}\"" ) + +if(TEST_FORTRAN) + # Definitions for the C++ code to test the values + target_compile_definitions(CompileOptions + PRIVATE + "TEST_FORTRAN" + "EXPECTED_Fortran_COMPILER_VERSION=\"${CMAKE_Fortran_COMPILER_VERSION}\"" + ) +endif() |