Skip to content

Commit

Permalink
Merge branch 'develop' into cmakebuildext
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored May 16, 2024
2 parents 688c0e4 + 59256b4 commit ef19171
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
51 changes: 34 additions & 17 deletions cmake/AmiciFindBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,33 @@ 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()
message(STATUS "Trying FindBLAS with BLA_VENDOR=${BLA_VENDOR}")
find_package(BLAS)
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 "")
Expand All @@ -42,6 +57,7 @@ elseif(

if(APPLE AND (NOT DEFINED BLA_VENDOR OR BLA_VENDOR STREQUAL "All"))
set(BLA_VENDOR Apple)
message(STATUS "Trying FindBLAS with BLA_VENDOR=${BLA_VENDOR}")
find_package(BLAS)
if(BLAS_FOUND)
message(STATUS "Found Apple Accelerate BLAS")
Expand All @@ -59,6 +75,7 @@ elseif(

endif()
if(NOT BLAS_FOUND)
message(STATUS "Trying FindBLAS with BLA_VENDOR=${BLA_VENDOR}")
find_package(BLAS)
if(BLAS_FOUND)
message(STATUS "Found BLAS via FindBLAS")
Expand All @@ -79,17 +96,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:
Expand Down
2 changes: 2 additions & 0 deletions cmake/cmakelang-tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ set(ALL_CMAKE_FILES
tests/cpp/unittests/CMakeLists.txt
${CMAKE_MODULE_PATH}/cmakelang-tools.cmake
${CMAKE_MODULE_PATH}/clang-tools.cmake
${CMAKE_MODULE_PATH}/AmiciFindBLAS.cmake
${CMAKE_MODULE_PATH}/version.cmake)

list(JOIN ALL_CMAKE_FILES " " ALL_CMAKE_FILES)

# --- cmake-format ---
Expand Down

0 comments on commit ef19171

Please sign in to comment.