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 1f307eb
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

1 comment on commit 1f307eb

@barracuda156
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evaleev Looks like this has broken finding BLAS/LAPACK on macOS with Clang:

  -- Found Gperftools: /opt/local/lib/libtcmalloc.dylib;/opt/local/lib/libprofiler.dylib  found components: tcmalloc profiler 
  CMake Warning at /opt/local/share/cmake-3.24/Modules/FindBoost.cmake:1384 (message):
    New Boost version may have incorrect or missing dependencies and imported
    targets
  Call Stack (most recent call first):
    /opt/local/share/cmake-3.24/Modules/FindBoost.cmake:1507 (_Boost_COMPONENT_DEPENDENCIES)
    /opt/local/share/cmake-3.24/Modules/FindBoost.cmake:2118 (_Boost_MISSING_DEPENDENCIES)
    external/boost.cmake:3 (find_package)
    CMakeLists.txt:641 (include)
  
  
  -- Found Boost: /opt/local/libexec/boost/1.81/include (found suitable version "1.81.0", minimum required is "1.4") found components: math_tr1 
  -- Looking for sgemm_
  -- Looking for sgemm_ - not found
  -- Looking for sgemm_
  -- Looking for sgemm_ - not found
  -- Looking for sgemm_
  -- Looking for sgemm_ - not found
  -- Looking for sgemm
  -- Looking for sgemm - not found
  -- Looking for sgemm
  -- Looking for sgemm - not found
  -- Looking for sgemm
  -- Looking for sgemm - not found
  -- Looking for sgemm__
  -- Looking for sgemm__ - not found
  -- Looking for sgemm__
  -- Looking for sgemm__ - not found
  -- Looking for sgemm__
  -- Looking for sgemm__ - not found
  -- Looking for SGEMM
  -- Looking for SGEMM - not found
  -- Looking for SGEMM
  -- Looking for SGEMM - not found
  -- Looking for SGEMM
  -- Looking for SGEMM - not found
  -- Looking for SGEMM_
  -- Looking for SGEMM_ - not found
  -- Looking for SGEMM_
  -- Looking for SGEMM_ - not found
  -- Looking for SGEMM_
  -- Looking for SGEMM_ - not found
  CMake Error at external/lapack.cmake:83 (message):
    Unable to link against BLAS function.  Specify the BLAS library in
    LAPACK_LIBRARIES.
  Call Stack (most recent call first):
    CMakeLists.txt:643 (include)
  
  
  -- Configuring incomplete, errors occurred!

Everything was working earlier.

Please sign in to comment.