Toolchain: Add Eigen3 and Remove FindLibint2.cmake (#5427)

This commit is contained in:
SY Wang 2026-06-24 03:49:03 +08:00 committed by GitHub
parent 2894a3be3d
commit 5fdc47cff4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 214 additions and 128 deletions

View file

@ -828,10 +828,21 @@ endif()
# Libint
if(CP2K_USE_LIBINT2)
find_package(Libint2 REQUIRED)
# Prefer the headers and Fortran module that match the selected libint
# library. System include paths can otherwise shadow a locally built libint.
include_directories(BEFORE ${CP2K_LIBINT2_INCLUDE_DIRS})
find_package(Libint2 CONFIG REQUIRED)
# Check Fortran interface
get_target_property(_libint2_include_dirs Libint2::int2
INTERFACE_INCLUDE_DIRECTORIES)
find_file(
CP2K_LIBINT2_MOD_FILE
NAMES libint_f.mod
PATHS ${_libint2_include_dirs} "/usr/lib64/gfortran/modules"
NO_DEFAULT_PATH)
if(NOT CP2K_LIBINT2_MOD_FILE)
message(
FATAL_ERROR "Libint2 was found, but its Fortran interface is missing")
endif()
get_filename_component(_libint2_mod_dir "${CP2K_LIBINT2_MOD_FILE}" DIRECTORY)
include_directories(BEFORE ${_libint2_include_dirs} "${_libint2_mod_dir}")
endif()
if(CP2K_USE_LIBFCI)

View file

@ -1,71 +0,0 @@
#!-------------------------------------------------------------------------------------------------!
#! CP2K: A general program to perform molecular dynamics simulations !
#! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
#! !
#! SPDX-License-Identifier: GPL-2.0-or-later !
#!-------------------------------------------------------------------------------------------------!
# Copyright (c) 2022- ETH Zurich
#
# authors : Mathieu Taillefumier
include(FindPackageHandleStandardArgs)
include(cp2k_utils)
cp2k_set_default_paths(LIBINT2 "Libint2")
find_package(PkgConfig REQUIRED)
if(PKG_CONFIG_FOUND)
pkg_check_modules(CP2K_LIBINT2 IMPORTED_TARGET GLOBAL libint2)
endif()
if(NOT CP2K_LIBINT2_FOUND)
cp2k_find_libraries(LIBINT2 int2)
endif()
if(NOT CP2K_LIBINT2_INCLUDE_DIRS)
cp2k_include_dirs(LIBINT2 "libint2.h;libint2/atom.h")
endif()
find_file(
CP2K_LIBINT2_MOD_FILE
NAMES "libint_f.mod"
PATHS "${CP2K_LIBINT2_ROOT}/include"
"${CP2K_LIBINT2_ROOT}/include/libint2"
"${CP2K_LIBINT2_ROOT}/lib/gfortran/modules"
"${CP2K_LIBINT2_ROOT}/lib64/gfortran/modules"
"/usr/lib/gfortran/modules"
"/usr/lib64/gfortran/modules")
if(CP2K_LIBINT2_MOD_FILE)
get_filename_component(CP2K_LIBINT2_MOD_DIR "${CP2K_LIBINT2_MOD_FILE}"
DIRECTORY)
list(APPEND CP2K_LIBINT2_INCLUDE_DIRS "${CP2K_LIBINT2_MOD_DIR}")
list(REMOVE_DUPLICATES CP2K_LIBINT2_INCLUDE_DIRS)
else()
message(FATAL_ERROR "Libint2 : Fortran support is missing")
endif()
find_package_handle_standard_args(
Libint2 CP2K_LIBINT2_FOUND CP2K_LIBINT2_INCLUDE_DIRS
CP2K_LIBINT2_LINK_LIBRARIES)
if(CP2K_LIBINT2_FOUND)
if(NOT TARGET cp2k::Libint2::int2)
add_library(cp2k::Libint2::int2 INTERFACE IMPORTED)
endif()
if(CP2K_LIBINT2_INCLUDE_DIRS)
set_target_properties(
cp2k::Libint2::int2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${CP2K_LIBINT2_INCLUDE_DIRS}")
endif()
set_target_properties(
cp2k::Libint2::int2 PROPERTIES INTERFACE_LINK_LIBRARIES
${CP2K_LIBINT2_LINK_LIBRARIES})
endif()
mark_as_advanced(CP2K_LIBINT2_FOUND CP2K_LIBINT2_LINK_LIBRARIES
CP2K_LIBINT2_INCLUDE_DIRS)

View file

@ -1786,7 +1786,7 @@ target_link_libraries(
$<$<BOOL:${CP2K_USE_SPLA}>:SPLA::spla>
$<$<BOOL:${CP2K_USE_MIMIC}>:CP2K::MIMIC::mclf>
$<$<BOOL:${CP2K_USE_MIMIC}>:CP2K::MIMIC::mcl>
$<$<BOOL:${CP2K_USE_LIBINT2}>:cp2k::Libint2::int2>
$<$<BOOL:${CP2K_USE_LIBINT2}>:Libint2::int2>
$<$<BOOL:${CP2K_USE_LIBFCI}>:cp2k::libfci::fci>
$<$<BOOL:${CP2K_USE_COSMA}>:cp2k::cosma>
$<$<BOOL:${CP2K_USE_DLAF}>:${CP2K_DLAF_FORTRAN_TARGET}>

View file

@ -230,6 +230,15 @@ else
fi
fi
done
# Additional feature of SIRIUS
if [ "${with_sirius}" = "__INSTALL__" ]; then
CMAKE_OPTIONS+=" -DCP2K_USE_SIRIUS_VCSQNM=ON"
if [ "${with_tblite}" != "__DONTUSE__" ]; then
CMAKE_OPTIONS+=" -DCP2K_USE_SIRIUS_DFTD3=ON -DCP2K_USE_SIRIUS_DFTD4=ON"
elif [ "${with_dftd4}" != "__DONTUSE__" ]; then
CMAKE_OPTIONS+=" -DCP2K_USE_SIRIUS_DFTD4=ON"
fi
fi
fi
# If GPU acceleration is used, add the option about GPU acceleration
if [ "${ENABLE_CUDA}" = "__TRUE__" ]; then

View file

@ -259,6 +259,8 @@ Specific options of --with-PKG:
integration. Installing GauXC with OneDFT/SKALA
support also enables libtorch and installs Skala-1.1.
Default = no
--with-eigen Enable Eigen3; required by libint and SIRIUS.
Default = no
--with-libint Enable libint for two-body molecular integrals in
Hartree-Fock and hybrid functional calculations.
Default = install
@ -474,10 +476,10 @@ EOF
tool_list="gcc intel amd cmake ninja"
mpi_list="mpich openmpi intelmpi"
math_list="mkl acml openblas"
lib_list="fftw libint libxc gauxc libxsmm libxs libxstream cosma scalapack elpa dbcsr
cusolvermp plumed spfft spla gsl spglib hdf5 libvdwxc sirius
libvori libtorch deepmd ace dftd4 tblite pugixml libsmeagol
fmt trexio libfci greenx gmp mcl"
lib_list="fftw eigen libint libxc gauxc libxsmm libxs libxstream cosma scalapack
elpa dbcsr cusolvermp plumed spfft spla gsl spglib hdf5 libvdwxc sirius
libvori libtorch deepmd ace dftd4 tblite pugixml libsmeagol fmt trexio
libfci greenx gmp mcl"
package_list="${tool_list} ${mpi_list} ${math_list} ${lib_list}"
# ------------------------------------------------------------------------
@ -496,6 +498,7 @@ with_gcc="__SYSTEM__"
# libs to turn on by default:
with_dbcsr="__INSTALL__"
with_fftw="__INSTALL__"
with_eigen="__DONTUSE__"
with_libint="__INSTALL__"
with_libxsmm="__INSTALL__"
with_libxs="__INSTALL__"
@ -838,6 +841,9 @@ Otherwise use option no."
--with-fftw*)
with_fftw=$(read_with "${1}")
;;
--with-eigen*)
with_eigen=$(read_with "${1}")
;;
--with-mkl*)
with_mkl=$(read_with "${1}" "__SYSTEM__")
if [ "${with_mkl}" != "__DONTUSE__" ]; then
@ -1152,27 +1158,11 @@ package will not be used separately."
fi
fi
# Several packages require cmake.
if [ "${with_spglib}" = "__INSTALL__" ] ||
[ "${with_libvori}" = "__INSTALL__" ] ||
[ "${with_scalapack}" = "__INSTALL__" ] ||
[ "${with_sirius}" = "__INSTALL__" ] ||
[ "${with_pugixml}" = "__INSTALL__" ] ||
[ "${with_cosma}" = "__INSTALL__" ] ||
[ "${with_spfft}" = "__INSTALL__" ] ||
[ "${with_spla}" = "__INSTALL__" ] ||
[ "${with_ninja}" = "__INSTALL__" ] ||
[ "${with_gauxc}" = "__INSTALL__" ] ||
[ "${with_greenx}" = "__INSTALL__" ] ||
[ "${with_libfci}" = "__INSTALL__" ] ||
[ "${with_dftd4}" = "__INSTALL__" ] ||
[ "${with_mcl}" = "__INSTALL__" ] ||
[ "${with_tblite}" = "__INSTALL__" ]; then
if [ "${with_cmake}" = "__DONTUSE__" ]; then
report_warning ${LINENO} "Installing one of the packages requires CMake but
CMake is not found in system, so a new copy of CMake will be installed first."
with_cmake="__INSTALL__"
fi
# Require cmake as hard dependency.
if [ "${with_cmake}" = "__DONTUSE__" ]; then
report_warning ${LINENO} "Installing dependencies and CP2K requires CMake but
CMake is not enabled, so a new copy of CMake will be installed first."
with_cmake="__INSTALL__"
fi
# SIRIUS dependencies
@ -1180,9 +1170,11 @@ if [ "${with_sirius}" = "__INSTALL__" ]; then
[ "${with_spfft}" = "__DONTUSE__" ] && with_spfft="__INSTALL__"
[ "${with_spla}" = "__DONTUSE__" ] && with_spla="__INSTALL__"
[ "${with_gsl}" = "__DONTUSE__" ] && with_gsl="__INSTALL__"
[ "${with_eigen}" = "__DONTUSE__" ] && with_eigen="__INSTALL__"
[ "${with_fmt}" = "__DONTUSE__" ] && with_fmt="__INSTALL__"
[ "${with_libxc}" = "__DONTUSE__" ] && with_libxc="__INSTALL__"
[ "${with_fftw}" = "__DONTUSE__" ] && with_fftw="__INSTALL__"
[ "${with_scalapack}" = "__DONTUSE__" ] && with_scalapack="__INSTALL__"
[ "${with_spglib}" = "__DONTUSE__" ] && with_spglib="__INSTALL__"
[ "${with_hdf5}" = "__DONTUSE__" ] && with_hdf5="__INSTALL__"
[ "${with_libvdwxc}" = "__DONTUSE__" ] && with_libvdwxc="__INSTALL__"
@ -1196,6 +1188,10 @@ elif [ "${with_sirius}" = "__DONTUSE__" ]; then
[ "${GPUVER}" = "no" ] && with_spla="__DONTUSE__"
fi
if [ "${with_libint}" = "__INSTALL__" ]; then
[ "${with_eigen}" = "__DONTUSE__" ] && with_eigen="__INSTALL__"
fi
if [ "${with_trexio}" = "__INSTALL__" ]; then
[ "${with_hdf5}" = "__DONTUSE__" ] && with_hdf5="__INSTALL__"
fi
@ -1219,17 +1215,19 @@ if [ "${MATH_MODE}" = "mkl" ]; then
# Use standalone FFTW when FFTW-MPI wrappers are needed. Otherwise, use
# MKL's FFTW3 interface and do not install a separate FFTW package.
if [ "${with_libvdwxc}" != "__DONTUSE__" ] && [ "${MPI_MODE}" != "no" ]; then
report_warning ${LINENO} "libvdwxc with MPI needs FFTW-MPI wrappers; enabling standalone FFTW."
if [ "${with_fftw}" = "__DONTUSE__" ]; then
report_warning ${LINENO} "libvdwxc with MPI needs FFTW-MPI wrappers; enabling FFTW."
with_fftw="__INSTALL__"
fi
export MKL_FFTW="no"
else
echo "Using MKL-vendored FFTW"
with_fftw="__DONTUSE__"
export MKL_FFTW="yes"
fi
# Use MKL-provided ScaLAPACK/BLACS for MPI builds.
if [ "${MPI_MODE}" != "no" ]; then
echo "Using MKL-vendored ScaLAPACK"
with_scalapack="__DONTUSE__"
export MKL_SCALAPACK="yes"
fi

