ENH: fix uppercase version so defines are not upper as well

This commit is contained in:
Bill Hoffman 2008-10-30 16:50:12 -04:00
parent 88cf2cb30f
commit 6066a3fca6
1 changed files with 14 additions and 6 deletions

View File

@ -84,7 +84,7 @@ function(discover_fortran_module_mangling prefix suffix found)
end subroutine end subroutine
end module test_interface end module test_interface
") ")
set(worked FALSE)
foreach(interface foreach(interface
"test_interface$" "test_interface$"
"TEST_INTERFACE_mp_" "TEST_INTERFACE_mp_"
@ -106,6 +106,12 @@ function(discover_fortran_module_mangling prefix suffix found)
return() return()
endif(worked) endif(worked)
endforeach(interface) endforeach(interface)
if(NOT worked)
message(STATUS "Failed to find C binding to Fortran module functions.")
set(${prefix} "BROKEN_C_FORTRAN_MODULE_BINDING" PARENT_SCOPE)
set(${suffix} "BROKEN_C_FORTRAN_MODULE_BINDING" PARENT_SCOPE)
set(${found} FALSE PARENT_SCOPE)
endif(NOT worked)
endfunction(discover_fortran_module_mangling) endfunction(discover_fortran_module_mangling)
@ -189,23 +195,25 @@ function(create_fortran_c_interface NAMESPACE FUNCTIONS HEADER)
"SUFFIX for Fortran to c name mangling") "SUFFIX for Fortran to c name mangling")
else(found) else(found)
set(FORTRAN_C_MODULE_MANGLING_FOUND FALSE CACHE INTERNAL set(FORTRAN_C_MODULE_MANGLING_FOUND FALSE CACHE INTERNAL
"SUFFIX for Fortran to c name mangling") "Fortran to C Module calling not availible.")
endif(found) endif(found)
endif(NOT FORTRAN_C_MANGLING_FOUND) endif(NOT FORTRAN_C_MANGLING_FOUND)
foreach(f ${${FUNCTIONS}}) foreach(f ${${FUNCTIONS}})
if(FORTRAN_C_MANGLING_UPPERCASE) if(FORTRAN_C_MANGLING_UPPERCASE)
string(TOUPPER "${f}" f) string(TOUPPER "${f}" fcase)
else() else()
string(TOLOWER "${f}" f) string(TOLOWER "${f}" fcase)
endif() endif()
if("${f}" MATCHES ":") if("${f}" MATCHES ":")
string(REGEX REPLACE "(.*):(.*)" "\\1" module "${f}") string(REGEX REPLACE "(.*):(.*)" "\\1" module "${f}")
string(REGEX REPLACE "(.*):(.*)" "\\2" function "${f}") string(REGEX REPLACE "(.*):(.*)" "\\2" function "${f}")
string(REGEX REPLACE "(.*):(.*)" "\\1" module_case "${fcase}")
string(REGEX REPLACE "(.*):(.*)" "\\2" function_case "${fcase}")
set(HEADER_CONTENT "${HEADER_CONTENT} set(HEADER_CONTENT "${HEADER_CONTENT}
#define ${NAMESPACE}${module}_${function} ${FORTRAN_C_MODULE_PREFIX}${module}${FORTRAN_C_MODULE_SUFFIX}${function} #define ${NAMESPACE}${module}_${function} ${FORTRAN_C_MODULE_PREFIX}${module_case}${FORTRAN_C_MODULE_SUFFIX}${function_case}
") ")
else("${f}" MATCHES ":") else("${f}" MATCHES ":")
set(function "${FORTRAN_C_PREFIX}${f}${FORTRAN_C_SUFFIX}") set(function "${FORTRAN_C_PREFIX}${fcase}${FORTRAN_C_SUFFIX}")
if("${f}" MATCHES "_" AND FORTRAN_C_MANGLING_EXTRA_UNDERSCORE) if("${f}" MATCHES "_" AND FORTRAN_C_MANGLING_EXTRA_UNDERSCORE)
set(function "${function}_") set(function "${function}_")
endif("${f}" MATCHES "_" AND FORTRAN_C_MANGLING_EXTRA_UNDERSCORE) endif("${f}" MATCHES "_" AND FORTRAN_C_MANGLING_EXTRA_UNDERSCORE)