diff --git a/FindLAPACK.cmake b/FindLAPACK.cmake index 3fe8a0a..aa7a4a1 100644 --- a/FindLAPACK.cmake +++ b/FindLAPACK.cmake @@ -16,6 +16,14 @@ if( "ilp64" IN_LIST LAPACK_FIND_COMPONENTS AND "lp64" IN_LIST LAPACK_FIND_COMPON message( FATAL_ERROR "LAPACK cannot link to both ILP64 and LP64 interfaces" ) endif() +# List of functions to check for valid LAPACK - overridable +if( NOT LAPACK_TEST_FUNCTIONS ) + # use dpstrf to check for full LAPACK API ... some implementations are incomplete (e.g. older OpenBLAS) + # also need to handle several corner cases: + # - OpenBLAS needs libgfortran only for some functions, dpstrf is not one of them, so check for dgesvd + set( LAPACK_TEST_FUNCTIONS "dpstrf;dgesvd" ) +endif() + # Get list of required / optional components foreach( _comp ${LAPACK_FIND_COMPONENTS} ) @@ -50,10 +58,8 @@ if( NOT LAPACK_LIBRARIES ) set( LAPACK_INCLUDE_DIRS ${BLAS_INCLUDE_DIRS} ) set( LAPACK_COMPILE_DEFINITIONS ${BLAS_COMPILE_DEFINITIONS} ) - # use dpstrf to check for full LAPACK API ... some implementations are incomplete (e.g. older OpenBLAS) - # also need to handle several corner cases: - # - OpenBLAS needs libgfortran only for some functions, dpstrf is not one of them, so check for dgesvd - check_fortran_functions_exist( "dpstrf;dgesvd" LAPACK LAPACK_LIBRARIES + # Check for required LAPACK functions + check_fortran_functions_exist( "${LAPACK_TEST_FUNCTIONS}" LAPACK LAPACK_LIBRARIES BLAS_HAS_LAPACK LAPACK_Fortran_LOWER LAPACK_Fortran_UNDERSCORE ) @@ -123,8 +129,8 @@ endif() if( BLAS_HAS_LAPACK ) set( LAPACK_LINK_OK TRUE ) else() - # see notes above the first invocation of check_fortran_functions_exist - check_fortran_functions_exist( "dpstrf;dgesvd" LAPACK LAPACK_LIBRARIES + # Check for required LAPACK functions + check_fortran_functions_exist( "${LAPACK_TEST_FUNCTIONS}" LAPACK LAPACK_LIBRARIES LAPACK_LINK_OK LAPACK_Fortran_LOWER LAPACK_Fortran_UNDERSCORE ) endif() diff --git a/FindOpenBLAS.cmake b/FindOpenBLAS.cmake index c4e3c4b..881f635 100644 --- a/FindOpenBLAS.cmake +++ b/FindOpenBLAS.cmake @@ -18,18 +18,18 @@ find_library( OpenBLAS_LIBRARIES ) find_path( OpenBLAS_INCLUDE_DIR - NAMES openblas_config.h + NAMES openblas/openblas_config.h openblas_config.h HINTS ${OpenBLAS_PREFIX} PATHS ${OpenBLAS_INCLUDE_DIR} PATH_SUFFIXES include DOC "OpenBLAS header" ) -#if( OpenBLAS_LIBRARY AND OpenBLAS_PREFERS_STATIC ) -# include( CMakeFindDependency ) -# find_package( Threads QUIET ) -# set( OpenBLAS_LIBRARIES ${OpenBLAS_LIBRARY} Threads::Threads "m") -#endif() +if( OpenBLAS_LIBRARY AND OpenBLAS_PREFERS_STATIC ) + include( CMakeFindDependency ) + find_package( Threads QUIET ) + set( OpenBLAS_LIBRARIES ${OpenBLAS_LIBRARY} Threads::Threads "m") +endif() # check ILP64 if( OpenBLAS_INCLUDE_DIR ) @@ -42,6 +42,8 @@ if( OpenBLAS_INCLUDE_DIR ) COMPILE_OUTPUT_VARIABLE _openblas_idx_compile_output RUN_OUTPUT_VARIABLE _openblas_idx_run_output ) + message( STATUS ${_openblas_idx_compile_output} ) + message( STATUS ${_openblas_idx_run_output} ) if( ${OpenBLAS_USES_LP64} EQUAL 0 ) set( OpenBLAS_USES_LP64 TRUE ) @@ -67,12 +69,12 @@ find_package_handle_standard_args( OpenBLAS HANDLE_COMPONENTS ) -#if( OpenBLAS_FOUND AND NOT TARGET OpenBLAS::OpenBLAS ) -# -# add_library( OpenBLAS::OpenBLAS INTERFACE IMPORTED ) -# set_target_properties( OpenBLAS::OpenBLAS PROPERTIES -# INTERFACE_INCLUDE_DIRECTORIES "${OpenBLAS_INCLUDE_DIR}" -# INTERFACE_LINK_LIBRARIES "${OpenBLAS_LIBRARIES}" -# ) -# -#endif() +if( OpenBLAS_FOUND AND NOT TARGET OpenBLAS::OpenBLAS ) + + add_library( OpenBLAS::OpenBLAS INTERFACE IMPORTED ) + set_target_properties( OpenBLAS::OpenBLAS PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OpenBLAS_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${OpenBLAS_LIBRARIES}" + ) + +endif() diff --git a/util/openblas_int_size.c b/util/openblas_int_size.c index 517cf66..3085e75 100644 --- a/util/openblas_int_size.c +++ b/util/openblas_int_size.c @@ -1,6 +1,10 @@ +#if __has_include() #include +#else +#include +#endif -int main() { +int main(int argc, char** argv) { int blis_int_size = sizeof(blasint)*8; if( blis_int_size == 32 ) return 0; else return 1;