Skip to content

Commit

Permalink
Merge pull request #501 from m-a-d-n-e-s-s/500-lapack_libraries-may-c…
Browse files Browse the repository at this point in the history
…ontain-imported-targets-make-sure-they-are-available

resolve `IMPORTED` targets in `LAPACK_LIBRARIES`
  • Loading branch information
evaleev authored Sep 28, 2023
2 parents 15ff74a + 1f307eb commit e4ee892
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmake/madness-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,10 @@ if (@LIBXC_FOUND@)
set(LIBXC_FOUND 1)
endif()

### 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()
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 e4ee892

Please sign in to comment.