From eb8cd35684f2dc2f53d205d7738e1c01a12a493f Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 22 Sep 2016 14:23:39 -0400 Subject: Tests: Split Fortran module testing into separate FortranModules test The main Fortran test is not granular enough. Split some into another test. --- Tests/CMakeLists.txt | 14 +++- Tests/Fortran/CMakeLists.txt | 85 ---------------------- Tests/Fortran/Executable/CMakeLists.txt | 8 -- Tests/Fortran/Executable/main.f90 | 7 -- Tests/Fortran/External/CMakeLists.txt | 3 - Tests/Fortran/External/a.f90 | 7 -- Tests/Fortran/Library/CMakeLists.txt | 11 --- Tests/Fortran/Library/a.f90 | 3 - Tests/Fortran/Library/b.f90 | 2 - Tests/Fortran/Library/main.f90 | 3 - Tests/Fortran/Subdir/CMakeLists.txt | 2 - Tests/Fortran/Subdir/subdir.f90 | 2 - Tests/Fortran/in_interface/main.f90 | 3 - Tests/Fortran/in_interface/module.f90 | 12 --- Tests/Fortran/include/test_preprocess.h | 5 -- Tests/Fortran/test_module_implementation.f90 | 6 -- Tests/Fortran/test_module_interface.f90 | 9 --- Tests/Fortran/test_module_main.f90 | 4 - Tests/Fortran/test_preprocess.F90 | 53 -------------- Tests/Fortran/test_preprocess_module.F90 | 5 -- Tests/Fortran/test_use_in_comment_fixedform.f | 7 -- Tests/Fortran/test_use_in_comment_freeform.f90 | 7 -- Tests/FortranModules/CMakeLists.txt | 78 ++++++++++++++++++++ Tests/FortranModules/Executable/CMakeLists.txt | 8 ++ Tests/FortranModules/Executable/main.f90 | 7 ++ Tests/FortranModules/External/CMakeLists.txt | 3 + Tests/FortranModules/External/a.f90 | 7 ++ Tests/FortranModules/Library/CMakeLists.txt | 11 +++ Tests/FortranModules/Library/a.f90 | 3 + Tests/FortranModules/Library/b.f90 | 2 + Tests/FortranModules/Library/main.f90 | 3 + Tests/FortranModules/Subdir/CMakeLists.txt | 2 + Tests/FortranModules/Subdir/subdir.f90 | 2 + Tests/FortranModules/in_interface/main.f90 | 3 + Tests/FortranModules/in_interface/module.f90 | 12 +++ Tests/FortranModules/include/test_preprocess.h | 5 ++ .../FortranModules/test_module_implementation.f90 | 6 ++ Tests/FortranModules/test_module_interface.f90 | 9 +++ Tests/FortranModules/test_module_main.f90 | 4 + Tests/FortranModules/test_preprocess.F90 | 53 ++++++++++++++ Tests/FortranModules/test_preprocess_module.F90 | 5 ++ .../FortranModules/test_use_in_comment_fixedform.f | 7 ++ .../test_use_in_comment_freeform.f90 | 7 ++ 43 files changed, 250 insertions(+), 245 deletions(-) delete mode 100644 Tests/Fortran/Executable/CMakeLists.txt delete mode 100644 Tests/Fortran/Executable/main.f90 delete mode 100644 Tests/Fortran/External/CMakeLists.txt delete mode 100644 Tests/Fortran/External/a.f90 delete mode 100644 Tests/Fortran/Library/CMakeLists.txt delete mode 100644 Tests/Fortran/Library/a.f90 delete mode 100644 Tests/Fortran/Library/b.f90 delete mode 100644 Tests/Fortran/Library/main.f90 delete mode 100644 Tests/Fortran/Subdir/CMakeLists.txt delete mode 100644 Tests/Fortran/Subdir/subdir.f90 delete mode 100644 Tests/Fortran/in_interface/main.f90 delete mode 100644 Tests/Fortran/in_interface/module.f90 delete mode 100644 Tests/Fortran/include/test_preprocess.h delete mode 100644 Tests/Fortran/test_module_implementation.f90 delete mode 100644 Tests/Fortran/test_module_interface.f90 delete mode 100644 Tests/Fortran/test_module_main.f90 delete mode 100644 Tests/Fortran/test_preprocess.F90 delete mode 100644 Tests/Fortran/test_preprocess_module.F90 delete mode 100644 Tests/Fortran/test_use_in_comment_fixedform.f delete mode 100644 Tests/Fortran/test_use_in_comment_freeform.f90 create mode 100644 Tests/FortranModules/CMakeLists.txt create mode 100644 Tests/FortranModules/Executable/CMakeLists.txt create mode 100644 Tests/FortranModules/Executable/main.f90 create mode 100644 Tests/FortranModules/External/CMakeLists.txt create mode 100644 Tests/FortranModules/External/a.f90 create mode 100644 Tests/FortranModules/Library/CMakeLists.txt create mode 100644 Tests/FortranModules/Library/a.f90 create mode 100644 Tests/FortranModules/Library/b.f90 create mode 100644 Tests/FortranModules/Library/main.f90 create mode 100644 Tests/FortranModules/Subdir/CMakeLists.txt create mode 100644 Tests/FortranModules/Subdir/subdir.f90 create mode 100644 Tests/FortranModules/in_interface/main.f90 create mode 100644 Tests/FortranModules/in_interface/module.f90 create mode 100644 Tests/FortranModules/include/test_preprocess.h create mode 100644 Tests/FortranModules/test_module_implementation.f90 create mode 100644 Tests/FortranModules/test_module_interface.f90 create mode 100644 Tests/FortranModules/test_module_main.f90 create mode 100644 Tests/FortranModules/test_preprocess.F90 create mode 100644 Tests/FortranModules/test_preprocess_module.F90 create mode 100644 Tests/FortranModules/test_use_in_comment_fixedform.f create mode 100644 Tests/FortranModules/test_use_in_comment_freeform.f90 diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 8cf1faa..235e38a 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3097,10 +3097,22 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-project testf --build-two-config --build-options ${build_options} - -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} --test-command testf) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") + if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) + add_test(FortranModules ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FortranModules" + "${CMake_BINARY_DIR}/Tests/FortranModules" + ${build_generator_args} + --build-project FortranModules + --build-options ${build_options} + -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranModules") + endif() + # FortranCInterface tests. if(UNIX) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 3105d13..740e6f5 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -1,8 +1,5 @@ cmake_minimum_required (VERSION 3.1) project(testf C CXX 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() message("CTEST_FULL_OUTPUT ") set(CMAKE_VERBOSE_MAKEFILE 1) @@ -144,85 +141,3 @@ else() endif() endif() - - - - -set(TEST_MODULE_DEPENDS 0) -if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - 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) - - set(TEST_MODULE_DEPENDS 1) -endif() - -if(TEST_MODULE_DEPENDS) - # 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) -endif() diff --git a/Tests/Fortran/Executable/CMakeLists.txt b/Tests/Fortran/Executable/CMakeLists.txt deleted file mode 100644 index de08d86..0000000 --- a/Tests/Fortran/Executable/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -include_directories(${Library_MODDIR}) -include_directories(${External_BINARY_DIR}) -link_directories(${External_BINARY_DIR}) - -add_executable(subdir_exe2 main.f90) -target_link_libraries(subdir_exe2 subdir_mods subdir_mods2) -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 deleted file mode 100644 index 640259c..0000000 --- a/Tests/Fortran/Executable/main.f90 +++ /dev/null @@ -1,7 +0,0 @@ -PROGRAM MAINF90 - USE libraryModuleA - USE libraryModuleB - USE subdirModuleA - USE externalMod - CALL printExtModGreeting -END PROGRAM MAINF90 diff --git a/Tests/Fortran/External/CMakeLists.txt b/Tests/Fortran/External/CMakeLists.txt deleted file mode 100644 index c90a0ffb..0000000 --- a/Tests/Fortran/External/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -project(ExtFort Fortran) - -add_library(myext a.f90) diff --git a/Tests/Fortran/External/a.f90 b/Tests/Fortran/External/a.f90 deleted file mode 100644 index 2be73c5..0000000 --- a/Tests/Fortran/External/a.f90 +++ /dev/null @@ -1,7 +0,0 @@ -MODULE externalMod -! -CONTAINS - SUBROUTINE printExtModGreeting - WRITE(*,*) "Greetings from Module externalMod" - END SUBROUTINE -END MODULE diff --git a/Tests/Fortran/Library/CMakeLists.txt b/Tests/Fortran/Library/CMakeLists.txt deleted file mode 100644 index 17438ca..0000000 --- a/Tests/Fortran/Library/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -include_directories(${Library_MODDIR}) -add_library(subdir_mods a.f90 b.f90) -add_executable(subdir_exe main.f90) -target_link_libraries(subdir_exe subdir_mods) - -# Test module output directory if available. -if(CMAKE_Fortran_MODDIR_FLAG) - set_target_properties(subdir_mods PROPERTIES - Fortran_MODULE_DIRECTORY modules - ) -endif() diff --git a/Tests/Fortran/Library/a.f90 b/Tests/Fortran/Library/a.f90 deleted file mode 100644 index 3031c07..0000000 --- a/Tests/Fortran/Library/a.f90 +++ /dev/null @@ -1,3 +0,0 @@ -MODULE libraryModuleA - USE libraryModuleB -END MODULE diff --git a/Tests/Fortran/Library/b.f90 b/Tests/Fortran/Library/b.f90 deleted file mode 100644 index ae1edcb..0000000 --- a/Tests/Fortran/Library/b.f90 +++ /dev/null @@ -1,2 +0,0 @@ -MODULE libraryModuleB -END MODULE diff --git a/Tests/Fortran/Library/main.f90 b/Tests/Fortran/Library/main.f90 deleted file mode 100644 index 2385408..0000000 --- a/Tests/Fortran/Library/main.f90 +++ /dev/null @@ -1,3 +0,0 @@ -PROGRAM MAINF90 - USE libraryModuleA -END PROGRAM MAINF90 diff --git a/Tests/Fortran/Subdir/CMakeLists.txt b/Tests/Fortran/Subdir/CMakeLists.txt deleted file mode 100644 index 52683e5..0000000 --- a/Tests/Fortran/Subdir/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_library(subdir_mods2 subdir.f90) -target_include_directories(subdir_mods2 INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/Tests/Fortran/Subdir/subdir.f90 b/Tests/Fortran/Subdir/subdir.f90 deleted file mode 100644 index 68955f6..0000000 --- a/Tests/Fortran/Subdir/subdir.f90 +++ /dev/null @@ -1,2 +0,0 @@ -MODULE subdirModuleA -END MODULE diff --git a/Tests/Fortran/in_interface/main.f90 b/Tests/Fortran/in_interface/main.f90 deleted file mode 100644 index 28bcf36..0000000 --- a/Tests/Fortran/in_interface/main.f90 +++ /dev/null @@ -1,3 +0,0 @@ -program hello - use test_interface -end program hello diff --git a/Tests/Fortran/in_interface/module.f90 b/Tests/Fortran/in_interface/module.f90 deleted file mode 100644 index 1064d74..0000000 --- a/Tests/Fortran/in_interface/module.f90 +++ /dev/null @@ -1,12 +0,0 @@ -module test_interface - - interface dummy - module procedure module_function - end interface - -contains - - subroutine module_function - end subroutine - -end module test_interface \ No newline at end of file diff --git a/Tests/Fortran/include/test_preprocess.h b/Tests/Fortran/include/test_preprocess.h deleted file mode 100644 index f4a00a9..0000000 --- a/Tests/Fortran/include/test_preprocess.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifdef BAR -PRINT*, 'BAR was defined via ADD_DEFINITIONS' -#else -PRINT*, 'If you can read this something went wrong' -#endif diff --git a/Tests/Fortran/test_module_implementation.f90 b/Tests/Fortran/test_module_implementation.f90 deleted file mode 100644 index de3cb57..0000000 --- a/Tests/Fortran/test_module_implementation.f90 +++ /dev/null @@ -1,6 +0,0 @@ -FUNCTION TEST_MODULE_FUNCTION(A,B) - REAL :: TEST_MODULE_FUNCTION - REAL, INTENT(IN) :: A - REAL, INTENT(IN) :: B - TEST_MODULE_FUNCTION = A + B -END FUNCTION TEST_MODULE_FUNCTION diff --git a/Tests/Fortran/test_module_interface.f90 b/Tests/Fortran/test_module_interface.f90 deleted file mode 100644 index dd0f35c..0000000 --- a/Tests/Fortran/test_module_interface.f90 +++ /dev/null @@ -1,9 +0,0 @@ -MODULE TEST_MODULE - INTERFACE - FUNCTION TEST_MODULE_FUNCTION(A,B) - REAL :: TEST_MODULE_FUNCTION - REAL, INTENT(IN) :: A - REAL, INTENT(IN) :: B - END FUNCTION TEST_MODULE_FUNCTION - END INTERFACE -END MODULE TEST_MODULE diff --git a/Tests/Fortran/test_module_main.f90 b/Tests/Fortran/test_module_main.f90 deleted file mode 100644 index 6ac97fa..0000000 --- a/Tests/Fortran/test_module_main.f90 +++ /dev/null @@ -1,4 +0,0 @@ -PROGRAM MAINF90 - USE TEST_MODULE - PRINT *,'Sum is',TEST_MODULE_FUNCTION(1., 2.) -END PROGRAM MAINF90 diff --git a/Tests/Fortran/test_preprocess.F90 b/Tests/Fortran/test_preprocess.F90 deleted file mode 100644 index 3a09976..0000000 --- a/Tests/Fortran/test_preprocess.F90 +++ /dev/null @@ -1,53 +0,0 @@ -MODULE Available -! no conent -END MODULE - -PROGRAM PPTEST -! value of InPPFalseBranch ; values of SkipToEnd -! 0 -#ifndef FOO - ! 1 ; <0> - USE NotAvailable -# ifndef FOO - ! 2 ; <0,0> - USE NotAvailable -# else - ! 2 ; <0,0> - USE NotAvailable -# endif - ! 1 ; <0> -# ifdef FOO - ! 2 ; <0,1> - USE NotAvailable -# else - ! 2 ; <0,1> - USE NotAvailable -# endif - ! 1 ; <0> -#else - ! 0 ; <0> - USE Available -# ifndef FOO - ! 1 ; <0,0> - USE NotAvailable -# else - ! 0 ; <0,0> - USE Available -# endif - ! 0 ; <0> -# ifdef FOO - ! 0 ; <0,1> - USE Available -# else - ! 1 ; <0,1> - USE NotAvailable -# endif - ! 0 ; <0> -#endif -! 0 ; - -USE PPAvailable - -#include "test_preprocess.h" - -END PROGRAM diff --git a/Tests/Fortran/test_preprocess_module.F90 b/Tests/Fortran/test_preprocess_module.F90 deleted file mode 100644 index 5849b62..0000000 --- a/Tests/Fortran/test_preprocess_module.F90 +++ /dev/null @@ -1,5 +0,0 @@ -#ifdef FOO -MODULE PPAvailable -! no conent -END MODULE -#endif diff --git a/Tests/Fortran/test_use_in_comment_fixedform.f b/Tests/Fortran/test_use_in_comment_fixedform.f deleted file mode 100644 index 39f486b..0000000 --- a/Tests/Fortran/test_use_in_comment_fixedform.f +++ /dev/null @@ -1,7 +0,0 @@ - PROGRAM foo -! USE bar -! use bar -! Use bar - - WRITE(*,*) 'Hello, Fortran world.' - END PROGRAM diff --git a/Tests/Fortran/test_use_in_comment_freeform.f90 b/Tests/Fortran/test_use_in_comment_freeform.f90 deleted file mode 100644 index 48bcd5a..0000000 --- a/Tests/Fortran/test_use_in_comment_freeform.f90 +++ /dev/null @@ -1,7 +0,0 @@ -PROGRAM foo -! USE bar -! use bar -! Use bar - - WRITE(*,*) 'Hello, Fortran world.' -END PROGRAM 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) diff --git a/Tests/FortranModules/Executable/CMakeLists.txt b/Tests/FortranModules/Executable/CMakeLists.txt new file mode 100644 index 0000000..de08d86 --- /dev/null +++ b/Tests/FortranModules/Executable/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(${Library_MODDIR}) +include_directories(${External_BINARY_DIR}) +link_directories(${External_BINARY_DIR}) + +add_executable(subdir_exe2 main.f90) +target_link_libraries(subdir_exe2 subdir_mods subdir_mods2) +add_dependencies(subdir_exe2 ExternalTarget) +target_link_libraries(subdir_exe2 myext) diff --git a/Tests/FortranModules/Executable/main.f90 b/Tests/FortranModules/Executable/main.f90 new file mode 100644 index 0000000..640259c --- /dev/null +++ b/Tests/FortranModules/Executable/main.f90 @@ -0,0 +1,7 @@ +PROGRAM MAINF90 + USE libraryModuleA + USE libraryModuleB + USE subdirModuleA + USE externalMod + CALL printExtModGreeting +END PROGRAM MAINF90 diff --git a/Tests/FortranModules/External/CMakeLists.txt b/Tests/FortranModules/External/CMakeLists.txt new file mode 100644 index 0000000..c90a0ffb --- /dev/null +++ b/Tests/FortranModules/External/CMakeLists.txt @@ -0,0 +1,3 @@ +project(ExtFort Fortran) + +add_library(myext a.f90) diff --git a/Tests/FortranModules/External/a.f90 b/Tests/FortranModules/External/a.f90 new file mode 100644 index 0000000..2be73c5 --- /dev/null +++ b/Tests/FortranModules/External/a.f90 @@ -0,0 +1,7 @@ +MODULE externalMod +! +CONTAINS + SUBROUTINE printExtModGreeting + WRITE(*,*) "Greetings from Module externalMod" + END SUBROUTINE +END MODULE diff --git a/Tests/FortranModules/Library/CMakeLists.txt b/Tests/FortranModules/Library/CMakeLists.txt new file mode 100644 index 0000000..17438ca --- /dev/null +++ b/Tests/FortranModules/Library/CMakeLists.txt @@ -0,0 +1,11 @@ +include_directories(${Library_MODDIR}) +add_library(subdir_mods a.f90 b.f90) +add_executable(subdir_exe main.f90) +target_link_libraries(subdir_exe subdir_mods) + +# Test module output directory if available. +if(CMAKE_Fortran_MODDIR_FLAG) + set_target_properties(subdir_mods PROPERTIES + Fortran_MODULE_DIRECTORY modules + ) +endif() diff --git a/Tests/FortranModules/Library/a.f90 b/Tests/FortranModules/Library/a.f90 new file mode 100644 index 0000000..3031c07 --- /dev/null +++ b/Tests/FortranModules/Library/a.f90 @@ -0,0 +1,3 @@ +MODULE libraryModuleA + USE libraryModuleB +END MODULE diff --git a/Tests/FortranModules/Library/b.f90 b/Tests/FortranModules/Library/b.f90 new file mode 100644 index 0000000..ae1edcb --- /dev/null +++ b/Tests/FortranModules/Library/b.f90 @@ -0,0 +1,2 @@ +MODULE libraryModuleB +END MODULE diff --git a/Tests/FortranModules/Library/main.f90 b/Tests/FortranModules/Library/main.f90 new file mode 100644 index 0000000..2385408 --- /dev/null +++ b/Tests/FortranModules/Library/main.f90 @@ -0,0 +1,3 @@ +PROGRAM MAINF90 + USE libraryModuleA +END PROGRAM MAINF90 diff --git a/Tests/FortranModules/Subdir/CMakeLists.txt b/Tests/FortranModules/Subdir/CMakeLists.txt new file mode 100644 index 0000000..52683e5 --- /dev/null +++ b/Tests/FortranModules/Subdir/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(subdir_mods2 subdir.f90) +target_include_directories(subdir_mods2 INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/Tests/FortranModules/Subdir/subdir.f90 b/Tests/FortranModules/Subdir/subdir.f90 new file mode 100644 index 0000000..68955f6 --- /dev/null +++ b/Tests/FortranModules/Subdir/subdir.f90 @@ -0,0 +1,2 @@ +MODULE subdirModuleA +END MODULE diff --git a/Tests/FortranModules/in_interface/main.f90 b/Tests/FortranModules/in_interface/main.f90 new file mode 100644 index 0000000..28bcf36 --- /dev/null +++ b/Tests/FortranModules/in_interface/main.f90 @@ -0,0 +1,3 @@ +program hello + use test_interface +end program hello diff --git a/Tests/FortranModules/in_interface/module.f90 b/Tests/FortranModules/in_interface/module.f90 new file mode 100644 index 0000000..1064d74 --- /dev/null +++ b/Tests/FortranModules/in_interface/module.f90 @@ -0,0 +1,12 @@ +module test_interface + + interface dummy + module procedure module_function + end interface + +contains + + subroutine module_function + end subroutine + +end module test_interface \ No newline at end of file diff --git a/Tests/FortranModules/include/test_preprocess.h b/Tests/FortranModules/include/test_preprocess.h new file mode 100644 index 0000000..f4a00a9 --- /dev/null +++ b/Tests/FortranModules/include/test_preprocess.h @@ -0,0 +1,5 @@ +#ifdef BAR +PRINT*, 'BAR was defined via ADD_DEFINITIONS' +#else +PRINT*, 'If you can read this something went wrong' +#endif diff --git a/Tests/FortranModules/test_module_implementation.f90 b/Tests/FortranModules/test_module_implementation.f90 new file mode 100644 index 0000000..de3cb57 --- /dev/null +++ b/Tests/FortranModules/test_module_implementation.f90 @@ -0,0 +1,6 @@ +FUNCTION TEST_MODULE_FUNCTION(A,B) + REAL :: TEST_MODULE_FUNCTION + REAL, INTENT(IN) :: A + REAL, INTENT(IN) :: B + TEST_MODULE_FUNCTION = A + B +END FUNCTION TEST_MODULE_FUNCTION diff --git a/Tests/FortranModules/test_module_interface.f90 b/Tests/FortranModules/test_module_interface.f90 new file mode 100644 index 0000000..dd0f35c --- /dev/null +++ b/Tests/FortranModules/test_module_interface.f90 @@ -0,0 +1,9 @@ +MODULE TEST_MODULE + INTERFACE + FUNCTION TEST_MODULE_FUNCTION(A,B) + REAL :: TEST_MODULE_FUNCTION + REAL, INTENT(IN) :: A + REAL, INTENT(IN) :: B + END FUNCTION TEST_MODULE_FUNCTION + END INTERFACE +END MODULE TEST_MODULE diff --git a/Tests/FortranModules/test_module_main.f90 b/Tests/FortranModules/test_module_main.f90 new file mode 100644 index 0000000..6ac97fa --- /dev/null +++ b/Tests/FortranModules/test_module_main.f90 @@ -0,0 +1,4 @@ +PROGRAM MAINF90 + USE TEST_MODULE + PRINT *,'Sum is',TEST_MODULE_FUNCTION(1., 2.) +END PROGRAM MAINF90 diff --git a/Tests/FortranModules/test_preprocess.F90 b/Tests/FortranModules/test_preprocess.F90 new file mode 100644 index 0000000..3a09976 --- /dev/null +++ b/Tests/FortranModules/test_preprocess.F90 @@ -0,0 +1,53 @@ +MODULE Available +! no conent +END MODULE + +PROGRAM PPTEST +! value of InPPFalseBranch ; values of SkipToEnd +! 0 +#ifndef FOO + ! 1 ; <0> + USE NotAvailable +# ifndef FOO + ! 2 ; <0,0> + USE NotAvailable +# else + ! 2 ; <0,0> + USE NotAvailable +# endif + ! 1 ; <0> +# ifdef FOO + ! 2 ; <0,1> + USE NotAvailable +# else + ! 2 ; <0,1> + USE NotAvailable +# endif + ! 1 ; <0> +#else + ! 0 ; <0> + USE Available +# ifndef FOO + ! 1 ; <0,0> + USE NotAvailable +# else + ! 0 ; <0,0> + USE Available +# endif + ! 0 ; <0> +# ifdef FOO + ! 0 ; <0,1> + USE Available +# else + ! 1 ; <0,1> + USE NotAvailable +# endif + ! 0 ; <0> +#endif +! 0 ; + +USE PPAvailable + +#include "test_preprocess.h" + +END PROGRAM diff --git a/Tests/FortranModules/test_preprocess_module.F90 b/Tests/FortranModules/test_preprocess_module.F90 new file mode 100644 index 0000000..5849b62 --- /dev/null +++ b/Tests/FortranModules/test_preprocess_module.F90 @@ -0,0 +1,5 @@ +#ifdef FOO +MODULE PPAvailable +! no conent +END MODULE +#endif diff --git a/Tests/FortranModules/test_use_in_comment_fixedform.f b/Tests/FortranModules/test_use_in_comment_fixedform.f new file mode 100644 index 0000000..39f486b --- /dev/null +++ b/Tests/FortranModules/test_use_in_comment_fixedform.f @@ -0,0 +1,7 @@ + PROGRAM foo +! USE bar +! use bar +! Use bar + + WRITE(*,*) 'Hello, Fortran world.' + END PROGRAM diff --git a/Tests/FortranModules/test_use_in_comment_freeform.f90 b/Tests/FortranModules/test_use_in_comment_freeform.f90 new file mode 100644 index 0000000..48bcd5a --- /dev/null +++ b/Tests/FortranModules/test_use_in_comment_freeform.f90 @@ -0,0 +1,7 @@ +PROGRAM foo +! USE bar +! use bar +! Use bar + + WRITE(*,*) 'Hello, Fortran world.' +END PROGRAM -- cgit v0.12