Skip to content

Commit 4403a6f

Browse files
committed
Fix Linux MKL build 2
1 parent a1a3550 commit 4403a6f

File tree

1 file changed

+18
-54
lines changed

1 file changed

+18
-54
lines changed

dynadjust/CMakeLists.txt

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -348,68 +348,32 @@ else()
348348
# Use Intel MKL's native CMake config
349349
add_compile_options("-DUSE_MKL")
350350

351-
# Set MKL interface based on ILP64 option
351+
# Use FindBLAS to locate Intel MKL with explicit interface selection
352+
# Note: MKLConfig.cmake in OneAPI 2025.x has issues with interface selection,
353+
# so we use FindBLAS which allows explicit LP64/ILP64 selection via BLA_VENDOR
354+
message(STATUS "Using FindBLAS with BLA_VENDOR set to Intel MKL")
355+
352356
if(ILP64)
353-
set(MKL_INTERFACE "ilp64" CACHE STRING "MKL interface layer")
357+
set(BLA_VENDOR "Intel10_64ilp")
354358
else()
355-
set(MKL_INTERFACE "lp64" CACHE STRING "MKL interface layer")
359+
set(BLA_VENDOR "Intel10_64lp")
356360
endif()
357361

358-
# Set MKL threading (required for proper configuration)
359-
if(NOT DEFINED MKL_THREADING)
360-
set(MKL_THREADING "gnu_thread" CACHE STRING "MKL threading layer")
361-
endif()
362+
find_package(BLAS MODULE REQUIRED)
363+
find_package(LAPACK MODULE)
362364

363-
# Set MKL link type
364-
if(NOT DEFINED MKL_LINK)
365-
set(MKL_LINK "dynamic" CACHE STRING "MKL link type")
365+
# Verify we actually got MKL
366+
if(NOT "${BLAS_LIBRARIES}" MATCHES "mkl")
367+
message(FATAL_ERROR "USE_MKL=ON but Intel MKL was not found. Found: ${BLAS_LIBRARIES}")
366368
endif()
367369

368-
# Find MKL using its CMake config
369-
find_package(MKL CONFIG)
370-
371-
if(MKL_FOUND)
372-
message(STATUS "Found Intel MKL using MKLConfig.cmake")
373-
message(STATUS " MKL Version: ${MKL_VERSION}")
374-
message(STATUS " MKL Interface: ${MKL_INTERFACE}")
375-
message(STATUS " MKL Threading: ${MKL_THREADING}")
376-
message(STATUS " MKL Link: ${MKL_LINK}")
377-
378-
# Explicitly ensure we're not using ILP64 when in LP64 mode
379-
if(NOT ILP64)
380-
# Remove any MKL_ILP64 definition that might have been set
381-
remove_definitions(-DMKL_ILP64)
382-
add_compile_definitions(MKL_LP64)
383-
endif()
384-
385-
# Use the modern MKL target
386-
list(APPEND DNA_LIBRARIES MKL::MKL)
387-
else()
388-
# MKL CONFIG not found, try with FindBLAS
389-
message(STATUS "MKLConfig.cmake not found, trying FindBLAS with BLA_VENDOR set to Intel MKL")
390-
391-
if(ILP64)
392-
set(BLA_VENDOR "Intel10_64ilp")
393-
else()
394-
set(BLA_VENDOR "Intel10_64lp")
395-
endif()
396-
397-
find_package(BLAS MODULE REQUIRED)
398-
find_package(LAPACK MODULE)
399-
400-
# Verify we actually got MKL
401-
if(NOT "${BLAS_LIBRARIES}" MATCHES "mkl")
402-
message(FATAL_ERROR "USE_MKL=ON but Intel MKL was not found. Found: ${BLAS_LIBRARIES}")
403-
endif()
404-
405-
message(STATUS "Found Intel MKL via FindBLAS: ${BLAS_LIBRARIES}")
406-
list(APPEND DNA_LIBRARIES ${BLAS_LIBRARIES})
407-
if(LAPACK_FOUND)
408-
list(APPEND DNA_LIBRARIES ${LAPACK_LIBRARIES})
409-
endif()
410-
411-
# MKL provides mkl_cblas.h, not cblas.h - no need to search for cblas.h
370+
message(STATUS "Found Intel MKL via FindBLAS: ${BLAS_LIBRARIES}")
371+
list(APPEND DNA_LIBRARIES ${BLAS_LIBRARIES})
372+
if(LAPACK_FOUND)
373+
list(APPEND DNA_LIBRARIES ${LAPACK_LIBRARIES})
412374
endif()
375+
376+
# MKL provides mkl_cblas.h, not cblas.h - no need to search for cblas.h
413377

414378
else()
415379
# Use standard BLAS and LAPACK search

0 commit comments

Comments
 (0)