diff options
author | Tim Gallagher <tim.gallagher@gatech.edu> | 2014-11-05 18:43:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-11-10 15:24:53 (GMT) |
commit | b6b37e303786e48c305cb83011ce5fa6cf71e359 (patch) | |
tree | ceb9d6e82793804a1adc0f079de8317dd0f37695 /Tests/FortranOnly | |
parent | 0842b08463d14d6c7e27dcb4cda278805cce6e5f (diff) | |
download | CMake-b6b37e303786e48c305cb83011ce5fa6cf71e359.zip CMake-b6b37e303786e48c305cb83011ce5fa6cf71e359.tar.gz CMake-b6b37e303786e48c305cb83011ce5fa6cf71e359.tar.bz2 |
Makefile: Add assembly and preprocessed targets for Fortran
Extend the FortranOnly test to cover "make <src>.i" targets.
Diffstat (limited to 'Tests/FortranOnly')
-rw-r--r-- | Tests/FortranOnly/CMakeLists.txt | 26 | ||||
-rw-r--r-- | Tests/FortranOnly/preprocess.F | 5 | ||||
-rw-r--r-- | Tests/FortranOnly/test_preprocess.cmake | 7 |
3 files changed, 38 insertions, 0 deletions
diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index f55e727..1b2651d 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -66,3 +66,29 @@ if(NOT CMAKE_Fortran_COMPILER_ID STREQUAL XL) "${err}") endif() endif() + +# Test generation of preprocessed sources. +if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) + if(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE) + # Skip running this part of the test on certain platforms + # until they are fixed. + set(MAYBE_ALL ALL) + list(LENGTH CMAKE_OSX_ARCHITECTURES ARCH_COUNT) + if(ARCH_COUNT GREATER 1) + # OSX does not support preprocessing more than one architecture. + set(MAYBE_ALL) + endif() + + add_executable(preprocess preprocess.F) + + # Custom target to try preprocessing invocation. + add_custom_target(test_preprocess ${MAYBE_ALL} + COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/preprocess.dir/preprocess.F.i + COMMAND ${CMAKE_MAKE_PROGRAM} preprocess.i + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake + # Remove bogus file some compilers leave behind. + COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/preprocess.s + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + endif() +endif() diff --git a/Tests/FortranOnly/preprocess.F b/Tests/FortranOnly/preprocess.F new file mode 100644 index 0000000..f7df457 --- /dev/null +++ b/Tests/FortranOnly/preprocess.F @@ -0,0 +1,5 @@ + PROGRAM PREPRO +#ifndef TEST_PREPROCESSOR + PRINT *, 'Hello' +#endif + END diff --git a/Tests/FortranOnly/test_preprocess.cmake b/Tests/FortranOnly/test_preprocess.cmake new file mode 100644 index 0000000..29ebdac --- /dev/null +++ b/Tests/FortranOnly/test_preprocess.cmake @@ -0,0 +1,7 @@ +set(TEST_FILE CMakeFiles/preprocess.dir/preprocess.F.i) +file(READ ${TEST_FILE} CONTENTS) +if("${CONTENTS}" MATCHES "PRINT *") + message(STATUS "${TEST_FILE} created successfully!") +else() + message(FATAL_ERROR "${TEST_FILE} creation failed!") +endif() |