From 2cd18395fcd4f76c5e67ef82b9d9a73d6e8ca26d Mon Sep 17 00:00:00 2001 From: Brendan Barnes Date: Tue, 23 Jul 2024 00:16:51 -0500 Subject: [PATCH] update MKL cmake --- CMakeLists.txt | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 489244b..fdbc51a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,18 +58,33 @@ function(setup_mkl) find_package(MKL QUIET) if(NOT MKL_FOUND) - # If not found, look for MKL in the default apt installation directory - set(MKLROOT "/usr/include/mkl" CACHE PATH "Root directory of MKL installation") + # Check for MKL in common locations + set(MKL_LOCATIONS + "/usr/include/mkl" + "/opt/intel/oneapi/mkl/latest" + "$ENV{MKLROOT}" + ) - if(NOT EXISTS ${MKLROOT}) + foreach(location ${MKL_LOCATIONS}) + if(EXISTS "${location}") + set(MKLROOT "${location}" CACHE PATH "Root directory of MKL installation" FORCE) + break() + endif() + endforeach() + + if(NOT MKLROOT) message(FATAL_ERROR "MKL not found. Please specify the correct MKLROOT.") endif() # Set include directories - target_include_directories(SQUINT INTERFACE ${MKLROOT}) + target_include_directories(SQUINT INTERFACE ${MKLROOT}/include) # Set library directories - target_link_directories(SQUINT INTERFACE /usr/lib/x86_64-linux-gnu) + if(EXISTS "${MKLROOT}/lib/intel64") + target_link_directories(SQUINT INTERFACE ${MKLROOT}/lib/intel64) + else() + target_link_directories(SQUINT INTERFACE /usr/lib/x86_64-linux-gnu) + endif() # Link against MKL libraries target_link_libraries(SQUINT INTERFACE @@ -81,6 +96,9 @@ function(setup_mkl) # Add compile definition for MKL target_compile_definitions(SQUINT INTERFACE BLAS_BACKEND_MKL) + + # Set MKLROOT in the parent scope + set(MKLROOT ${MKLROOT} PARENT_SCOPE) endfunction() # Option to control building tests