diff --git a/SuiteSparse_config/cmake_modules/SuiteSparseBLAS.cmake b/SuiteSparse_config/cmake_modules/SuiteSparseBLAS.cmake index 9093426ccc..ff665e97f6 100644 --- a/SuiteSparse_config/cmake_modules/SuiteSparseBLAS.cmake +++ b/SuiteSparse_config/cmake_modules/SuiteSparseBLAS.cmake @@ -23,6 +23,38 @@ if ( NOT DEFINED ALLOW_64BIT_BLAS ) set ( ALLOW_64BIT_BLAS false ) endif ( ) +#------------------------------------------------------------------------------- +# look for a specific BLAS library +#------------------------------------------------------------------------------- + +# To request specific BLAS, use either (for example): +# +# CMAKE_OPTIONS="-DBLA_VENDOR=Apple" make +# cd build ; cmake -DBLA_VENDOR=Apple .. ; make +# +# Note that the ALLOW_64BIT_BLAS flag is ignored in this case. If you want +# to select a specific BLAS integer size, use -DBLA_SIZEOF_INTEGER=64 or 32. + +if ( DEFINED BLA_VENDOR ) + # only look for the BLAS from a single vendor + message ( STATUS "============================================" ) + message ( STATUS "Looking for BLAS: " ${BLA_VENDOR} ) + if ( NOT DEFINED BLA_SIZEOF_INTEGER ) + message ( FATAL_ERROR "Both BLA_VENDOR and BLA_SIZEOF_INTEGER must be specified" ) + endif ( ) + # only look for the BLAS with a specific integer size + find_package ( BLAS REQUIRED ) + find_package ( LAPACK REQUIRED ) + if ( BLA_SIZEOF_INTEGER EQUAL 8 ) + include ( SuiteSparseBLAS64 ) + elseif ( BLA_SIZEOF_INTEGER EQUAL 4 ) + include ( SuiteSparseBLAS32 ) + else ( ) + message ( FATAL_ERROR "BLA_SIZEOF_INTEGER invalid (must be 4 or 8)" ) + endif ( ) + return ( ) +endif ( ) + #------------------------------------------------------------------------------- # these blocks of code can be rearranged to change the search order for the BLAS #------------------------------------------------------------------------------- @@ -35,7 +67,6 @@ if ( ALLOW_64BIT_BLAS ) find_package ( BLAS ) find_package ( LAPACK ) if ( BLAS_FOUND AND LAPACK_FOUND ) - add_compile_definitions ( BLAS_INTEL_64ILP ) include ( SuiteSparseBLAS64 ) return ( ) endif ( ) @@ -48,7 +79,6 @@ set ( BLA_SIZEOF_INTEGER 4 ) find_package ( BLAS ) find_package ( LAPACK ) if ( BLAS_FOUND AND LAPACK_FOUND ) - add_compile_definitions ( BLAS_INTEL_64LP ) include ( SuiteSparseBLAS32 ) return ( ) endif ( ) @@ -60,7 +90,6 @@ set ( BLA_SIZEOF_INTEGER 4 ) find_package ( BLAS ) find_package ( LAPACK ) if ( BLAS_FOUND AND LAPACK_FOUND ) - add_compile_definitions ( BLAS_APPLE ) include ( SuiteSparseBLAS32 ) return ( ) endif ( ) @@ -73,7 +102,6 @@ if ( ALLOW_64BIT_BLAS ) find_package ( BLAS ) find_package ( LAPACK ) if ( BLAS_FOUND AND LAPACK_FOUND ) - add_compile_definitions ( BLAS_ARM_MP ) include ( SuiteSparseBLAS64 ) return ( ) endif ( ) @@ -86,7 +114,6 @@ set ( BLA_SIZEOF_INTEGER 4 ) find_package ( BLAS ) find_package ( LAPACK ) if ( BLAS_FOUND AND LAPACK_FOUND ) - add_compile_definitions ( BLAS_ARM_ILP64_MP ) include ( SuiteSparseBLAS32 ) return ( ) endif ( ) @@ -99,7 +126,6 @@ if ( ALLOW_64BIT_BLAS ) find_package ( BLAS ) find_package ( LAPACK ) if ( BLAS_FOUND AND LAPACK_FOUND ) - add_compile_definitions ( BLAS_IBMESSL_SMP_64 ) include ( SuiteSparseBLAS64 ) return ( ) endif ( ) @@ -112,7 +138,6 @@ set ( BLA_SIZEOF_INTEGER 4 ) find_package ( BLAS ) find_package ( LAPACK ) if ( BLAS_FOUND AND LAPACK_FOUND ) - add_compile_definitions ( BLAS_IBMESSL_SMP_32 ) include ( SuiteSparseBLAS32 ) return ( ) endif ( ) @@ -125,7 +150,6 @@ if ( ALLOW_64BIT_BLAS ) find_package ( BLAS ) find_package ( LAPACK ) if ( BLAS_FOUND AND LAPACK_FOUND ) - add_compile_definitions ( BLAS_OPENBLAS_64 ) include ( SuiteSparseBLAS64 ) return ( ) endif ( ) @@ -138,7 +162,6 @@ set ( BLA_SIZEOF_INTEGER 4 ) find_package ( BLAS ) find_package ( LAPACK ) if ( BLAS_FOUND AND LAPACK_FOUND ) - add_compile_definitions ( BLAS_OPENBLAS ) include ( SuiteSparseBLAS32 ) return ( ) endif ( ) diff --git a/SuiteSparse_config/cmake_modules/SuiteSparseBLAS32.cmake b/SuiteSparse_config/cmake_modules/SuiteSparseBLAS32.cmake index d746070ae8..71b3e04001 100644 --- a/SuiteSparse_config/cmake_modules/SuiteSparseBLAS32.cmake +++ b/SuiteSparse_config/cmake_modules/SuiteSparseBLAS32.cmake @@ -10,6 +10,7 @@ # actions taken when a 32-bit BLAS has been found -message ( STATUS "Found 32-bit BLAS+LAPACK" ) +message ( STATUS "Found ${BLA_VENDOR} 32-bit BLAS+LAPACK" ) +add_compile_definitions ( BLAS_${BLA_VENDOR} ) set ( SuiteSparse_BLAS_integer "int32_t" ) diff --git a/SuiteSparse_config/cmake_modules/SuiteSparseBLAS64.cmake b/SuiteSparse_config/cmake_modules/SuiteSparseBLAS64.cmake index f5710f6bcf..eefab62c0f 100644 --- a/SuiteSparse_config/cmake_modules/SuiteSparseBLAS64.cmake +++ b/SuiteSparse_config/cmake_modules/SuiteSparseBLAS64.cmake @@ -10,7 +10,8 @@ # actions taken when a 64-bit BLAS has been found -message ( STATUS "Found 64-bit BLAS+LAPACK" ) +message ( STATUS "Found ${BLA_VENDOR} 64-bit BLAS+LAPACK" ) +add_compile_definitions ( BLAS_${BLA_VENDOR} ) add_compile_definitions ( BLAS64 ) set ( SuiteSparse_BLAS_integer "int64_t" )