View file

@ -0,0 +1,81 @@
#!/bin/bash -e
# TODO: Review and if possible fix shellcheck errors.
# shellcheck disable=all
[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")/.." && pwd -P)"
source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
source "${SCRIPT_DIR}"/signal_trap.sh
source "${INSTALLDIR}"/toolchain.conf
source "${INSTALLDIR}"/toolchain.env
eigen_ver="5.0.1"
eigen_sha256="e9c326dc8c05cd1e044c71f30f1b2e34a6161a3b6ecf445d56b53ff1669e3dec"
[ -f "${BUILDDIR}/setup_eigen" ] && rm "${BUILDDIR}/setup_eigen"
! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
case "$with_eigen" in
__INSTALL__)
echo "==================== Installing Eigen ===================="
pkg_install_dir="${INSTALLDIR}/eigen-${eigen_ver}"
install_lock_file="${pkg_install_dir}/install_successful"
if verify_checksums "${install_lock_file}"; then
echo "eigen-${eigen_ver} is already installed, skipping it."
else
retrieve_package "${eigen_sha256}" "eigen-${eigen_ver}.tar.gz"
echo "Installing from scratch into ${pkg_install_dir}"
[ -d eigen-${eigen_ver} ] && rm -rf eigen-${eigen_ver}
tar -xzf "eigen-${eigen_ver}.tar.gz"
cd eigen-${eigen_ver}
mkdir build
cd build
cmake .. \
-DCMAKE_INSTALL_PREFIX=${pkg_install_dir} \
-DBUILD_TESTING=OFF \
-DEIGEN_BUILD_BLAS=OFF \
-DEIGEN_BUILD_LAPACK=OFF \
> configure.log 2>&1 || tail_excerpt configure.log
make install -j $(get_nprocs) > make.log 2>&1 || tail_excerpt make.log
cd ..
write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage3/$(basename ${SCRIPT_NAME})"
fi
;;
__SYSTEM__)
echo "==================== Finding Eigen from system paths ===================="
add_include_from_paths EIGEN_CFLAGS "eigen3" "${INCLUDE_PATHS}"
;;
__DONTUSE__) ;;
*)
echo "==================== Linking Eigen to user paths ===================="
pkg_install_dir="$with_eigen"
check_dir "${pkg_install_dir}/include/eigen3"
;;
esac
if [ "$with_eigen" != "__DONTUSE__" ]; then
cat << EOF > "${BUILDDIR}/setup_eigen"
export EIGEN_VER="${eigen_ver}"
export EIGEN_ROOT="${pkg_install_dir}"
EOF
if [ "$with_eigen" != "__SYSTEM__" ]; then
cat << EOF >> "${BUILDDIR}/setup_eigen"
prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}"
prepend_path CPATH "${pkg_install_dir}/include/eigen3"
EOF
fi
filter_setup "${BUILDDIR}/setup_eigen" "${SETUPFILE}"
fi
load "${BUILDDIR}/setup_eigen"
write_toolchain_env "${INSTALLDIR}"
cd "${ROOTDIR}"
report_timing "eigen"

