From 2b849a77a6e108100cae8d1ae59be2a7727a66ec Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 27 Jul 2009 12:43:42 -0400 Subject: ENH: Test Fortran and C++ in one executable This extends the Fortran-to-C interface test to add a C++ source file. The executable can only link with the C++ linker and with the proper Fortran runtime libraries. These libraries should be detected by CMake automatically, so this tests verifies the detection functionality. --- Tests/Fortran/CMakeLists.txt | 4 ++-- Tests/Fortran/foo.c | 2 +- Tests/Fortran/foo.cxx | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 Tests/Fortran/foo.cxx diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index d11d299..91390e9 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 2.6) -project(testf Fortran C) +project(testf Fortran C CXX) message("CTEST_FULL_OUTPUT ") set(CMAKE_VERBOSE_MAKEFILE 1) message("ENV_FLAGS = $ENV{FFLAGS}") @@ -30,7 +30,7 @@ function(test_fortran_c_interface_module) endif(FORTRAN_C_MODULE_MANGLING_FOUND) endif() set(FORTRAN_FUNCTIONS ${FORTRAN_FUNCTIONS} my_sub mysub ) - set(srcs ${srcs} mysub.f foo.c) + set(srcs ${srcs} mysub.f foo.c foo.cxx) create_fortran_c_interface("F_" FORTRAN_FUNCTIONS "${testf_BINARY_DIR}/foo.h") include_directories("${testf_BINARY_DIR}") diff --git a/Tests/Fortran/foo.c b/Tests/Fortran/foo.c index f03aec1..7837534 100644 --- a/Tests/Fortran/foo.c +++ b/Tests/Fortran/foo.c @@ -1,7 +1,7 @@ #include "foo.h" extern F_test_mod_sub(); extern F_mysub(); -int main() +int foo() { F_mysub(); F_my_sub(); diff --git a/Tests/Fortran/foo.cxx b/Tests/Fortran/foo.cxx new file mode 100644 index 0000000..bb3117f --- /dev/null +++ b/Tests/Fortran/foo.cxx @@ -0,0 +1,6 @@ +extern "C" int foo(void); +int main() +{ + delete new int; + return foo(); +} -- cgit v0.12