diff --git a/SuiteSparse_config/CMakeLists.txt b/SuiteSparse_config/CMakeLists.txt index 7c06afcb5..314331a2a 100644 --- a/SuiteSparse_config/CMakeLists.txt +++ b/SuiteSparse_config/CMakeLists.txt @@ -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: ") diff --git a/SuiteSparse_config/cmake_modules/SuiteSparsePolicy.cmake b/SuiteSparse_config/cmake_modules/SuiteSparsePolicy.cmake index b6b195407..51d63eada 100644 --- a/SuiteSparse_config/cmake_modules/SuiteSparsePolicy.cmake +++ b/SuiteSparse_config/cmake_modules/SuiteSparsePolicy.cmake @@ -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 @@ -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" )