View file

@ -64,12 +64,11 @@ case "$with_libint" in
FCFLAGS="$LIBINT_FCFLAGS" cmake .. \
-DCMAKE_INSTALL_PREFIX=${pkg_install_dir} \
-DCMAKE_CXX_COMPILER="$CXX" \
-DLIBINT2_INSTALL_LIBDIR="${pkg_install_dir}/lib" \
-DCMAKE_INSTALL_LIBDIR="${pkg_install_dir}/lib" \
-DBUILD_TESTING=OFF \
-DLIBINT2_ENABLE_FORTRAN=ON \
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=ON \
-DLIBINT2_REQUIRE_CXX_API=OFF \
> configure.log 2>&1 || tail_excerpt configure.log
tar -xzf ../external/boost.tar.gz -C ./include/libint2
make install -j $(get_nprocs) > make.log 2>&1 || tail_excerpt make.log
cd ..

View file

@ -4,6 +4,7 @@
# shellcheck disable=all
./scripts/stage3/install_fftw.sh
./scripts/stage3/install_eigen.sh
./scripts/stage3/install_libint.sh
./scripts/stage3/install_libxc.sh
./scripts/stage3/install_greenx.sh

View file

@ -65,8 +65,8 @@ case "$with_sirius" in
tar -xzf SIRIUS-${sirius_ver}.tar.gz
cd SIRIUS-${sirius_ver}
patch -l -p1 < "${SCRIPT_DIR}/stage8/sirius-dftd4-static-link.patch" \
> sirius-dftd4-static-link.patch.log 2>&1 || tail_excerpt sirius-dftd4-static-link.patch.log
patch -l -p1 < "${SCRIPT_DIR}/stage8/sirius-linking.patch" \
> sirius-linking.patch.log 2>&1 || tail_excerpt sirius-linking.patch.log
rm -Rf build
mkdir build
@ -74,8 +74,8 @@ case "$with_sirius" in
if [ "${with_elpa}" != "__DONTUSE__" ]; then
EXTRA_CMAKE_FLAGS="-DSIRIUS_USE_ELPA=ON ${EXTRA_CMAKE_FLAGS}"
fi
if [ "${MATH_MODE}" == "mkl" ]; then
EXTRA_CMAKE_FLAGS="-DSIRIUS_USE_MKL=ON -DSIRIUS_USE_SCALAPACK=ON ${EXTRA_CMAKE_FLAGS}"
if [ "${math_mode}" == "mkl" ]; then
EXTRA_CMAKE_FLAGS="-DSIRIUS_USE_MKL=ON ${EXTRA_CMAKE_FLAGS}"
fi
if [ "${with_tblite}" != "__DONTUSE__" ]; then
# tblite includes s-dftd3
@ -94,6 +94,8 @@ case "$with_sirius" in
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DSIRIUS_USE_SCALAPACK=ON \
-DSIRIUS_USE_VCSQNM=ON \
-DSIRIUS_USE_VDWXC=ON \
-DSIRIUS_USE_PUGIXML=ON \
-DSIRIUS_USE_MEMORY_POOL=OFF \
@ -120,6 +122,8 @@ case "$with_sirius" in
-DSIRIUS_USE_MEMORY_POOL=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DSIRIUS_USE_SCALAPACK=ON \
-DSIRIUS_USE_VCSQNM=ON \
-DSIRIUS_USE_PUGIXML=ON \
-DSIRIUS_USE_VDWXC=ON \
-DCMAKE_CXX_COMPILER="${MPICXX}" \
@ -133,7 +137,8 @@ case "$with_sirius" in
fi
SIRIUS_CFLAGS="-I'${pkg_install_dir}/include/sirius'"
SIRIUS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath,'${pkg_install_dir}/lib"
write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage8/$(basename ${SCRIPT_NAME})"
write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage8/$(basename ${SCRIPT_NAME})" \
"${SCRIPT_DIR}/stage8/sirius-linking.patch"
fi
;;
__SYSTEM__)
@ -161,16 +166,22 @@ export SIRIUS_VER="${sirius_ver}"
EOF
if [ "$with_sirius" != "__SYSTEM__" ]; then
cat << EOF >> "${BUILDDIR}/setup_sirius"
prepend_path PATH "${pkg_install_dir}/bin"
prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib"
prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/cuda/lib"
prepend_path LD_RUN_PATH "${pkg_install_dir}/lib"
prepend_path LD_RUN_PATH "${pkg_install_dir}/cuda/lib"
prepend_path LIBRARY_PATH "${pkg_install_dir}/lib"
prepend_path LIBRARY_PATH "${pkg_install_dir}/cuda/lib"
prepend_path CPATH "${pkg_install_dir}/include/sirius"
prepend_path PKG_CONFIG_PATH "${pkg_install_dir}/lib/pkgconfig"
prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}"
EOF
if [ "$ENABLE_CUDA" = "__TRUE__" ]; then
cat << EOF >> "${BUILDDIR}/setup_sirius"
prepend_path PATH "${pkg_install_dir}/cuda/bin"
prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/cuda/lib"
prepend_path LD_RUN_PATH "${pkg_install_dir}/cuda/lib"
prepend_path LIBRARY_PATH "${pkg_install_dir}/cuda/lib"
EOF
fi
fi
cat << EOF >> "${BUILDDIR}/setup_sirius"
export SIRIUS_CFLAGS="IF_CUDA(-I${pkg_install_dir}/cuda/include/sirius|-I${pkg_install_dir}/include/sirius)"

