ENH: only call the fortran c interface test when compilers match
This commit is contained in:
parent
e3cb059859
commit
020f5ae82e
|
@ -9,6 +9,9 @@ MESSAGE("CMAKE_Fortran_COMPILER = ${CMAKE_Fortran_COMPILER}")
|
|||
MESSAGE("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}")
|
||||
ADD_EXECUTABLE(testf hello.f)
|
||||
|
||||
|
||||
function(test_fortran_c_interface_module)
|
||||
message(STATUS "Testing FortranCInterface module")
|
||||
# test the C to Fortran interface module
|
||||
include(FortranCInterface)
|
||||
if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
|
||||
|
@ -28,23 +31,11 @@ if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
|
|||
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")
|
||||
create_fortran_c_interface("F_" FORTRAN_FUNCTIONS
|
||||
"${testf_BINARY_DIR}/foo.h")
|
||||
include_directories("${testf_BINARY_DIR}")
|
||||
|
||||
if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "${CMAKE_C_COMPILER_ID}" )
|
||||
message("Fortran = ${CMAKE_Fortran_COMPILER_ID}")
|
||||
message("C = ${CMAKE_C_COMPILER_ID}")
|
||||
add_executable(foo ${srcs})
|
||||
else()
|
||||
message("Fortran does not match c compiler")
|
||||
message("Fortran = ${CMAKE_Fortran_COMPILER_ID}")
|
||||
message("C = ${CMAKE_C_COMPILER_ID}")
|
||||
endif()
|
||||
# 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}")
|
||||
|
||||
# if the name mangling is not found for an F90 compiler
|
||||
# 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)
|
||||
|
@ -68,6 +59,31 @@ if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
|
|||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
message("Fortran = ${CMAKE_Fortran_COMPILER_ID}")
|
||||
message("C = ${CMAKE_C_COMPILER_ID}")
|
||||
add_executable(foo ${srcs})
|
||||
# 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}")
|
||||
endfunction()
|
||||
|
||||
# if the id's match or the compilers are compatible, then
|
||||
# call the test_fortran_c_interface_module function
|
||||
if(("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel")
|
||||
AND
|
||||
("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
|
||||
)
|
||||
set(COMPATABLE_COMPILERS TRUE)
|
||||
endif()
|
||||
if(COMPATABLE_COMPILERS
|
||||
OR ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "${CMAKE_C_COMPILER_ID}" ))
|
||||
test_fortran_c_interface_module()
|
||||
else()
|
||||
message("Fortran does not match c compiler")
|
||||
message("Fortran = ${CMAKE_Fortran_COMPILER_ID}")
|
||||
message("C = ${CMAKE_C_COMPILER_ID}")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue