diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2008-10-29 14:58:40 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2008-10-29 14:58:40 (GMT) |
commit | 84a4222314e8cb52781cb2b98dca4c69bb6cf739 (patch) | |
tree | 1b3dde4101bdfded6db3a6d500714416b51f6de2 /Tests/Fortran | |
parent | 4eec7b2d03e0173deeb0f7ae29891eefb8ea9bb8 (diff) | |
download | CMake-84a4222314e8cb52781cb2b98dca4c69bb6cf739.zip CMake-84a4222314e8cb52781cb2b98dca4c69bb6cf739.tar.gz CMake-84a4222314e8cb52781cb2b98dca4c69bb6cf739.tar.bz2 |
ENH: add test for FortranCInterface
Diffstat (limited to 'Tests/Fortran')
-rw-r--r-- | Tests/Fortran/CMakeLists.txt | 17 | ||||
-rw-r--r-- | Tests/Fortran/foo.c | 11 | ||||
-rw-r--r-- | Tests/Fortran/foo.f | 9 | ||||
-rw-r--r-- | Tests/Fortran/mysub.f | 4 |
4 files changed, 40 insertions, 1 deletions
diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index ca7d89a..5df5280 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 2.6) -PROJECT(testf Fortran) +PROJECT(testf C Fortran) SET(CMAKE_VERBOSE_MAKEFILE 1) MESSAGE("ENV_FLAGS = $ENV{FFLAGS}") MESSAGE("CMAKE_Fortran_COMPILER_INIT = ${CMAKE_Fortran_COMPILER_INIT}") @@ -8,6 +8,21 @@ MESSAGE("CMAKE_Fortran_COMPILER = ${CMAKE_Fortran_COMPILER}") MESSAGE("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}") ADD_EXECUTABLE(testf hello.f) +# test the C to Fortran interface module +include(FortranCInterface) +if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) + set(srcs foo.f) + set(FORTRAN_FUNCTIONS test_mod:sub) +endif() +set(FORTRAN_FUNCTIONS ${FORTRAN_FUNCTIONS} my_sub mysub ) +set(srcs ${srcs} mysub.f foo.c) +create_fortran_c_interface("F_" FORTRAN_FUNCTIONS "${testf_BINARY_DIR}/foo.h") +include_directories("${testf_BINARY_DIR}") +add_executable(foo ${srcs}) + + + + SET(TEST_MODULE_DEPENDS 0) IF(CMAKE_Fortran_COMPILER_SUPPORTS_F90) ADD_EXECUTABLE(test_module diff --git a/Tests/Fortran/foo.c b/Tests/Fortran/foo.c new file mode 100644 index 0000000..f03aec1 --- /dev/null +++ b/Tests/Fortran/foo.c @@ -0,0 +1,11 @@ +#include "foo.h" +extern F_test_mod_sub(); +extern F_mysub(); +int main() +{ + F_mysub(); + F_my_sub(); +#ifdef F_test_mod_sub + F_test_mod_sub(); +#endif +} diff --git a/Tests/Fortran/foo.f b/Tests/Fortran/foo.f new file mode 100644 index 0000000..dbbb3a4 --- /dev/null +++ b/Tests/Fortran/foo.f @@ -0,0 +1,9 @@ + module test_mod + interface dummy + module procedure sub + end interface + contains + subroutine sub + end subroutine + + end module test_mod diff --git a/Tests/Fortran/mysub.f b/Tests/Fortran/mysub.f new file mode 100644 index 0000000..36b4155 --- /dev/null +++ b/Tests/Fortran/mysub.f @@ -0,0 +1,4 @@ + subroutine mysub + end subroutine + subroutine my_sub + end subroutine |