Skip to content

cmake: Ensure linked MKL libraries are consistent with octopus build options.

As discussed and settled in issue #1137, we want serial builds of Octopus to link to sequential libraries.

Ensure Octopus links to MKL libraries that are consistent with the Octopus build options. For dynamic linking (MKL_LINK dynamic), this can be controlled by setting MKL_MPI and MKL_THREADING, rather explicitly linking to the desired components:

target_link_libraries(Octopus_lib PRIVATE
   MKL::mkl_core
   MKL::mkl_intel_${MKL_INTERFACE})

if (OCTOPUS_MPI)
target_link_libraries(Octopus_lib PRIVATE
   MKL::mkl_scalapack_${MKL_INTERFACE}
   MKL::mkl_blacs_${MKL_MPI}_${MKL_INTERFACE})
endif ()

if (OCTOPUS_OpenMP)
   target_link_libraries(Octopus_lib PRIVATE MKL::mkl_intel_thread)
else ()
   target_link_libraries(Octopus_lib PRIVATE MKL::mkl_sequential)
endif ()

This closes issue #1193 (closed), and it might as well close issue #1137 as this discussion was settled.

One can verify the variables returned from find_package(MKL CONFIG) with:

get_cmake_property(all_vars VARIABLES)

foreach(var IN LISTS all_vars)
   if(var MATCHES "^MKL")
     message(STATUS "MKL variable: ${var} = ${${var}}")
   endif()
endforeach()
Edited by Alex Buccheri

Merge request reports

Loading