Skip to content

Commit

Permalink
simpler way to force a BLAS underscore, or force no underscore
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTimothyAldenDavis committed Feb 19, 2024
1 parent 680794f commit 4f45fc4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
13 changes: 9 additions & 4 deletions SuiteSparse_config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}

include ( SuiteSparsePolicy )

if ( SUITESPARSE_HAS_FORTRAN )
include ( FortranCInterface )
else ( )
# No Fortran compiler available or enabled, configuration is not automatic.
if ( ( NOT SUITESPARSE_HAS_FORTRAN ) OR SUITESPARSE_BLAS_UNDERSCORE OR SUITESPARSE_BLAS_NO_UNDERSCORE )
# No Fortran compiler available or enabled, or either of the
# SUITESPARSE_BLAS_UNDERSCORE or SUITESPARSE_BLAS_NO_UNDERSCORE are set ON:
# configuration is not automatic.
set ( FortranCInterface_GLOBAL_MACRO ${SUITESPARSE_C_TO_FORTRAN} )
set ( FortranCInterface_GLOBAL__MACRO ${SUITESPARSE_C_TO_FORTRAN} )
else ( )
# A Fortran compiler is available and enabled, and both
# SUITESPARSE_BLAS_UNDERSCORE and SUITESPARSE_BLAS_NO_UNDERSCORE are set to
# their default values (OFF): configure the BLAS automatically.
include ( FortranCInterface )
endif ( )

message ( STATUS "C to Fortran calling protocol: ")
Expand Down
37 changes: 35 additions & 2 deletions SuiteSparse_config/cmake_modules/SuiteSparsePolicy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@
# for your system.
# Default: ON
#
# SUITESPARSE_BLAS_UNDERSCORE: if ON, the SUITESPARSE_C_TO_FORTRAN setting
# is ignored, and the Fortran compiler is also ignored
# even if available and used. The C-to-Fortran
# convention "(name,NAME) name##_" is used, which forces
# the appending of an underscore to the names of the
# BLAS/LAPACK functions (dgemm_ for example).
# Default: OFF
#
# SUITESPARSE_BLAS_NO_UNDERSCORE: if ON and SUITESPARSE_BLAS_UNDERSCORE is
# OFF, the SUITESPARSE_C_TO_FORTRAN setting is ignored,
# and the Fortran compiler is also ignored even if
# available and used. The C-to-Fortran convention
# "(name,NAME) name" is used, which forces NO appending of an
# underscore to the names of the BLAS/LAPACK functions.
# (dgemm for example). Note that if
# SUITESPARSE_BLAS_UNDERSCORE is set to ON, this setting
# is ignored.
# Default: OFF
#
# SUITESPARSE_PKGFILEDIR: Directory where CMake Config and pkg-config files
# will be installed. By default, CMake Config files will
# be installed in the subfolder `cmake` of the directory
Expand Down Expand Up @@ -297,8 +316,22 @@ if ( SUITESPARSE_USE_STRICT AND SUITESPARSE_USE_FORTRAN AND NOT SUITESPARSE_HAS_
message ( FATAL_ERROR "Fortran required for SuiteSparse but not found" )
endif ( )

# default C-to-Fortran name mangling if Fortran compiler not found
if ( MSVC )
# C-to-Fortran name mangling
option ( SUITESPARSE_BLAS_UNDERSCORE "OFF (default): do not force an underscore; ON: ignore Fortran and force calls to BLAS to use a trailing underscore (dgemm_)" OFF )
option ( SUITESPARSE_BLAS_NO_UNDERSCORE "OFF (default): do not force no-underscore; ON: ignore Fortran and force calls to BLAS to NOT use a trailing underscore (dgemm)" OFF )
if ( SUITESPARSE_BLAS_UNDERSCORE )
# Ignore the Fortran compiler even if used, also ignore the C compiler, and
# force an underscore to be appended to all calls to BLAS/LAPACK.
# Also force the name to be lowercase (dgemm_ for example).
set ( SUITESPARSE_C_TO_FORTRAN "(name,NAME) name##_"
CACHE STRING "C to Fortan name mangling" FORCE )
elseif ( SUITESPARSE_BLAS_NO_UNDERSCORE )
# Ignore the Fortran compiler even if used, also ignore the C compiler, and
# force NO underscore to be appended to all calls to BLAS/LAPACK.
# Also force the name to be lowercase (dgemm for example).
set ( SUITESPARSE_C_TO_FORTRAN "(name,NAME) name"
CACHE STRING "C to Fortan name mangling" FORCE )
elseif ( MSVC )
# MS Visual Studio Fortran compiler does not mangle the Fortran name
set ( SUITESPARSE_C_TO_FORTRAN "(name,NAME) name"
CACHE STRING "C to Fortan name mangling" )
Expand Down

0 comments on commit 4f45fc4

Please sign in to comment.