[Cmake-commits] [cmake-commits] hoffman committed FortranCInterface.cmake 1.2 1.3

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Oct 28 19:53:56 EDT 2008


Update of /cvsroot/CMake/CMake/Modules
In directory public:/mounts/ram/cvs-serv18930

Modified Files:
	FortranCInterface.cmake 
Log Message:
ENH: add support for g77 extra _ at the end of functions that have an _ in the name...


Index: FortranCInterface.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/FortranCInterface.cmake,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** FortranCInterface.cmake	28 Oct 2008 01:42:41 -0000	1.2
--- FortranCInterface.cmake	28 Oct 2008 23:53:54 -0000	1.3
***************
*** 28,40 ****
  # ISUPPER - if TRUE then sub will be called as SUB
  # DOC - string used in status checking Fortran ${DOC} linkage
  # RESULT place to store result TRUE if this linkage works, FALSE
  #        if not.
  #
! function(test_fortran_mangling CODE PREFIX ISUPPER POSTFIX DOC RESULT)
    if(ISUPPER)
!     set(FUNCTION "${PREFIX}SUB${POSTFIX}")
!   else(ISUPPER)
!     set(FUNCTION "${PREFIX}sub${POSTFIX}")
    endif(ISUPPER)
    # create a fortran file with sub called sub
    # 
--- 28,42 ----
  # ISUPPER - if TRUE then sub will be called as SUB
  # DOC - string used in status checking Fortran ${DOC} linkage
+ # SUB - the name of the SUB to call
  # RESULT place to store result TRUE if this linkage works, FALSE
  #        if not.
  #
! function(test_fortran_mangling CODE PREFIX ISUPPER POSTFIX DOC SUB RESULT)
    if(ISUPPER)
!     string(TOUPPER "${SUB}" sub)
!   else(ISUPPER) 
!     string(TOLOWER "${SUB}" sub)
    endif(ISUPPER)
+   set(FUNCTION "${PREFIX}${sub}${POSTFIX}")
    # create a fortran file with sub called sub
    # 
***************
*** 89,93 ****
        "__test_interface_MOD_")
      test_fortran_mangling("${CODE}" "${interface}"
!       ${FORTRAN_C_MANGLING_UPPERCASE} "" "module" worked)
      if(worked)
        string(REGEX REPLACE "(.*)test_interface(.*)" "\\1" pre "${interface}")
--- 91,95 ----
        "__test_interface_MOD_")
      test_fortran_mangling("${CODE}" "${interface}"
!       ${FORTRAN_C_MANGLING_UPPERCASE} "" "module" "sub" worked)
      if(worked)
        string(REGEX REPLACE "(.*)test_interface(.*)" "\\1" pre "${interface}")
***************
*** 102,106 ****
  
  
! function(discover_fortran_mangling prefix isupper suffix found )
    set(CODE 
      "
--- 104,109 ----
  
  
! function(discover_fortran_mangling prefix isupper suffix extra_under_score
!     found )
    set(CODE 
      "
***************
*** 112,116 ****
        foreach(post "" "_")
          set(worked FALSE)
!         test_fortran_mangling("${CODE}" "${pre}" ${isup} "${post}" "function" worked )
          if(worked)
            message(STATUS "found Fortran function linkage")
--- 115,120 ----
        foreach(post "" "_")
          set(worked FALSE)
!         test_fortran_mangling("${CODE}" "${pre}" ${isup}
!           "${post}" "function" sub worked )
          if(worked)
            message(STATUS "found Fortran function linkage")
***************
*** 119,123 ****
            set(${suffix} "${post}" PARENT_SCOPE)
            set(${found} TRUE PARENT_SCOPE)
!           return()
          endif()
        endforeach()
--- 123,144 ----
            set(${suffix} "${post}" PARENT_SCOPE)
            set(${found} TRUE PARENT_SCOPE)
!           set(CODE 
!             "
!       subroutine my_sub
!       end subroutine my_sub
!     ")
!           set(worked FALSE)
!           test_fortran_mangling("${CODE}" "${pre}" ${isup}
!             "${post}" "function with _ " my_sub worked )
!           if(worked)
!             set(${extra_under_score} FALSE PARENT_SCOPE)
!           else(worked)
!             test_fortran_mangling("${CODE}" "${pre}" ${isup}
!               "${post}_" "function with _ " my_sub worked )
!             if(worked)
!               set(${extra_under_score} TRUE PARENT_SCOPE)
!             endif(worked)
!           endif(worked)
!         return()
          endif()
        endforeach()
***************
*** 130,134 ****
    if(NOT FORTRAN_C_MANGLING_FOUND)
      # find regular fortran function mangling
!     discover_fortran_mangling(prefix isupper suffix found)
      if(NOT found)
        message(SEND_ERROR "Could not find fortran c name mangling.")
--- 151,155 ----
    if(NOT FORTRAN_C_MANGLING_FOUND)
      # find regular fortran function mangling
!     discover_fortran_mangling(prefix isupper suffix extra_under found)
      if(NOT found)
        message(SEND_ERROR "Could not find fortran c name mangling.")
***************
*** 142,145 ****
--- 163,168 ----
      set(FORTRAN_C_MANGLING_UPPERCASE ${isupper} CACHE INTERNAL 
        "Was fortran to c mangling found" )
+     set(FORTRAN_C_MANGLING_EXTRA_UNDERSCORE ${extra_under} CACHE INTERNAL 
+       "If a function has a _ in the name does the compiler append an extra _" )
      set(FORTRAN_C_MANGLING_FOUND TRUE CACHE INTERNAL 
        "Was fortran to c mangling found" )
***************
*** 175,178 ****
--- 198,204 ----
      else("${f}" MATCHES ":")
        set(function "${FORTRAN_C_PREFIX}${ff}${FORTRAN_C_SUFFIX}")
+       if("${f}" MATCHES "_" AND FORTRAN_C_MANGLING_EXTRA_UNDERSCORE)
+         set(function "${function}_")
+       endif("${f}" MATCHES "_" AND FORTRAN_C_MANGLING_EXTRA_UNDERSCORE)
        set(HEADER_CONTENT "${HEADER_CONTENT}
  #define ${NAMESPACE}${f} ${function}



More information about the Cmake-commits mailing list