Skip to content

Commit 064728a

Browse files
authored
Merge pull request #1173 from caic99/xc
feature: build libxc in the absence of local install
2 parents 89d1231 + a7ea946 commit 064728a

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ if(ENABLE_DEEPKS)
217217
HINTS ${libnpy_INCLUDE_DIR}
218218
)
219219
if(NOT libnpy_SOURCE_DIR)
220-
include(FetchContent)
220+
include(FetchContent)
221221
FetchContent_Declare(
222222
libnpy
223223
GIT_REPOSITORY https://github.com/llohse/libnpy.git
@@ -237,14 +237,22 @@ if(DEFINED Libxc_DIR)
237237
set(ENABLE_LIBXC ON)
238238
endif()
239239
if(ENABLE_LIBXC)
240-
find_package(Libxc)
240+
find_package(Libxc HINTS ${Libxc_DIR}/share/cmake/Libxc)
241241
if(${Libxc_FOUND})
242242
message("Using Libxc.")
243243
add_compile_definitions(USE_LIBXC)
244244
target_link_libraries(${ABACUS_BIN_NAME} Libxc::xc)
245245
include_directories(${Libxc_INCLUDE_DIRS})
246246
else()
247-
message(WARNING "Will not use Libxc.")
247+
include(FetchContent)
248+
FetchContent_Declare(
249+
Libxc
250+
GIT_REPOSITORY https://gitlab.com/libxc/libxc.git
251+
GIT_TAG "5.2.3"
252+
GIT_SHALLOW TRUE
253+
GIT_PROGRESS TRUE
254+
)
255+
FetchContent_MakeAvailable(Libxc)
248256
endif()
249257
endif()
250258

@@ -319,7 +327,7 @@ target_link_libraries(${ABACUS_BIN_NAME}
319327
pw
320328
ri
321329
driver
322-
xc
330+
xc_
323331
hsolver
324332
elecstate
325333
hamilt

docs/install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ cmake -B build -DFFTW3_ROOT=/opt/fftw3
9595

9696
If environment variable `MKLROOT` exists, `cmake` will take MKL as a preference, i.e. not using `LAPACK` and `ScaLAPACK`. To disable MKL, unset environment variable `MKLROOT`, or pass `-DMKLROOT=OFF` to `cmake`.
9797

98-
You can also choose to build with which components.
98+
You can also choose to build with which components, e.g.:
9999

100100
```bash
101101
cmake -B build -DUSE_LIBXC=1 -DUSE_CUDA=1
102102
```
103103

104-
If Libxc is not installed in standard path (i.e. installed with a custom prefix path), you may add the installation prefix of `FindLibxc.cmake` to `CMAKE_MODULE_PATH` environment variable, or set `Libxc_DIR` to the directory containing the file.
104+
If Libxc is not installed in standard path (i.e. installed with a custom prefix path), you can set `Libxc_DIR` to the corresponding directory.
105105

106106
```bash
107107
cmake -B build -DLibxc_DIR=~/libxc

source/module_deepks/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ add_executable(
66
get_target_property(ABACUS_LINK_LIBRARIES ${ABACUS_BIN_NAME} LINK_LIBRARIES)
77
target_link_libraries(
88
test_deepks
9-
base cell symmetry md surchem xc
9+
base cell symmetry md surchem xc_
1010
neighbor orb io ions gint lcao parallel mrrr pdiag pw ri driver esolver hsolver psi elecstate hamilt planewave
1111
pthread
1212
deepks

source/module_xc/CMakeLists.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
list(APPEND objects
1+
add_library(
2+
xc_
3+
OBJECT
24
xc_functional.cpp
35
xc_functional_vxc.cpp
46
xc_functional_gradcorr.cpp
@@ -10,14 +12,8 @@ list(APPEND objects
1012
xc_funct_exch_gga.cpp
1113
xc_funct_corr_gga.cpp
1214
xc_funct_hcth.cpp
13-
)
14-
15-
add_library(
16-
xc
17-
OBJECT
18-
${objects}
1915
)
2016

2117
IF (BUILD_TESTING)
2218
add_subdirectory(test)
23-
endif()
19+
endif()

0 commit comments

Comments
 (0)