summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Fortran/CMakeLists.txt72
-rw-r--r--Tests/Fortran/myc.c2
2 files changed, 38 insertions, 36 deletions
diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt
index c435faa..312b4d7 100644
--- a/Tests/Fortran/CMakeLists.txt
+++ b/Tests/Fortran/CMakeLists.txt
@@ -15,47 +15,48 @@ function(test_fortran_c_interface_module)
# test the C to Fortran interface module
include(FortranCInterface)
if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
- if(FORTRAN_C_MODULE_MANGLING_FOUND)
+ if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro")
+ set(module_expected 1)
+ endif()
+ if(FortranCInterface_MODULE_FOUND OR module_expected)
set(srcs foo.f)
set(FORTRAN_FUNCTIONS test_mod:sub)
- else(FORTRAN_C_MODULE_MANGLING_FOUND)
- if(CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro")
- message("${CMAKE_Fortran_COMPILER_ID} compilers do not support"
- " linking Fortran module procedures from C")
- else()
- message("This will fail, but let the user see the error")
- set(srcs foo.f)
- set(FORTRAN_FUNCTIONS test_mod:sub)
- endif()
- endif(FORTRAN_C_MODULE_MANGLING_FOUND)
+ set(MYC_DEFS TEST_MOD)
+ else()
+ message("${CMAKE_Fortran_COMPILER_ID} compilers do not support"
+ " linking Fortran module procedures from C")
+ endif()
endif()
- set(FORTRAN_FUNCTIONS ${FORTRAN_FUNCTIONS} my_sub mysub )
- create_fortran_c_interface("F_" FORTRAN_FUNCTIONS
- "${testf_BINARY_DIR}/foo.h")
+ list(APPEND FORTRAN_FUNCTIONS my_sub mysub)
+ FortranCInterface_HEADER(foo.h
+ MACRO_NAMESPACE "FC_"
+ SYMBOL_NAMESPACE "F_"
+ SYMBOLS ${FORTRAN_FUNCTIONS}
+ )
include_directories("${testf_BINARY_DIR}")
-
+
# if the name mangling is not found for a F90 compiler
# print out some diagnostic stuff for the dashboard
- if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
- if(NOT FORTRAN_C_MODULE_MANGLING_FOUND)
- file(GLOB_RECURSE O_OBJFILES
- "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckFortranLink/*.o"
- "*.o" )
- file(GLOB_RECURSE OBJ_OBJFILES
- "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckFortranLink/*.obj")
- find_program(DUMPBIN dumpbin)
- find_program(NM nm)
- foreach(ofile ${O_OBJFILES} ${OBJ_OBJFILES})
- if(DEPENDS)
- execute_process(COMMAND ${DUMPBIN} /symbols "${ofile}"
- OUTPUT_VARIABLE out)
- message("symbols in ${ofile}:\n${out}")
- endif()
- if(NM)
- execute_process(COMMAND ${NM} "${ofile}" OUTPUT_VARIABLE out)
- message("symbols in ${ofile}:\n${out}")
- endif()
- endforeach()
+ if(NOT FortranCInterface_GLOBAL_FOUND OR
+ (NOT FortranCInterface_MODULE_FOUND AND module_expected) )
+ find_program(FortranCInterface_EXE
+ NAMES FortranCInterface
+ PATHS ${FortranCInterface_BINARY_DIR} ${FortranCInterface_BINARY_DIR}/Debug
+ NO_DEFAULT_PATH
+ )
+ find_program(DUMPBIN dumpbin)
+ find_program(NM nm)
+ if(FortranCInterface_EXE)
+ if(DEPENDS)
+ execute_process(COMMAND ${DUMPBIN} /symbols "${FortranCInterface_EXE}"
+ OUTPUT_VARIABLE out)
+ message("symbols in ${FortranCInterface_EXE}:\n${out}")
+ endif()
+ if(NM)
+ execute_process(COMMAND ${NM} "${FortranCInterface_EXE}"
+ OUTPUT_VARIABLE out)
+ message("symbols in ${FortranCInterface_EXE}:\n${out}")
+ endif()
endif()
endif()
message("Fortran = ${CMAKE_Fortran_COMPILER_ID}")
@@ -65,6 +66,7 @@ function(test_fortran_c_interface_module)
add_library(myc myc.c)
target_link_libraries(myc myfort)
+ set_property(TARGET myc PROPERTY COMPILE_DEFINITIONS ${MYC_DEFS})
add_library(mycxx mycxx.cxx)
target_link_libraries(mycxx myc)
diff --git a/Tests/Fortran/myc.c b/Tests/Fortran/myc.c
index b817dff..efd9b68 100644
--- a/Tests/Fortran/myc.c
+++ b/Tests/Fortran/myc.c
@@ -5,7 +5,7 @@ int myc(void)
{
F_mysub();
F_my_sub();
-#ifdef F_test_mod_sub
+#ifdef TEST_MOD
F_test_mod_sub();
#endif
return 0;