diff --git a/external/lapack.cmake b/external/lapack.cmake index 30306fbbea7..f146a0a4cc3 100644 --- a/external/lapack.cmake +++ b/external/lapack.cmake @@ -117,6 +117,14 @@ if (USER_LAPACK_LIBRARIES) endif(USER_LAPACK_LIBRARIES_IS_ACML) endif(USER_LAPACK_LIBRARIES_IS_MKL) + # LAPACK_LIBRARIES might include imported targets that are not globally available + if (LAPACK_LIBRARIES MATCHES OpenMP::OpenMP_C AND NOT TARGET OpenMP::OpenMP_C) + find_package(OpenMP REQUIRED COMPONENTS C) + endif() + if (LAPACK_LIBRARIES MATCHES Threads::Threads AND NOT TARGET Threads::Threads) + find_package(Threads REQUIRED) + endif() + endif(USER_LAPACK_LIBRARIES) cmake_pop_check_state() diff --git a/src/madness/CMakeLists.txt b/src/madness/CMakeLists.txt index c7142efc970..0e60e5ce8dc 100644 --- a/src/madness/CMakeLists.txt +++ b/src/madness/CMakeLists.txt @@ -94,7 +94,13 @@ if(HAVE_IBMBGQ OR HAVE_IBMBGP) target_link_libraries(madness PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/new_mtxmq/bests/libMADMTXM.a) endif() if (LAPACK_FOUND) - target_link_libraries(madness PUBLIC ${LAPACK_LIBRARIES}) + + # if LAPACK_LIBRARIES includes IMPORTED targets make sure they are available + if (LAPACK_LIBRARIES MATCHES OpenMP::OpenMP_C AND NOT TARGET OpenMP::OpenMP_C) + find_package(OpenMP REQUIRED COMPONENTS C) + endif() + + target_link_libraries(madness PUBLIC ${LAPACK_LIBRARIES}) if (LAPACK_INCLUDE_DIRS) target_include_directories(madness PUBLIC ${LAPACK_INCLUDE_DIRS}) endif(LAPACK_INCLUDE_DIRS)