-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake: Fix MKL detection when not using environment modules #2443
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,18 +12,32 @@ set_property(CACHE BLAS PROPERTY STRINGS "CBLAS" "MKL" "ACCELERATE") | |
|
||
if(${BLAS} STREQUAL "MKL" OR DEFINED ENV{MKLROOT}) | ||
if(DEFINED ENV{MKLROOT}) | ||
# This is set by Environment Modules | ||
message(STATUS "Using MKL_INCDIR and MKL_LIB from environment module") | ||
set(BLAS | ||
"MKL" | ||
CACHE STRING "BLAS library to use" FORCE) | ||
set(BLAS_INCLUDE_DIRS | ||
"$ENV{MKL_INCDIR}" | ||
CACHE STRING "" FORCE) | ||
set(BLAS_LIBRARIES | ||
"$ENV{MKL_LIB}" | ||
CACHE STRING "" FORCE) | ||
|
||
# Was MKLROOT set by /opt/intel/oneapi/setvars.sh? then cmake will find it | ||
message(STATUS "Trying to find BLAS based on MKLROOT=$ENV{MKLROOT}") | ||
# give the user the option to override the BLA_VENDOR | ||
if(NOT DEFINED BLA_VENDOR) | ||
set(BLA_VENDOR Intel10_64lp) | ||
endif() | ||
find_package(BLAS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really only going to work if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, missed the |
||
if(BLAS_FOUND) | ||
message(STATUS "Found BLAS via FindBLAS and MKLROOT") | ||
else() | ||
# This is set by Environment Modules and might not be compatible with | ||
# FindBLAS | ||
message(STATUS "Using MKL_INCDIR and MKL_LIB from environment module") | ||
set(BLAS_INCLUDE_DIRS | ||
"$ENV{MKL_INCDIR}" | ||
CACHE STRING "" FORCE) | ||
set(BLAS_LIBRARIES | ||
"$ENV{MKL_LIB}" | ||
CACHE STRING "" FORCE) | ||
endif() | ||
else() | ||
message(STATUS "BLAS is set to MKL, but MKLROOT is not set.") | ||
set(BLAS_INCLUDE_DIRS | ||
"" | ||
CACHE STRING "") | ||
|
@@ -79,17 +93,17 @@ endif() | |
# Create an imported target | ||
if(NOT TARGET BLAS::BLAS) | ||
add_library(BLAS INTERFACE) | ||
set_target_properties(BLAS PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${BLAS_INCLUDE_DIRS}" | ||
INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}") | ||
set_target_properties( | ||
BLAS PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${BLAS_INCLUDE_DIRS}" | ||
INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}") | ||
add_library(BLAS::BLAS ALIAS BLAS) | ||
if("${PROJECT_NAME}" STREQUAL "amici") | ||
install(TARGETS BLAS EXPORT BLAS) | ||
export(EXPORT BLAS NAMESPACE BLAS::) | ||
install( | ||
EXPORT BLAS | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Amici" | ||
NAMESPACE BLAS::) | ||
install(TARGETS BLAS EXPORT BLAS) | ||
export(EXPORT BLAS NAMESPACE BLAS::) | ||
install( | ||
EXPORT BLAS | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Amici" | ||
NAMESPACE BLAS::) | ||
endif() | ||
|
||
# legacy python package environment variables: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add message about assumed default here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default is that BLA_VENDOR is undefined and that any BLAS is accepted.
I add a message with the current value.