mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 06:05:29 -04:00
Cleanup LibXC handling in CMake
This commit is contained in:
parent
35f4375abe
commit
a2ea924e12
5 changed files with 8 additions and 67 deletions
|
|
@ -588,7 +588,7 @@ if(CP2K_USE_ELPA)
|
|||
endif()
|
||||
|
||||
if(CP2K_USE_LIBXC)
|
||||
find_package(LibXC 7 REQUIRED)
|
||||
find_package(Libxc 7 REQUIRED CONFIG)
|
||||
endif()
|
||||
|
||||
# uncomment this when libgrpp cmake support is complete
|
||||
|
|
@ -822,10 +822,9 @@ if(CP2K_USE_CUSOLVER_MP)
|
|||
endif()
|
||||
|
||||
if(CP2K_USE_LIBXC)
|
||||
message(
|
||||
" - LIBXC (note to package managers : libxc can be build with cmake as well)"
|
||||
" - include directories : ${CP2K_LIBXC_INCLUDE_DIRS}\n"
|
||||
" - libraries : ${CP2K_LIBXC_LINK_LIBRARIES}\n\n")
|
||||
message(" - LibXC\n" " - Libxc_VERSION: ${Libxc_VERSION}\n"
|
||||
" - Libxc_INCLUDE_DIRS : ${Libxc_INCLUDE_DIRS}\n"
|
||||
" - Libxc_LIBRARIES : ${Libxc_LIBRARIES}\n\n")
|
||||
endif()
|
||||
|
||||
if(CP2K_USE_LIBTORCH)
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
#!-------------------------------------------------------------------------------------------------!
|
||||
#! CP2K: A general program to perform molecular dynamics simulations !
|
||||
#! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
|
||||
#! !
|
||||
#! SPDX-License-Identifier: GPL-2.0-or-later !
|
||||
#!-------------------------------------------------------------------------------------------------!
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
include(cp2k_utils)
|
||||
|
||||
cp2k_set_default_paths(LIBXC "LibXC")
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
# For LibXC >= 7, the Fortran interface is only libxcf03
|
||||
pkg_check_modules(CP2K_LIBXC IMPORTED_TARGET GLOBAL libxcf03 libxc>=7)
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_LIBXC_FOUND)
|
||||
# Revert pkg_check_modules side effects
|
||||
cp2k_set_default_paths(LIBXC "LibXC")
|
||||
foreach(_var xc xcf03)
|
||||
string(TOUPPER LIB${_var} _var_up)
|
||||
cp2k_find_libraries(${_var_up} ${_var})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(CP2K_LIBXC_FOUND)
|
||||
# Require both libxc + libxcf03 for LibXC 7
|
||||
set(CP2K_LIBXC_LINK_LIBRARIES
|
||||
"${CP2K_LIBXCF03_LIBRARIES};${CP2K_LIBXC_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
if(NOT CP2K_LIBXC_INCLUDE_DIRS)
|
||||
cp2k_include_dirs(LIBXC "xc.h;libxc/xc.h")
|
||||
endif()
|
||||
|
||||
if(CP2K_LIBXC_INCLUDE_DIRS)
|
||||
find_package_handle_standard_args(
|
||||
LibXC DEFAULT_MSG CP2K_LIBXC_FOUND CP2K_LIBXC_LINK_LIBRARIES
|
||||
CP2K_LIBXC_INCLUDE_DIRS)
|
||||
else()
|
||||
find_package_handle_standard_args(LibXC DEFAULT_MSG CP2K_LIBXC_FOUND
|
||||
CP2K_LIBXC_LINK_LIBRARIES)
|
||||
endif()
|
||||
if(CP2K_LIBXC_FOUND)
|
||||
if(NOT TARGET cp2k::Libxc::xc)
|
||||
add_library(cp2k::Libxc::xc INTERFACE IMPORTED)
|
||||
endif()
|
||||
|
||||
if(CP2K_LIBXC_INCLUDE_DIRS)
|
||||
set_target_properties(
|
||||
cp2k::Libxc::xc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CP2K_LIBXC_INCLUDE_DIRS}")
|
||||
endif()
|
||||
target_link_libraries(cp2k::Libxc::xc INTERFACE ${CP2K_LIBXC_LINK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
mark_as_advanced(CP2K_LIBXC_FOUND CP2K_LIBXC_LINK_LIBRARIES
|
||||
CP2K_LIBXC_INCLUDE_DIRS)
|
||||
|
|
@ -1609,7 +1609,7 @@ target_link_libraries(
|
|||
$<$<BOOL:${CP2K_USE_VORI}>:cp2k::VORI::vori>
|
||||
$<$<BOOL:${CP2K_USE_SPGLIB}>:Spglib::symspg>
|
||||
$<$<BOOL:${CP2K_USE_LIBSMEAGOL}>:cp2k::libsmeagol::smeagol>
|
||||
$<$<BOOL:${CP2K_USE_LIBXC}>:cp2k::Libxc::xc>
|
||||
$<$<BOOL:${CP2K_USE_LIBXC}>:Libxc::xcf03>
|
||||
$<$<BOOL:${CP2K_USE_ELPA}>:cp2k::ELPA::elpa>
|
||||
$<$<BOOL:${CP2K_USE_PLUMED}>:cp2k::plumed::plumed>
|
||||
$<$<BOOL:${CP2K_USE_FFTW3_}>:cp2k::FFTW3::fftw3>
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ elif [[ "${PROFILE}" == "toolchain" ]] && [[ "${VERSION}" == "pdbg" ]]; then
|
|||
|
||||
elif [[ "${PROFILE}" == "ubuntu" ]] && [[ "${VERSION}" == "ssmp" ]]; then
|
||||
# TODO fix spglib https://github.com/cp2k/cp2k/issues/3414
|
||||
# NOTE: libxc 5.2.3 is provided, CP2K requires libxc 7
|
||||
cmake \
|
||||
-GNinja \
|
||||
-DCMAKE_INSTALL_PREFIX=/opt/cp2k \
|
||||
|
|
@ -190,6 +191,7 @@ elif [[ "${PROFILE}" == "ubuntu" ]] && [[ "${VERSION}" == "ssmp" ]]; then
|
|||
-DCP2K_USE_LIBINT2=ON \
|
||||
-DCP2K_USE_LIBXC=ON \
|
||||
-DCP2K_USE_FFTW3=ON \
|
||||
-DCP2K_USE_LIBXC=OFF \
|
||||
-DCP2K_USE_LIBXSMM=ON \
|
||||
-DCP2K_USE_SPGLIB=OFF \
|
||||
-DCP2K_USE_MPI=OFF \
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ spack:
|
|||
- "netlib-scalapack@2.2.0"
|
||||
- "libxsmm@1.17"
|
||||
- "fftw@3.3.10 +openmp"
|
||||
- "libxc@6.2.2"
|
||||
- "libxc@7.0.0 +kxc build_system=cmake"
|
||||
- "spglib@2.3.0"
|
||||
- "dla-future@0.7.3 +scalapack"
|
||||
- "dla-future-fortran@0.2.0"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue