From f4fb1a4f91ead40d04cfed4a570e25821a1e37ef Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 28 Dec 2007 11:50:29 -0500 Subject: [PATCH] ENH: Add tests of Fortran module dependencies across directories and on external modules. Tests based on cases provided by Maik in issue #5809. --- Tests/Fortran/CMakeLists.txt | 29 +++++++++++++++++++++++++ Tests/Fortran/Executable/CMakeLists.txt | 8 +++++++ Tests/Fortran/Executable/main.f90 | 6 +++++ Tests/Fortran/External/CMakeLists.txt | 4 ++++ Tests/Fortran/External/a.f90 | 7 ++++++ 5 files changed, 54 insertions(+) create mode 100644 Tests/Fortran/Executable/CMakeLists.txt create mode 100644 Tests/Fortran/Executable/main.f90 create mode 100644 Tests/Fortran/External/CMakeLists.txt create mode 100644 Tests/Fortran/External/a.f90 diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index a8b861cc9..fc22a01a1 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -22,5 +22,34 @@ IF(CMAKE_Fortran_COMPILER_SUPPORTS_F90) in_interface/main.f90 in_interface/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}") + ELSE(CMAKE_CONFIGURATION_TYPES) + SET(External_CONFIG_TYPE) + ENDIF(CMAKE_CONFIGURATION_TYPES) + ADD_CUSTOM_COMMAND( + OUTPUT ${testf_BINARY_DIR}/ExternalProject + COMMAND ${CMAKE_CTEST_COMMAND} + ARGS ${External_CONFIG_TYPE} + --build-and-test + ${testf_SOURCE_DIR}/External + ${testf_BINARY_DIR}/External + --build-noclean + --build-two-config + --build-project ExtFort + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --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} + ) + ADD_CUSTOM_TARGET(ExternalTarget ALL DEPENDS ${testf_BINARY_DIR}/ExternalProject) + ADD_SUBDIRECTORY(Library) + ADD_SUBDIRECTORY(Executable) ENDIF(CMAKE_Fortran_COMPILER_SUPPORTS_F90) diff --git a/Tests/Fortran/Executable/CMakeLists.txt b/Tests/Fortran/Executable/CMakeLists.txt new file mode 100644 index 000000000..7596ff1fc --- /dev/null +++ b/Tests/Fortran/Executable/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(${testf_BINARY_DIR}/Library) +include_directories(${testf_BINARY_DIR}/External) +link_directories(${testf_BINARY_DIR}/External) + +add_executable(subdir_exe2 main.f90) +target_link_libraries(subdir_exe2 subdir_mods) +add_dependencies(subdir_exe2 ExternalTarget) +target_link_libraries(subdir_exe2 myext) diff --git a/Tests/Fortran/Executable/main.f90 b/Tests/Fortran/Executable/main.f90 new file mode 100644 index 000000000..f21156cda --- /dev/null +++ b/Tests/Fortran/Executable/main.f90 @@ -0,0 +1,6 @@ +PROGRAM MAINF90 + USE libraryModuleA + USE libraryModuleB + USE externalMod + CALL printExtModGreeting +END PROGRAM MAINF90 diff --git a/Tests/Fortran/External/CMakeLists.txt b/Tests/Fortran/External/CMakeLists.txt new file mode 100644 index 000000000..0eb1cfeed --- /dev/null +++ b/Tests/Fortran/External/CMakeLists.txt @@ -0,0 +1,4 @@ +project(ExtFort Fortran) + +add_library(myext a.f90) + diff --git a/Tests/Fortran/External/a.f90 b/Tests/Fortran/External/a.f90 new file mode 100644 index 000000000..2be73c53c --- /dev/null +++ b/Tests/Fortran/External/a.f90 @@ -0,0 +1,7 @@ +MODULE externalMod +! +CONTAINS + SUBROUTINE printExtModGreeting + WRITE(*,*) "Greetings from Module externalMod" + END SUBROUTINE +END MODULE