View file

@ -1,15 +0,0 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -119,8 +119,9 @@ target_link_libraries(sirius_cxx PUBLIC ${GSL_LIBRARY}
SpFFT::spfft
SPLA::spla
GSL::gsl
- $<$<BOOL:${SIRIUS_USE_DFTD3}>:sirius::dftd3 sirius::mctclib>
- $<$<BOOL:${SIRIUS_USE_DFTD4}>:sirius::dftd4 sirius::multicharge sirius::mctclib>
+ $<$<BOOL:${SIRIUS_USE_DFTD3}>:sirius::dftd3>
+ $<$<BOOL:${SIRIUS_USE_DFTD4}>:sirius::dftd4 sirius::multicharge>
+ $<$<OR:$<BOOL:${SIRIUS_USE_DFTD3}>,$<BOOL:${SIRIUS_USE_DFTD4}>>:sirius::mctclib>
"${SIRIUS_LINALG_LIB}"
$<$<BOOL:${SIRIUS_USE_PUGIXML}>:pugixml::pugixml>
$<$<BOOL:${SIRIUS_USE_MEMORY_POOL}>:umpire>

View file

@ -0,0 +1,62 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 787e2ce..40bf714 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -205,7 +205,7 @@ else()
find_package(LAPACK REQUIRED)
set(SIRIUS_LINALG_LIB "${LAPACK_LIBRARIES}")
if(SIRIUS_USE_SCALAPACK)
find_package(SCALAPACK REQUIRED) # just sets scalapack_DIR
- set(SIRIUS_LINALG_LIB "${SIRIUS_LINALG_LIB};${SIRIUS_SCALAPACK_LIBRARIES}")
+ list(APPEND SIRIUS_LINALG_LIB sirius::scalapack)
endif()
endif()
diff --git a/cmake/modules/FindSCALAPACK.cmake b/cmake/modules/FindSCALAPACK.cmake
index 2df5d2f4e..779cf748f 100644
--- a/cmake/modules/FindSCALAPACK.cmake
+++ b/cmake/modules/FindSCALAPACK.cmake
@@ -7,8 +7,26 @@ find_library(SIRIUS_SCALAPACK_LIBRARIES
HINTS
${_SCALAPACK_LIBRARY_DIRS}
ENV SCALAPACKROOT
- /usr
- PATH_SUFFIXES lib
+ /usr /usr/local
+ PATH_SUFFIXES lib lib64
DOC "scalapack library path")
+if(NOT TARGET sirius::scalapack)
+ add_library(sirius::scalapack INTERFACE IMPORTED)
+ set_target_properties(sirius::scalapack PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${SIRIUS_SCALAPACK_LIBRARIES}"
+ )
+ if(_SCALAPACK_INCLUDE_DIRS)
+ set_target_properties(sirius::scalapack PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${_SCALAPACK_INCLUDE_DIRS}"
+ )
+ endif()
+endif()
+
+if(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES)
+ set_property(TARGET sirius::scalapack APPEND PROPERTY
+ INTERFACE_LINK_LIBRARIES ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES})
+endif()
+
find_package_handle_standard_args(SCALAPACK DEFAULT_MSG SIRIUS_SCALAPACK_LIBRARIES)
+mark_as_advanced(SIRIUS_SCALAPACK_LIBRARIES)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3f3b5d8f1..546a54828 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -119,8 +119,9 @@ target_link_libraries(sirius_cxx PUBLIC ${GSL_LIBRARY}
SpFFT::spfft
SPLA::spla
GSL::gsl
- $<$<BOOL:${SIRIUS_USE_DFTD3}>:sirius::dftd3 sirius::mctclib>
- $<$<BOOL:${SIRIUS_USE_DFTD4}>:sirius::dftd4 sirius::multicharge sirius::mctclib>
+ $<$<BOOL:${SIRIUS_USE_DFTD3}>:sirius::dftd3>
+ $<$<BOOL:${SIRIUS_USE_DFTD4}>:sirius::dftd4 sirius::multicharge>
+ $<$<OR:$<BOOL:${SIRIUS_USE_DFTD3}>,$<BOOL:${SIRIUS_USE_DFTD4}>>:sirius::mctclib>
"${SIRIUS_LINALG_LIB}"
$<$<BOOL:${SIRIUS_USE_PUGIXML}>:pugixml::pugixml>
$<$<BOOL:${SIRIUS_USE_MEMORY_POOL}>:umpire>