summaryrefslogtreecommitdiff
path: root/Tests/FortranOnly
diff options
context:
space:
mode:
authorTim Gallagher <tim.gallagher@gatech.edu>2014-11-05 13:43:06 -0500
committerBrad King <brad.king@kitware.com>2014-11-10 10:24:53 -0500
commitb6b37e303786e48c305cb83011ce5fa6cf71e359 (patch)
treeceb9d6e82793804a1adc0f079de8317dd0f37695 /Tests/FortranOnly
parent0842b08463d14d6c7e27dcb4cda278805cce6e5f (diff)
downloadcmake-b6b37e303786e48c305cb83011ce5fa6cf71e359.tar.gz
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.txt26
-rw-r--r--Tests/FortranOnly/preprocess.F5
-rw-r--r--Tests/FortranOnly/test_preprocess.cmake7
3 files changed, 38 insertions, 0 deletions
diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt
index f55e727074..1b2651dd7d 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 0000000000..f7df4572c2
--- /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 0000000000..29ebdace60
--- /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()