ENH: add test for FortranCInterface
This commit is contained in:
parent
4eec7b2d03
commit
84a4222314
|
@ -110,9 +110,9 @@ function(discover_fortran_mangling prefix isupper suffix extra_under_score
|
||||||
subroutine sub
|
subroutine sub
|
||||||
end subroutine sub
|
end subroutine sub
|
||||||
")
|
")
|
||||||
foreach(pre "_" "" "__")
|
foreach(post "_" "")
|
||||||
foreach(isup TRUE FALSE)
|
foreach(isup FALSE TRUE)
|
||||||
foreach(post "" "_")
|
foreach(pre "" "_" "__")
|
||||||
set(worked FALSE)
|
set(worked FALSE)
|
||||||
test_fortran_mangling("${CODE}" "${pre}" ${isup}
|
test_fortran_mangling("${CODE}" "${pre}" ${isup}
|
||||||
"${post}" "function" sub worked )
|
"${post}" "function" sub worked )
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required (VERSION 2.6)
|
cmake_minimum_required (VERSION 2.6)
|
||||||
PROJECT(testf Fortran)
|
PROJECT(testf C Fortran)
|
||||||
SET(CMAKE_VERBOSE_MAKEFILE 1)
|
SET(CMAKE_VERBOSE_MAKEFILE 1)
|
||||||
MESSAGE("ENV_FLAGS = $ENV{FFLAGS}")
|
MESSAGE("ENV_FLAGS = $ENV{FFLAGS}")
|
||||||
MESSAGE("CMAKE_Fortran_COMPILER_INIT = ${CMAKE_Fortran_COMPILER_INIT}")
|
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}")
|
MESSAGE("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}")
|
||||||
ADD_EXECUTABLE(testf hello.f)
|
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)
|
SET(TEST_MODULE_DEPENDS 0)
|
||||||
IF(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
|
IF(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
|
||||||
ADD_EXECUTABLE(test_module
|
ADD_EXECUTABLE(test_module
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
module test_mod
|
||||||
|
interface dummy
|
||||||
|
module procedure sub
|
||||||
|
end interface
|
||||||
|
contains
|
||||||
|
subroutine sub
|
||||||
|
end subroutine
|
||||||
|
|
||||||
|
end module test_mod
|
|
@ -0,0 +1,4 @@
|
||||||
|
subroutine mysub
|
||||||
|
end subroutine
|
||||||
|
subroutine my_sub
|
||||||
|
end subroutine
|
Loading…
Reference in New Issue