From e6ebf077fb7de147eb6e3d4b9935b22a276dfdcc Mon Sep 17 00:00:00 2001 From: yizeyi18 <18586016708@163.com> Date: Fri, 12 Jan 2024 20:17:53 +0800 Subject: [PATCH 01/15] Fix for finding LibXC and ELPA --- CMakeLists.txt | 11 +++++----- cmake/FindELPA.cmake | 50 +++++++++++++++++++++++++++---------------- cmake/FindLibxc.cmake | 43 +++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 23 deletions(-) create mode 100644 cmake/FindLibxc.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 431f844993..19bd7adeb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -508,11 +508,12 @@ if(DEFINED Libxc_DIR) set(ENABLE_LIBXC ON) endif() if(ENABLE_LIBXC) - find_package(Libxc REQUIRED HINTS - ${Libxc_DIR}/share/cmake/Libxc - ${Libxc_DIR}/lib/cmake/Libxc - ${Libxc_DIR}/lib64/cmake/Libxc - ) +# find_package(Libxc REQUIRED HINTS +# ${Libxc_DIR}/share/cmake/Libxc +# ${Libxc_DIR}/lib/cmake/Libxc +# ${Libxc_DIR}/lib64/cmake/Libxc +# ) + find_package(Libxc REQUIRED) message(STATUS "Found Libxc: version " ${Libxc_VERSION}) if(${Libxc_VERSION} VERSION_LESS 5.1.7) message(FATAL_ERROR "LibXC >= 5.1.7 is required.") diff --git a/cmake/FindELPA.cmake b/cmake/FindELPA.cmake index 5769f7248c..8606490a6e 100644 --- a/cmake/FindELPA.cmake +++ b/cmake/FindELPA.cmake @@ -7,23 +7,37 @@ # ELPA_INCLUDE_DIR - Where to find ELPA headers. # -find_path(ELPA_INCLUDE_DIR - elpa/elpa.h - HINTS ${ELPA_DIR} - PATH_SUFFIXES "include" "include/elpa" - ) -if(USE_OPENMP) - find_library(ELPA_LIBRARY - NAMES elpa_openmp elpa - HINTS ${ELPA_DIR} - PATH_SUFFIXES "lib" - ) +# Legacy Routine +#find_path(ELPA_INCLUDE_DIR +# elpa/elpa.h +# HINTS ${ELPA_DIR} +# PATH_SUFFIXES "include" "include/elpa" +# ) +#if(USE_OPENMP) +# find_library(ELPA_LIBRARY +# NAMES elpa_openmp elpa +# HINTS ${ELPA_DIR} +# PATH_SUFFIXES "lib" +# ) +#else() +# find_library(ELPA_LIBRARY +# NAMES elpa +# HINTS ${ELPA_DIR} +# PATH_SUFFIXES "lib" +# ) +#endif() + +find_package(PkgConfig) + +if(PKG_CONFIG_FOUND) + if(USE_OPENMP) + pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp) + else() + pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa) + endif() else() - find_library(ELPA_LIBRARY - NAMES elpa - HINTS ${ELPA_DIR} - PATH_SUFFIXES "lib" - ) + message( + "ELPA : We need pkg-config to get all information about the elpa library") endif() # Handle the QUIET and REQUIRED arguments and @@ -33,8 +47,8 @@ find_package_handle_standard_args(ELPA DEFAULT_MSG ELPA_LIBRARY ELPA_INCLUDE_DIR # Copy the results to the output variables and target. if(ELPA_FOUND) - set(ELPA_LIBRARIES ${ELPA_LIBRARY}) - set(ELPA_INCLUDE_DIR ${ELPA_INCLUDE_DIR}) + set(ELPA_LIBRARY ${ELPA_LIBRARIES}) + set(ELPA_INCLUDE_DIR ${ELPA_INCLUDE_DIRS}) if(NOT TARGET ELPA::ELPA) add_library(ELPA::ELPA UNKNOWN IMPORTED) diff --git a/cmake/FindLibxc.cmake b/cmake/FindLibxc.cmake new file mode 100644 index 0000000000..4446b2e7da --- /dev/null +++ b/cmake/FindLibxc.cmake @@ -0,0 +1,43 @@ +############################################################################### +# - Find ELPA +# Find the native ELPA headers and libraries. +# +# ELPA_FOUND - True if libelpa is found. +# ELPA_LIBRARIES - List of libraries when using libyaml +# ELPA_INCLUDE_DIR - Where to find ELPA headers. +# + +#find_path(ELPA_INCLUDE_DIR +# elpa/elpa.h +# HINTS ${ELPA_DIR} +# PATH_SUFFIXES "include" "include/elpa" +# ) + +find_package(PkgConfig) + +if(PKG_CONFIG_FOUND) + pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc) +else() + message( + "LibXC : We need pkg-config to get all information about the libxc library") +endif() + +# Handle the QUIET and REQUIRED arguments and +# set ELPA_FOUND to TRUE if all variables are non-zero. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) + +# Copy the results to the output variables and target. +if(Libxc_FOUND AND NOT TARGET Libxc::xc) + set(Libxc_LIBRARY ${Libxc_LINK_LIBRARIES}) + set(Libxc_LIBRARIES ${Libxc_LIBRARY}) + set(Libxc_INCLUDE_DIR ${Libxc_INCLUDE_DIRS}) + add_library(Libxc::xc UNKNOWN IMPORTED) + set_target_properties(Libxc::xc PROPERTIES + IMPORTED_LOCATION "${Libxc_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${Libxc_INCLUDE_DIR}") +endif() + +set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Libxc_INCLUDE_DIR}) + +mark_as_advanced(Libxc_INCLUDE_DIR Libxc_LIBRARY) From b43112b1f38b30cf707b0580da6463e9addc2558 Mon Sep 17 00:00:00 2001 From: yizeyi18 <18586016708@163.com> Date: Fri, 12 Jan 2024 20:49:24 +0800 Subject: [PATCH 02/15] For compatibility to previous routines --- cmake/FindELPA.cmake | 63 +++++++++++++++++++++++++++---------------- cmake/FindLibxc.cmake | 19 +++++++------ 2 files changed, 51 insertions(+), 31 deletions(-) diff --git a/cmake/FindELPA.cmake b/cmake/FindELPA.cmake index 8606490a6e..2200d43dc1 100644 --- a/cmake/FindELPA.cmake +++ b/cmake/FindELPA.cmake @@ -7,25 +7,24 @@ # ELPA_INCLUDE_DIR - Where to find ELPA headers. # -# Legacy Routine -#find_path(ELPA_INCLUDE_DIR -# elpa/elpa.h -# HINTS ${ELPA_DIR} -# PATH_SUFFIXES "include" "include/elpa" -# ) -#if(USE_OPENMP) -# find_library(ELPA_LIBRARY -# NAMES elpa_openmp elpa -# HINTS ${ELPA_DIR} -# PATH_SUFFIXES "lib" -# ) -#else() -# find_library(ELPA_LIBRARY -# NAMES elpa -# HINTS ${ELPA_DIR} -# PATH_SUFFIXES "lib" -# ) -#endif() +find_path(ELPA_INCLUDE_DIR + elpa/elpa.h + HINTS ${ELPA_DIR} + PATH_SUFFIXES "include" "include/elpa" + ) +if(USE_OPENMP) + find_library(ELPA_LIBRARY + NAMES elpa_openmp elpa + HINTS ${ELPA_DIR} + PATH_SUFFIXES "lib" + ) +else() + find_library(ELPA_LIBRARY + NAMES elpa + HINTS ${ELPA_DIR} + PATH_SUFFIXES "lib" + ) +endif() find_package(PkgConfig) @@ -36,18 +35,36 @@ if(PKG_CONFIG_FOUND) pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa) endif() else() - message( - "ELPA : We need pkg-config to get all information about the elpa library") + find_path(ELPA_INCLUDE_DIRS + elpa/elpa.h + HINTS ${ELPA_DIR} + PATH_SUFFIXES "include" "include/elpa" + ) + if(USE_OPENMP) + find_library(ELPA_LINK_LIBRARIES + NAMES elpa_openmp elpa + HINTS ${ELPA_DIR} + PATH_SUFFIXES "lib" + ) + else() + find_library(ELPA_LINK_LIBRARIES + NAMES elpa + HINTS ${ELPA_DIR} + PATH_SUFFIXES "lib" + ) + endif() + #message( + # "ELPA : We need pkg-config to get all information about the elpa library") endif() # Handle the QUIET and REQUIRED arguments and # set ELPA_FOUND to TRUE if all variables are non-zero. include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(ELPA DEFAULT_MSG ELPA_LIBRARY ELPA_INCLUDE_DIR) +find_package_handle_standard_args(ELPA DEFAULT_MSG ELPA_LINK_LIBRARIES ELPA_INCLUDE_DIRS) # Copy the results to the output variables and target. if(ELPA_FOUND) - set(ELPA_LIBRARY ${ELPA_LIBRARIES}) + set(ELPA_LIBRARY ${ELPA_LINK_LIBRARIES}) set(ELPA_INCLUDE_DIR ${ELPA_INCLUDE_DIRS}) if(NOT TARGET ELPA::ELPA) diff --git a/cmake/FindLibxc.cmake b/cmake/FindLibxc.cmake index 4446b2e7da..23f8689e27 100644 --- a/cmake/FindLibxc.cmake +++ b/cmake/FindLibxc.cmake @@ -13,20 +13,23 @@ # PATH_SUFFIXES "include" "include/elpa" # ) +include(FindPackageHandleStandardArgs) + find_package(PkgConfig) if(PKG_CONFIG_FOUND) - pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc) + pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc) + find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) else() - message( - "LibXC : We need pkg-config to get all information about the libxc library") + find_package(Libxc REQUIRED HINTS + ${Libxc_DIR}/share/cmake/Libxc + ${Libxc_DIR}/lib/cmake/Libxc + ${Libxc_DIR}/lib64/cmake/Libxc + ) + #message( + # "LibXC : We need pkg-config to get all information about the libxc library") endif() -# Handle the QUIET and REQUIRED arguments and -# set ELPA_FOUND to TRUE if all variables are non-zero. -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) - # Copy the results to the output variables and target. if(Libxc_FOUND AND NOT TARGET Libxc::xc) set(Libxc_LIBRARY ${Libxc_LINK_LIBRARIES}) From e8d46c447d62be2c0270b5274088fbed1470cd60 Mon Sep 17 00:00:00 2001 From: yizeyi18 <18586016708@163.com> Date: Fri, 12 Jan 2024 21:04:40 +0800 Subject: [PATCH 03/15] syntax fix for FindELPA.cmake --- cmake/FindELPA.cmake | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/cmake/FindELPA.cmake b/cmake/FindELPA.cmake index 2200d43dc1..a6f5663c22 100644 --- a/cmake/FindELPA.cmake +++ b/cmake/FindELPA.cmake @@ -7,25 +7,6 @@ # ELPA_INCLUDE_DIR - Where to find ELPA headers. # -find_path(ELPA_INCLUDE_DIR - elpa/elpa.h - HINTS ${ELPA_DIR} - PATH_SUFFIXES "include" "include/elpa" - ) -if(USE_OPENMP) - find_library(ELPA_LIBRARY - NAMES elpa_openmp elpa - HINTS ${ELPA_DIR} - PATH_SUFFIXES "lib" - ) -else() - find_library(ELPA_LIBRARY - NAMES elpa - HINTS ${ELPA_DIR} - PATH_SUFFIXES "lib" - ) -endif() - find_package(PkgConfig) if(PKG_CONFIG_FOUND) @@ -41,17 +22,17 @@ else() PATH_SUFFIXES "include" "include/elpa" ) if(USE_OPENMP) - find_library(ELPA_LINK_LIBRARIES - NAMES elpa_openmp elpa - HINTS ${ELPA_DIR} - PATH_SUFFIXES "lib" - ) + find_library(ELPA_LINK_LIBRARIES + NAMES elpa_openmp elpa + HINTS ${ELPA_DIR} + PATH_SUFFIXES "lib" + ) else() - find_library(ELPA_LINK_LIBRARIES - NAMES elpa - HINTS ${ELPA_DIR} - PATH_SUFFIXES "lib" - ) + find_library(ELPA_LINK_LIBRARIES + NAMES elpa + HINTS ${ELPA_DIR} + PATH_SUFFIXES "lib" + ) endif() #message( # "ELPA : We need pkg-config to get all information about the elpa library") From 283b67fe1efb7d501404339f4f1fc24535f4b29b Mon Sep 17 00:00:00 2001 From: YI Zeping <18586016708@163.com> Date: Mon, 15 Jan 2024 14:21:29 +0800 Subject: [PATCH 04/15] Update cmake/FindELPA.cmake Co-authored-by: Chun Cai --- cmake/FindELPA.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindELPA.cmake b/cmake/FindELPA.cmake index a6f5663c22..ec539d8b81 100644 --- a/cmake/FindELPA.cmake +++ b/cmake/FindELPA.cmake @@ -10,7 +10,7 @@ find_package(PkgConfig) if(PKG_CONFIG_FOUND) - if(USE_OPENMP) + if(USE_OPENMP) pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp) else() pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa) From f9e3642d621939aafbcc2a98f1ee70859467dc1a Mon Sep 17 00:00:00 2001 From: yizeyi18 <18586016708@163.com> Date: Mon, 15 Jan 2024 15:04:11 +0800 Subject: [PATCH 05/15] Using CMake interface as default for finding LibXC --- cmake/FindLibxc.cmake | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cmake/FindLibxc.cmake b/cmake/FindLibxc.cmake index 23f8689e27..1bccd7f113 100644 --- a/cmake/FindLibxc.cmake +++ b/cmake/FindLibxc.cmake @@ -17,20 +17,22 @@ include(FindPackageHandleStandardArgs) find_package(PkgConfig) -if(PKG_CONFIG_FOUND) - pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc) - find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) -else() - find_package(Libxc REQUIRED HINTS +# Using CMake interface as default. +# NO REQUIRED here, otherwhile it would throw error +# with no LibXC found. +find_package(Libxc HINTS ${Libxc_DIR}/share/cmake/Libxc ${Libxc_DIR}/lib/cmake/Libxc ${Libxc_DIR}/lib64/cmake/Libxc ) - #message( - # "LibXC : We need pkg-config to get all information about the libxc library") +if(NOT Libxc_FOUND AND PKG_CONFIG_FOUND) + pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc) + find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) endif() # Copy the results to the output variables and target. +# if find_package() above works, Libxc::xc would be present and +# below would be skipped. if(Libxc_FOUND AND NOT TARGET Libxc::xc) set(Libxc_LIBRARY ${Libxc_LINK_LIBRARIES}) set(Libxc_LIBRARIES ${Libxc_LIBRARY}) @@ -39,6 +41,9 @@ if(Libxc_FOUND AND NOT TARGET Libxc::xc) set_target_properties(Libxc::xc PROPERTIES IMPORTED_LOCATION "${Libxc_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${Libxc_INCLUDE_DIR}") +elseif(NOT Libxc_FOUND) + message(FATAL_ERROR + "LibXC : We need pkg-config to get all information about the libxc library") endif() set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Libxc_INCLUDE_DIR}) From 660d3906fa95b1a234463a34111c057dd24af5dd Mon Sep 17 00:00:00 2001 From: yizeyi18 <18586016708@163.com> Date: Mon, 15 Jan 2024 15:47:00 +0800 Subject: [PATCH 06/15] update docs --- cmake/FindELPA.cmake | 3 +++ cmake/FindLibxc.cmake | 9 ++++++--- docs/quick_start/easy_install.md | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/FindELPA.cmake b/cmake/FindELPA.cmake index ec539d8b81..328b75035f 100644 --- a/cmake/FindELPA.cmake +++ b/cmake/FindELPA.cmake @@ -10,6 +10,9 @@ find_package(PkgConfig) if(PKG_CONFIG_FOUND) + if(DEFINED ELPA_DIR) + string(APPEND CMAKE_PREFIX_PATH ";${ELPA_DIR}") + endif() if(USE_OPENMP) pkg_search_module(ELPA REQUIRED IMPORTED_TARGET GLOBAL elpa_openmp) else() diff --git a/cmake/FindLibxc.cmake b/cmake/FindLibxc.cmake index 1bccd7f113..74348a5adc 100644 --- a/cmake/FindLibxc.cmake +++ b/cmake/FindLibxc.cmake @@ -17,6 +17,9 @@ include(FindPackageHandleStandardArgs) find_package(PkgConfig) +if(DEFINED Libxc_DIR) + string(APPEND CMAKE_PREFIX_PATH ";${Libxc_DIR}") +endif() # Using CMake interface as default. # NO REQUIRED here, otherwhile it would throw error # with no LibXC found. @@ -28,6 +31,9 @@ find_package(Libxc HINTS if(NOT Libxc_FOUND AND PKG_CONFIG_FOUND) pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc) find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) +elseif(NOT PKG_CONFIG_FOUND) + message(FATAL_ERROR + "LibXC : We need pkg-config to get all information about the libxc library") endif() # Copy the results to the output variables and target. @@ -41,9 +47,6 @@ if(Libxc_FOUND AND NOT TARGET Libxc::xc) set_target_properties(Libxc::xc PROPERTIES IMPORTED_LOCATION "${Libxc_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${Libxc_INCLUDE_DIR}") -elseif(NOT Libxc_FOUND) - message(FATAL_ERROR - "LibXC : We need pkg-config to get all information about the libxc library") endif() set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Libxc_INCLUDE_DIR}) diff --git a/docs/quick_start/easy_install.md b/docs/quick_start/easy_install.md index 957b9d3262..4bb409495b 100644 --- a/docs/quick_start/easy_install.md +++ b/docs/quick_start/easy_install.md @@ -111,7 +111,7 @@ Here, 'build' is the path for building ABACUS; and '-D' is used for setting up s - `LAPACK_DIR`: Path to OpenBLAS library `libopenblas.so`(including BLAS and LAPACK) - `SCALAPACK_DIR`: Path to ScaLAPACK library `libscalapack.so` - `ELPA_DIR`: Path to ELPA install directory; should be the folder containing 'include' and 'lib'. - > Note: If you install ELPA from source, please add a symlink to avoid the additional include file folder with version name: `ln -s elpa/include/elpa-2021.05.002/elpa elpa/include/elpa`. This is a known behavior of ELPA. + > Note: If you install ELPA from source and have no `pkg-config` installed, please add a symlink to avoid the additional include file folder with version name: `ln -s elpa/include/elpa-2021.05.002/elpa elpa/include/elpa` to help the build system find ELPA headers. - `FFTW3_DIR`: Path to FFTW3. - `CEREAL_INCLUDE_DIR`: Path to the parent folder of `cereal/cereal.hpp`. Will download from GitHub if absent. From 7bd18db5e4e5ceba44857857d4d2206aac29e933 Mon Sep 17 00:00:00 2001 From: yizeyi18 <18586016708@163.com> Date: Mon, 15 Jan 2024 15:51:05 +0800 Subject: [PATCH 07/15] fix for FindLibxc: changing imcompatible if statement --- cmake/FindLibxc.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindLibxc.cmake b/cmake/FindLibxc.cmake index 74348a5adc..0d438a8583 100644 --- a/cmake/FindLibxc.cmake +++ b/cmake/FindLibxc.cmake @@ -28,7 +28,7 @@ find_package(Libxc HINTS ${Libxc_DIR}/lib/cmake/Libxc ${Libxc_DIR}/lib64/cmake/Libxc ) -if(NOT Libxc_FOUND AND PKG_CONFIG_FOUND) +if(NOT TARGET Libxc::xc AND PKG_CONFIG_FOUND) pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc) find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) elseif(NOT PKG_CONFIG_FOUND) From ab0ab5a51003a30e55649190b059d687a0272cdd Mon Sep 17 00:00:00 2001 From: yizeyi18 <18586016708@163.com> Date: Mon, 15 Jan 2024 15:54:22 +0800 Subject: [PATCH 08/15] fix for FindLibxc: changing imcompatible if statement --- cmake/FindLibxc.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindLibxc.cmake b/cmake/FindLibxc.cmake index 0d438a8583..f5494df3d8 100644 --- a/cmake/FindLibxc.cmake +++ b/cmake/FindLibxc.cmake @@ -31,7 +31,7 @@ find_package(Libxc HINTS if(NOT TARGET Libxc::xc AND PKG_CONFIG_FOUND) pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc) find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) -elseif(NOT PKG_CONFIG_FOUND) +elseif(NOT TARGET Libxc::xc NOT PKG_CONFIG_FOUND) message(FATAL_ERROR "LibXC : We need pkg-config to get all information about the libxc library") endif() From f887d41057db9406196f4c93f9e440f4d4fa5919 Mon Sep 17 00:00:00 2001 From: yizeyi18 <18586016708@163.com> Date: Mon, 15 Jan 2024 15:56:00 +0800 Subject: [PATCH 09/15] fix for FindLibxc: changing imcompatible if statement --- cmake/FindLibxc.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindLibxc.cmake b/cmake/FindLibxc.cmake index f5494df3d8..df9d5e5210 100644 --- a/cmake/FindLibxc.cmake +++ b/cmake/FindLibxc.cmake @@ -31,7 +31,7 @@ find_package(Libxc HINTS if(NOT TARGET Libxc::xc AND PKG_CONFIG_FOUND) pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc) find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) -elseif(NOT TARGET Libxc::xc NOT PKG_CONFIG_FOUND) +elseif(NOT TARGET Libxc::xc AND NOT PKG_CONFIG_FOUND) message(FATAL_ERROR "LibXC : We need pkg-config to get all information about the libxc library") endif() From 7cdd7b4749cfeac5dc4f54dfa373be6315aee7b0 Mon Sep 17 00:00:00 2001 From: yizeyi18 <18586016708@163.com> Date: Tue, 16 Jan 2024 15:17:09 +0800 Subject: [PATCH 10/15] update docs for installing pkg-config --- docs/quick_start/easy_install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_start/easy_install.md b/docs/quick_start/easy_install.md index 4bb409495b..cb9c8e0cd4 100644 --- a/docs/quick_start/easy_install.md +++ b/docs/quick_start/easy_install.md @@ -28,7 +28,7 @@ These requirements support the calculation of plane-wave basis in ABACUS. For LC Some of these packages can be installed with popular package management system, such as `apt` and `yum`: ```bash -sudo apt update && sudo apt install -y libopenblas-openmp-dev liblapack-dev libscalapack-mpi-dev libelpa-dev libfftw3-dev libcereal-dev libxc-dev g++ make cmake bc git +sudo apt update && sudo apt install -y libopenblas-openmp-dev liblapack-dev libscalapack-mpi-dev libelpa-dev libfftw3-dev libcereal-dev libxc-dev g++ make cmake bc git pkgconf ``` > Installing ELPA by apt only matches requirements on Ubuntu 22.04. For earlier linux distributions, you should build ELPA from source. From 3ce7ac69de7ae8431410077a32d56e9be4684c75 Mon Sep 17 00:00:00 2001 From: Chun Cai Date: Wed, 17 Jan 2024 11:40:51 +0800 Subject: [PATCH 11/15] Update FindLibxc.cmake --- cmake/FindLibxc.cmake | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/cmake/FindLibxc.cmake b/cmake/FindLibxc.cmake index df9d5e5210..630eb38ead 100644 --- a/cmake/FindLibxc.cmake +++ b/cmake/FindLibxc.cmake @@ -1,22 +1,5 @@ -############################################################################### -# - Find ELPA -# Find the native ELPA headers and libraries. -# -# ELPA_FOUND - True if libelpa is found. -# ELPA_LIBRARIES - List of libraries when using libyaml -# ELPA_INCLUDE_DIR - Where to find ELPA headers. -# - -#find_path(ELPA_INCLUDE_DIR -# elpa/elpa.h -# HINTS ${ELPA_DIR} -# PATH_SUFFIXES "include" "include/elpa" -# ) - include(FindPackageHandleStandardArgs) -find_package(PkgConfig) - if(DEFINED Libxc_DIR) string(APPEND CMAKE_PREFIX_PATH ";${Libxc_DIR}") endif() @@ -28,14 +11,13 @@ find_package(Libxc HINTS ${Libxc_DIR}/lib/cmake/Libxc ${Libxc_DIR}/lib64/cmake/Libxc ) -if(NOT TARGET Libxc::xc AND PKG_CONFIG_FOUND) +if(NOT TARGET Libxc::xc) + find_package(PkgConfig REQUIRED) pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc) - find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) -elseif(NOT TARGET Libxc::xc AND NOT PKG_CONFIG_FOUND) - message(FATAL_ERROR - "LibXC : We need pkg-config to get all information about the libxc library") endif() +find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) + # Copy the results to the output variables and target. # if find_package() above works, Libxc::xc would be present and # below would be skipped. From e8438195b0ea38e0897c1bf6c0f4e46eb3f38bd1 Mon Sep 17 00:00:00 2001 From: Chun Cai Date: Wed, 17 Jan 2024 14:45:03 +0800 Subject: [PATCH 12/15] Update FindLibxc.cmake --- cmake/FindLibxc.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindLibxc.cmake b/cmake/FindLibxc.cmake index 630eb38ead..4a3c04cba7 100644 --- a/cmake/FindLibxc.cmake +++ b/cmake/FindLibxc.cmake @@ -14,9 +14,9 @@ find_package(Libxc HINTS if(NOT TARGET Libxc::xc) find_package(PkgConfig REQUIRED) pkg_search_module(Libxc REQUIRED IMPORTED_TARGET GLOBAL libxc) + find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) endif() -find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_INCLUDE_DIRS) # Copy the results to the output variables and target. # if find_package() above works, Libxc::xc would be present and From 821977decd280ef6a32c5936f7becc5524556e9d Mon Sep 17 00:00:00 2001 From: YI Zeping <18586016708@163.com> Date: Wed, 17 Jan 2024 06:55:37 +0000 Subject: [PATCH 13/15] remove previous LibXC routine in CMakeLists.txt Co-authored-by: Chun Cai --- CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19bd7adeb4..d3db9f529d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -508,11 +508,7 @@ if(DEFINED Libxc_DIR) set(ENABLE_LIBXC ON) endif() if(ENABLE_LIBXC) -# find_package(Libxc REQUIRED HINTS -# ${Libxc_DIR}/share/cmake/Libxc -# ${Libxc_DIR}/lib/cmake/Libxc -# ${Libxc_DIR}/lib64/cmake/Libxc -# ) + # use `cmake/FindLibxc.cmake` to detect Libxc installation with `pkg-config` find_package(Libxc REQUIRED) message(STATUS "Found Libxc: version " ${Libxc_VERSION}) if(${Libxc_VERSION} VERSION_LESS 5.1.7) From a9cbf70d83af005b7a5ccad10af94f32ca360de8 Mon Sep 17 00:00:00 2001 From: YI Zeping <18586016708@163.com> Date: Wed, 17 Jan 2024 07:01:05 +0000 Subject: [PATCH 14/15] Update easy_install.md with Makefile-built LibXC supported --- docs/quick_start/easy_install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_start/easy_install.md b/docs/quick_start/easy_install.md index cb9c8e0cd4..f38d56d229 100644 --- a/docs/quick_start/easy_install.md +++ b/docs/quick_start/easy_install.md @@ -116,7 +116,7 @@ Here, 'build' is the path for building ABACUS; and '-D' is used for setting up s - `FFTW3_DIR`: Path to FFTW3. - `CEREAL_INCLUDE_DIR`: Path to the parent folder of `cereal/cereal.hpp`. Will download from GitHub if absent. - `Libxc_DIR`: (Optional) Path to Libxc. - > Note: Building Libxc from source with Makefile does NOT support using it in CMake here. Please compile Libxc with CMake instead. + > Note: In ABACUS v3.5.1 or earlier, Libxc built from source with Makefile is NOT supported; please compile Libxc with CMake instead. - `LIBRI_DIR`: (Optional) Path to LibRI. - `LIBCOMM_DIR`: (Optional) Path to LibComm. From 3eb0e2fe8d631706aba49a4f44600e5334b7abe7 Mon Sep 17 00:00:00 2001 From: YI Zeping <18586016708@163.com> Date: Wed, 17 Jan 2024 07:15:18 +0000 Subject: [PATCH 15/15] Update easy_install.md to include different behavior in different version on finding ELPA --- docs/quick_start/easy_install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick_start/easy_install.md b/docs/quick_start/easy_install.md index f38d56d229..45adc8e60a 100644 --- a/docs/quick_start/easy_install.md +++ b/docs/quick_start/easy_install.md @@ -111,7 +111,7 @@ Here, 'build' is the path for building ABACUS; and '-D' is used for setting up s - `LAPACK_DIR`: Path to OpenBLAS library `libopenblas.so`(including BLAS and LAPACK) - `SCALAPACK_DIR`: Path to ScaLAPACK library `libscalapack.so` - `ELPA_DIR`: Path to ELPA install directory; should be the folder containing 'include' and 'lib'. - > Note: If you install ELPA from source and have no `pkg-config` installed, please add a symlink to avoid the additional include file folder with version name: `ln -s elpa/include/elpa-2021.05.002/elpa elpa/include/elpa` to help the build system find ELPA headers. + > Note: In ABACUS v3.5.1 or earlier, if you install ELPA from source , please add a symlink to avoid the additional include file folder with version name: `ln -s elpa/include/elpa-2021.05.002/elpa elpa/include/elpa` to help the build system find ELPA headers. - `FFTW3_DIR`: Path to FFTW3. - `CEREAL_INCLUDE_DIR`: Path to the parent folder of `cereal/cereal.hpp`. Will download from GitHub if absent.