|
| 1 | +# @HEADER |
| 2 | +# ************************************************************************ |
| 3 | +# |
| 4 | +# Trilinos: An Object-Oriented Solver Framework |
| 5 | +# Copyright (2001) Sandia Corporation |
| 6 | +# |
| 7 | +# |
| 8 | +# Copyright (2001) Sandia Corporation. Under the terms of Contract |
| 9 | +# DE-AC04-94AL85000, there is a non-exclusive license for use of this |
| 10 | +# work by or on behalf of the U.S. Government. Export of this program |
| 11 | +# may require a license from the United States Government. |
| 12 | +# |
| 13 | +# 1. Redistributions of source code must retain the above copyright |
| 14 | +# notice, this list of conditions and the following disclaimer. |
| 15 | +# |
| 16 | +# 2. Redistributions in binary form must reproduce the above copyright |
| 17 | +# notice, this list of conditions and the following disclaimer in the |
| 18 | +# documentation and/or other materials provided with the distribution. |
| 19 | +# |
| 20 | +# 3. Neither the name of the Corporation nor the names of the |
| 21 | +# contributors may be used to endorse or promote products derived from |
| 22 | +# this software without specific prior written permission. |
| 23 | +# |
| 24 | +# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY |
| 25 | +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 26 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 27 | +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE |
| 28 | +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 29 | +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 30 | +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 31 | +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 32 | +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 33 | +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 34 | +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 35 | +# |
| 36 | +# NOTICE: The United States Government is granted for itself and others |
| 37 | +# acting on its behalf a paid-up, nonexclusive, irrevocable worldwide |
| 38 | +# license in this data to reproduce, prepare derivative works, and |
| 39 | +# perform publicly and display publicly. Beginning five (5) years from |
| 40 | +# July 25, 2001, the United States Government is granted for itself and |
| 41 | +# others acting on its behalf a paid-up, nonexclusive, irrevocable |
| 42 | +# worldwide license in this data to reproduce, prepare derivative works, |
| 43 | +# distribute copies to the public, perform publicly and display |
| 44 | +# publicly, and to permit others to do so. |
| 45 | +# |
| 46 | +# NEITHER THE UNITED STATES GOVERNMENT, NOR THE UNITED STATES DEPARTMENT |
| 47 | +# OF ENERGY, NOR SANDIA CORPORATION, NOR ANY OF THEIR EMPLOYEES, MAKES |
| 48 | +# ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR |
| 49 | +# RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY |
| 50 | +# INFORMATION, APPARATUS, PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS |
| 51 | +# THAT ITS USE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS. |
| 52 | +# |
| 53 | +# ************************************************************************ |
| 54 | +# @HEADER |
| 55 | + |
| 56 | +# Function that defines variables describing the BLAS name mangling convention |
| 57 | +# |
| 58 | +# Sets the following outputs on success: |
| 59 | +# |
| 60 | +# BLAS_FN_CASE |
| 61 | +# "UPPER" if names are translated to upper-case, |
| 62 | +# "LOWER" otherwise. |
| 63 | +# |
| 64 | +# BLAS_FN_UNDERSCORE |
| 65 | +# "NO_UNDER" if nothing is appended, "UNDER" if |
| 66 | +# one underscore is appended, and "SECOND_UNDER" |
| 67 | +# if a function with an underscore has a second |
| 68 | +# appended. |
| 69 | +# |
| 70 | +# BLAS_FUNC_DEFAULT |
| 71 | +# The default mange mangling for Fortran functions |
| 72 | +# that do not contain an underscore. |
| 73 | +# |
| 74 | +# The Fortran 2003 name binding facilities and ISO_C_BINDING module |
| 75 | +# should be preferred over cpp macro trickery whenever possible. |
| 76 | +# |
| 77 | +FUNCTION(BLAS_MANGLING) |
| 78 | + |
| 79 | + IF(NOT DEFINED BLAS_FN_CASE) |
| 80 | + |
| 81 | + IF (Trilinos_VERBOSE_CONFIGURE) |
| 82 | + MESSAGE("BLAS_MANGLING: Testing name Mangling Schemes!\n") |
| 83 | + ENDIF() |
| 84 | + |
| 85 | + FIND_FILE(_blascmakelists blasmangle/ ${CMAKE_MODULE_PATH}) |
| 86 | + IF (NOT _blascmakelists) |
| 87 | + MESSAGE(STATUS "Error, the file blasmangle could not be found so we can not determine Fortran name mangling!") |
| 88 | + RETURN() |
| 89 | + ENDIF() |
| 90 | + |
| 91 | + SET(_fcmangledir ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/blasmangle) |
| 92 | + FILE(MAKE_DIRECTORY ${_fcmangledir}) |
| 93 | + |
| 94 | + FOREACH(cdef LOWER UPPER) |
| 95 | + |
| 96 | + FOREACH(udef UNDER NO_UNDER) |
| 97 | + |
| 98 | + IF (Trilinos_VERBOSE_CONFIGURE) |
| 99 | + MESSAGE("BLAS_MANGLING: Testing ${cdef} ${udef}\n\n") |
| 100 | + ENDIF() |
| 101 | + |
| 102 | + SET(_fcmangledir_case "${_fcmangledir}/${cdef}/${udef}") |
| 103 | + FILE(MAKE_DIRECTORY "${_fcmangledir}/${cdef}") |
| 104 | + FILE(MAKE_DIRECTORY ${_fcmangledir_case}) |
| 105 | + |
| 106 | + TRY_COMPILE(_blasmngl ${_fcmangledir_case} ${_blascmakelists} blasmangle |
| 107 | + CMAKE_FLAGS "-DMANGLE_FLAGS:STRING=-DFC_FN_${cdef};-DFC_FN_${udef}" |
| 108 | + OUTPUT_VARIABLE _blasmngl_output |
| 109 | + ) |
| 110 | + IF (Trilinos_VERBOSE_CONFIGURE) |
| 111 | + MESSAGE("${_blasmngl_output}\n\n") |
| 112 | + ENDIF() |
| 113 | + |
| 114 | + IF(_blasmngl) |
| 115 | + IF (Trilinos_VERBOSE_CONFIGURE) |
| 116 | + MESSAGE("BLAS_MANGLING: Bingo! ${cdef} ${udef} is the correct BLAS name mangling!\n") |
| 117 | + ENDIF() |
| 118 | + SET(BLAS_FN_CASE ${cdef} CACHE INTERNAL |
| 119 | + "Case used by Fortran functions" FORCE) |
| 120 | + SET(BLAS_FN_UNDERSCORE ${udef} CACHE INTERNAL |
| 121 | + "Underscore convention used by Fortran functions" FORCE) |
| 122 | + BREAK() |
| 123 | + ENDIF() |
| 124 | + |
| 125 | + ENDFOREACH() |
| 126 | + |
| 127 | + IF(_blasmngl) |
| 128 | + BREAK() |
| 129 | + ENDIF() |
| 130 | + |
| 131 | + ENDFOREACH() |
| 132 | + |
| 133 | + IF(_blasmngl) |
| 134 | + MESSAGE(STATUS "BLAS name mangling: ${BLAS_FN_CASE} ${BLAS_FN_UNDERSCORE}") |
| 135 | + ELSE() |
| 136 | + MESSAGE(STATUS "Warning, cannot automatically determine BLAS mangling.") |
| 137 | + ENDIF() |
| 138 | + |
| 139 | + ENDIF() |
| 140 | + |
| 141 | + IF (BLAS_FN_CASE STREQUAL LOWER) |
| 142 | + SET(BLAS_NAME_NAME name) |
| 143 | + ELSEIF (BLAS_FN_CASE STREQUAL UPPER) |
| 144 | + SET(BLAS_NAME_NAME NAME) |
| 145 | + ENDIF() |
| 146 | + |
| 147 | + IF (BLAS_FN_UNDERSCORE) |
| 148 | + IF(BLAS_FN_UNDERSCORE STREQUAL "UNDER") |
| 149 | + SET(BLAS_FUNC_DEFAULT "(name,NAME) ${BLAS_NAME_NAME} ## _" CACHE INTERNAL "") |
| 150 | + ELSE() |
| 151 | + SET(BLAS_FUNC_DEFAULT "(name,NAME) ${BLAS_NAME_NAME}" CACHE INTERNAL "") |
| 152 | + ENDIF() |
| 153 | + ENDIF() |
| 154 | + |
| 155 | +ENDFUNCTION() |
0 commit comments