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.
This commit is contained in:
Brad King 2009-07-27 12:43:42 -04:00
parent 1c98cdf224
commit 2b849a77a6
3 changed files with 9 additions and 3 deletions

View File

@ -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}")

View File

@ -1,7 +1,7 @@
#include "foo.h"
extern F_test_mod_sub();
extern F_mysub();
int main()
int foo()
{
F_mysub();
F_my_sub();

6
Tests/Fortran/foo.cxx Normal file
View File

@ -0,0 +1,6 @@
extern "C" int foo(void);
int main()
{
delete new int;
return foo();
}