diff --git a/CMakeLists.txt b/CMakeLists.txt index afa2e5adb2..205d8a9759 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,19 +53,29 @@ option(DLAF_BUILD_DOC "Build documentation" OFF) option(DLAF_WITH_PRECOMPILED_HEADERS "Use precompiled headers." OFF) option(DLAF_WITH_SCALAPACK "Build ScaLAPACK-like C API (requires ScaLAPACK)" OFF) -unset(DLAF_WITH_MKL_TRY_COMPILE CACHE) -try_compile( - DLAF_WITH_MKL_TRY_COMPILE "${PROJECT_BINARY_DIR}/cmake/tests" - "${PROJECT_SOURCE_DIR}/cmake/tests/mkl_set_num_threads.cpp" - CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${LAPACK_INCLUDE_DIR}" - LINK_LIBRARIES ${LAPACK_LIBRARY} -) -if(DLAF_WITH_MKL_TRY_COMPILE) - message(STATUS "Intel MKL detection: Found") +option(DLAF_WITH_MKL "Enable MKL as provider for BLAS and LAPACK" "${DLAF_WITH_MKL_TRY_COMPILE}") +if(DEFINED CACHE{DLAF_WITH_MKL}) + if(DLAF_WITH_MKL) + message(STATUS "Intel MKL support: Enabled by user") + else() + message(STATUS "Intel MKL support: Disabled by user") + endif() + set(DLAF_WITH_MKL_INTERNAL ${DLAF_WITH_MKL} CACHE BOOL "" FORCE) else() - message(STATUS "Intel MKL detection: Not found") + unset(DLAF_WITH_MKL_TRY_COMPILE CACHE) + try_compile( + DLAF_WITH_MKL_TRY_COMPILE "${PROJECT_BINARY_DIR}/cmake/tests" + "${PROJECT_SOURCE_DIR}/cmake/tests/mkl_set_num_threads.cpp" + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${LAPACK_INCLUDE_DIR}" + LINK_LIBRARIES ${LAPACK_LIBRARY} + ) + if(DLAF_WITH_MKL_TRY_COMPILE) + message(STATUS "Intel MKL support: Found") + else() + message(STATUS "Intel MKL support: Not found") + endif() + set(DLAF_WITH_MKL_INTERNAL ${DLAF_WITH_MKL_TRY_COMPILE} CACHE BOOL "" FORCE) endif() -option(DLAF_WITH_MKL "Enable MKL as provider for BLAS and LAPACK" "${DLAF_WITH_MKL_TRY_COMPILE}") if(DLAF_WITH_MKL) # When using MKL there is no need to set the number of threads with diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 708175a9d0..4af59a4e25 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,7 +103,7 @@ target_compile_definitions( $<$:DLAF_ASSERT_MODERATE_ENABLE> $<$:DLAF_ASSERT_HEAVY_ENABLE> DLAF_FUNCTION_NAME=$,__PRETTY_FUNCTION__,__func__> - $<$:DLAF_WITH_MKL> + $<$:DLAF_WITH_MKL> $<$:DLAF_WITH_OPENMP> $<$:DLAF_WITH_GPU> $<$:DLAF_WITH_CUDA>