summaryrefslogtreecommitdiffstats
path: root/Tests/FortranModules/CMakeLists.txt
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-22 18:23:39 (GMT)
committerBrad King <brad.king@kitware.com>2016-09-22 18:52:01 (GMT)
commiteb8cd35684f2dc2f53d205d7738e1c01a12a493f (patch)
tree77732180392bf2da1fe0aa6facd25c9fe95e6614 /Tests/FortranModules/CMakeLists.txt
parenta41c8724d155f1cd74ce36cdfbd10da0eac5b389 (diff)
downloadCMake-eb8cd35684f2dc2f53d205d7738e1c01a12a493f.zip
CMake-eb8cd35684f2dc2f53d205d7738e1c01a12a493f.tar.gz
CMake-eb8cd35684f2dc2f53d205d7738e1c01a12a493f.tar.bz2
Tests: Split Fortran module testing into separate FortranModules test
The main Fortran test is not granular enough. Split some into another test.
Diffstat (limited to 'Tests/FortranModules/CMakeLists.txt')
-rw-r--r--Tests/FortranModules/CMakeLists.txt78
1 files changed, 78 insertions, 0 deletions
diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt
new file mode 100644
index 0000000..b406df3
--- /dev/null
+++ b/Tests/FortranModules/CMakeLists.txt
@@ -0,0 +1,78 @@
+cmake_minimum_required (VERSION 3.1)
+project(FortranModules Fortran)
+
+if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
+endif()
+
+add_executable(test_module
+ test_module_main.f90
+ test_module_implementation.f90
+ test_module_interface.f90)
+
+add_executable(test_use_in_comment_fixedform
+ test_use_in_comment_fixedform.f)
+set_property(SOURCE test_use_in_comment_fixedform.f PROPERTY Fortran_FORMAT FIXED)
+add_executable(test_use_in_comment_freeform
+ test_use_in_comment_freeform.f90)
+set_property(SOURCE test_use_in_comment_freeform.f90 PROPERTY Fortran_FORMAT FREE)
+
+add_executable(test_in_interface
+ in_interface/main.f90
+ in_interface/module.f90)
+
+add_definitions(-DFOO -DBAR=1)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
+add_executable(test_preprocess test_preprocess.F90 test_preprocess_module.F90)
+
+# Build the external project separately using a custom target.
+# Make sure it uses the same build configuration as this test.
+if(CMAKE_CONFIGURATION_TYPES)
+ set(External_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
+ set(External_BUILD_TYPE)
+else()
+ set(External_CONFIG_TYPE)
+ set(External_BUILD_TYPE -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE})
+endif()
+set(External_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/External")
+set(External_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/External")
+if("${CMAKE_CURRENT_BINARY_DIR}" MATCHES " ")
+ # Our build tree has a space, so the build tool supports spaces.
+ # Test using modules from a path with spaces.
+ string(APPEND External_BINARY_DIR " Build")
+endif()
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ExternalProject
+ COMMAND ${CMAKE_CTEST_COMMAND}
+ ARGS ${External_CONFIG_TYPE}
+ --build-and-test
+ ${External_SOURCE_DIR}
+ ${External_BINARY_DIR}
+ --build-noclean
+ --build-two-config
+ --build-project ExtFort
+ --build-generator ${CMAKE_GENERATOR}
+ --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
+ --build-options -DCMAKE_Fortran_COMPILER:STRING=${CMAKE_Fortran_COMPILER}
+ -DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}
+ -DCMAKE_Fortran_FLAGS_DEBUG:STRING=${CMAKE_Fortran_FLAGS_DEBUG}
+ -DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}
+ -DCMAKE_Fortran_FLAGS_MINSIZEREL:STRING=${CMAKE_Fortran_FLAGS_MINSIZEREL}
+ -DCMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO}
+ -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_NESTED_MAKE_PROGRAM}
+ ${External_BUILD_TYPE}
+ VERBATIM
+ )
+add_custom_target(ExternalTarget ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ExternalProject)
+
+# Test module output directory if available.
+if(CMAKE_Fortran_MODDIR_FLAG)
+ set(Library_MODDIR "${CMAKE_CURRENT_BINARY_DIR}/Library/modules")
+else()
+ set(Library_MODDIR "${CMAKE_CURRENT_BINARY_DIR}/Library")
+endif()
+
+add_subdirectory(Library)
+add_subdirectory(Subdir)
+add_subdirectory(Executable)