From f3cd1e06f5a5fb092f249de3e1b582125d067daa Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 4 Aug 2009 14:06:45 -0400 Subject: [PATCH] Test C, C++, Fortran interface combinations Previously the Fortran test created a single executable containing C, C++, and Fortran sources. This commit divides the executable into three libraries corresponding to each language, and two executables testing Fortran/C only and Fortran/C/C++ together. The result tests more combinations of using the languages together, and that language requirements propagate through linking. --- Tests/Fortran/CMakeLists.txt | 16 ++++++++++++++-- Tests/Fortran/foo.cxx | 6 ------ Tests/Fortran/mainc.c | 5 +++++ Tests/Fortran/maincxx.c | 6 ++++++ Tests/Fortran/{foo.c => myc.c} | 7 ++++--- Tests/Fortran/mycxx.cxx | 6 ++++++ 6 files changed, 35 insertions(+), 11 deletions(-) delete mode 100644 Tests/Fortran/foo.cxx create mode 100644 Tests/Fortran/mainc.c create mode 100644 Tests/Fortran/maincxx.c rename Tests/Fortran/{foo.c => myc.c} (55%) create mode 100644 Tests/Fortran/mycxx.cxx diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 91390e9c2..c435faae1 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -30,7 +30,6 @@ 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 foo.cxx) create_fortran_c_interface("F_" FORTRAN_FUNCTIONS "${testf_BINARY_DIR}/foo.h") include_directories("${testf_BINARY_DIR}") @@ -61,7 +60,20 @@ function(test_fortran_c_interface_module) endif() message("Fortran = ${CMAKE_Fortran_COMPILER_ID}") message("C = ${CMAKE_C_COMPILER_ID}") - add_executable(foo ${srcs}) + + add_library(myfort mysub.f ${srcs}) + + add_library(myc myc.c) + target_link_libraries(myc myfort) + + add_library(mycxx mycxx.cxx) + target_link_libraries(mycxx myc) + + add_executable(mainc mainc.c) + target_link_libraries(mainc myc) + add_executable(maincxx maincxx.c) + target_link_libraries(maincxx mycxx) + # print out some stuff to help debug on machines via cdash file(READ "${testf_BINARY_DIR}/foo.h" fooh) message("foo.h contents:\n${fooh}") diff --git a/Tests/Fortran/foo.cxx b/Tests/Fortran/foo.cxx deleted file mode 100644 index bb3117ff2..000000000 --- a/Tests/Fortran/foo.cxx +++ /dev/null @@ -1,6 +0,0 @@ -extern "C" int foo(void); -int main() -{ - delete new int; - return foo(); -} diff --git a/Tests/Fortran/mainc.c b/Tests/Fortran/mainc.c new file mode 100644 index 000000000..9efafc5c0 --- /dev/null +++ b/Tests/Fortran/mainc.c @@ -0,0 +1,5 @@ +extern int myc(void); +int main() +{ + return myc(); +} diff --git a/Tests/Fortran/maincxx.c b/Tests/Fortran/maincxx.c new file mode 100644 index 000000000..d35ea7e25 --- /dev/null +++ b/Tests/Fortran/maincxx.c @@ -0,0 +1,6 @@ +extern int myc(void); +extern int mycxx(void); +int main() +{ + return myc() + mycxx(); +} diff --git a/Tests/Fortran/foo.c b/Tests/Fortran/myc.c similarity index 55% rename from Tests/Fortran/foo.c rename to Tests/Fortran/myc.c index 7837534c7..b817dff63 100644 --- a/Tests/Fortran/foo.c +++ b/Tests/Fortran/myc.c @@ -1,11 +1,12 @@ #include "foo.h" -extern F_test_mod_sub(); -extern F_mysub(); -int foo() +extern F_test_mod_sub(void); +extern F_mysub(void); +int myc(void) { F_mysub(); F_my_sub(); #ifdef F_test_mod_sub F_test_mod_sub(); #endif + return 0; } diff --git a/Tests/Fortran/mycxx.cxx b/Tests/Fortran/mycxx.cxx new file mode 100644 index 000000000..bf04062ed --- /dev/null +++ b/Tests/Fortran/mycxx.cxx @@ -0,0 +1,6 @@ +extern "C" int myc(void); +extern "C" int mycxx(void) +{ + delete new int; + return myc(); +}