Skip to content

Commit

Permalink
[cmake] if LAPACK_LIBRARIES includes IMPORTED targets make sure they …
Browse files Browse the repository at this point in the history
…are available
  • Loading branch information
evaleev committed Sep 28, 2023
1 parent 03ad53b commit ee7bfa4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions external/lapack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 7 additions & 1 deletion src/madness/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ee7bfa4

Please sign in to comment.