From ff35793769bbe3c21ac5aba7e5e521976d99fea1 Mon Sep 17 00:00:00 2001 From: Growl Date: Sun, 7 Jun 2026 23:07:55 +0800 Subject: [PATCH 1/3] Toolchain: Rely on installed CMake config file for Cereal and RapidJSON --- .github/workflows/ase_plugin_test.yml | 13 +++++++++ .github/workflows/build_test_cmake.yml | 21 ++++++++++++++ .github/workflows/build_test_makefile.yml | 4 +++ .github/workflows/coverage.yml | 15 +++++++++- .github/workflows/cuda.yml | 14 ++++++++- .github/workflows/devcontainer.yml | 4 +++ .github/workflows/doxygen.yml | 4 +++ .github/workflows/dynamic.yml | 12 ++++++++ .github/workflows/interface.yml | 4 +++ .github/workflows/mirror_gitee.yml | 4 +++ .github/workflows/performance.yml | 4 +++ .github/workflows/pytest.yml | 4 +++ .github/workflows/test.yml | 4 +-- .github/workflows/toolchain_full.yaml | 5 ++++ .github/workflows/toolchain_quick.yaml | 5 ++++ .github/workflows/version_check.yml | 6 +++- CMakeLists.txt | 27 ++--------------- cmake/FindCereal.cmake | 29 ------------------- .../source_io/module_json/test/CMakeLists.txt | 5 ++-- toolchain/build_abacus_gcc-aocl.sh | 4 --- toolchain/build_abacus_gcc-mkl.sh | 4 --- toolchain/build_abacus_gnu.sh | 4 --- toolchain/build_abacus_intel.sh | 4 --- .../install_requirements_fedora.sh | 1 + .../install_requirements_ubuntu.sh | 1 + toolchain/scripts/stage4/install_cereal.sh | 17 ++++++++--- toolchain/scripts/stage4/install_rapidjson.sh | 18 ++++++------ 27 files changed, 146 insertions(+), 91 deletions(-) delete mode 100644 cmake/FindCereal.cmake diff --git a/.github/workflows/ase_plugin_test.yml b/.github/workflows/ase_plugin_test.yml index 856a26a953d..b9f8de0b948 100644 --- a/.github/workflows/ase_plugin_test.yml +++ b/.github/workflows/ase_plugin_test.yml @@ -3,6 +3,10 @@ name: Atomic Simulation Environment (ASE) Plugin Test on: pull_request: +defaults: + run: + shell: bash + jobs: test: name: abacuslite @@ -33,6 +37,14 @@ jobs: cd interfaces/ASE_interface pip install . + - name: Install external tools from toolchain + run: | + apt update && apt install -y xz-utils + cd toolchain + ./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run -j8 + ./scripts/stage4/install_stage4.sh + cd .. + - name: Configure & Build ABACUS (GNU) run: | git config --global --add safe.directory `pwd` @@ -40,6 +52,7 @@ jobs: export PKG_CONFIG_PATH=${GKLIB_ROOT}/lib/pkgconfig:${METIS32_ROOT}/lib/pkgconfig:${PARMETIS32_ROOT}/lib/pkgconfig:${SUPERLU32_DIST_ROOT}/lib/pkgconfig:${PEXSI32_ROOT}/lib/pkgconfig:${PKG_CONFIG_PATH} export CPATH=${GKLIB_ROOT}/include:${METIS32_ROOT}/include:${PARMETIS32_ROOT}/include:${SUPERLU32_DIST_ROOT}/include:${PEXSI32_ROOT}/include:${CPATH} export CMAKE_PREFIX_PATH=${PEXSI32_ROOT}:${SUPERLU_DIST32_ROOT}:${PARMETIS32_ROOT}:${METIS32_ROOT}:${GKLIB_ROOT}:${CMAKE_PREFIX_PATH} + source toolchain/install/setup rm -rf build cmake -B build cmake --build build -j2 diff --git a/.github/workflows/build_test_cmake.yml b/.github/workflows/build_test_cmake.yml index 8296f7bc9f4..0f17e52b95b 100644 --- a/.github/workflows/build_test_cmake.yml +++ b/.github/workflows/build_test_cmake.yml @@ -3,6 +3,10 @@ on: push: pull_request: +defaults: + run: + shell: bash + jobs: test: runs-on: ubuntu-latest @@ -13,29 +17,37 @@ jobs: build_args: "" name: "Build with GNU toolchain" - tag: intel + external_toolchain_args: "--with-intel" build_args: "" name: "Build with Intel toolchain" - tag: gnu + external_toolchain_args: "" build_args: "-DENABLE_LIBXC=1 -DENABLE_MLALGO=1 -DENABLE_LIBRI=1" name: "Build extra components with GNU toolchain" - tag: intel + external_toolchain_args: "--with-intel" build_args: "-DENABLE_LIBXC=1 -DENABLE_PEXSI=1 -DENABLE_MLALGO=1 -DENABLE_LIBRI=1" name: "Build extra components with Intel toolchain" - tag: cuda + external_toolchain_args: "" build_args: "-DUSE_CUDA=1" name: "Build with CUDA support" - tag: gnu + external_toolchain_args: "" build_args: "-DENABLE_LCAO=0" name: "Build without LCAO" - tag: gnu + external_toolchain_args: "" build_args: "-DUSE_ELPA=0 " name: "Build without ELPA" - tag: gnu + external_toolchain_args: "" build_args: "-DENABLE_MPI=0" name: "Build without MPI" - tag: gnu + external_toolchain_args: "" build_args: "-DENABLE_MPI=0 -DENABLE_LCAO=0" name: "Build without LCAO and MPI" @@ -47,6 +59,14 @@ jobs: with: submodules: recursive + - name: Install external tools from toolchain + run: | + apt update && apt install -y gfortran xz-utils + cd toolchain + ./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run ${{matrix.external_toolchain_args}} + ./scripts/stage4/install_stage4.sh + cd .. + - name: Build run: | git config --global --add safe.directory `pwd` @@ -54,6 +74,7 @@ jobs: export PKG_CONFIG_PATH=${GKLIB_ROOT}/lib/pkgconfig:${METIS32_ROOT}/lib/pkgconfig:${PARMETIS32_ROOT}/lib/pkgconfig:${SUPERLU32_DIST_ROOT}/lib/pkgconfig:${PEXSI32_ROOT}/lib/pkgconfig:${PKG_CONFIG_PATH} export CPATH=${GKLIB_ROOT}/include:${METIS32_ROOT}/include:${PARMETIS32_ROOT}/include:${SUPERLU32_DIST_ROOT}/include:${PEXSI32_ROOT}/include:${CPATH} export CMAKE_PREFIX_PATH=${PEXSI32_ROOT}:${SUPERLU_DIST32_ROOT}:${PARMETIS32_ROOT}:${METIS32_ROOT}:${GKLIB_ROOT}:${CMAKE_PREFIX_PATH} + source toolchain/install/setup rm -rf build cmake -B build ${{ matrix.build_args }} cmake --build build -j2 diff --git a/.github/workflows/build_test_makefile.yml b/.github/workflows/build_test_makefile.yml index b0cabbce97c..d0cbdd99404 100644 --- a/.github/workflows/build_test_makefile.yml +++ b/.github/workflows/build_test_makefile.yml @@ -3,6 +3,10 @@ on: push: pull_request: +defaults: + run: + shell: bash + jobs: test: runs-on: ubuntu-latest diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index a80032e02d9..50ab3341af3 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -5,6 +5,11 @@ on: push: tags: - 'v*' + +defaults: + run: + shell: bash + jobs: test-coverage: name: Generate Coverage Report @@ -18,13 +23,21 @@ jobs: - name: Install Perl Dependencies and Coverage Tools run: | - apt update && apt install -y curl jq ca-certificates python3-pip + apt update && apt install -y curl jq ca-certificates python3-pip xz-utils apt install -y lcov perl-modules apt install -y libcapture-tiny-perl libdatetime-perl libjson-perl libperlio-gzip-perl lcov --version + - name: Install external tools from toolchain + run: | + cd toolchain + ./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run -j8 + ./scripts/stage4/install_stage4.sh + cd .. + - name: Building with Coverage run: | + source toolchain/install/setup rm -rf build/ rm -f CMakeCache.txt diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index 7c30bcf6463..834704021e2 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -4,6 +4,10 @@ on: workflow_dispatch: pull_request: +defaults: + run: + shell: bash + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -28,11 +32,19 @@ jobs: - name: Install Ccache run: | sudo apt-get update - sudo apt-get install -y ccache + sudo apt-get install -y ccache xz-utils + + - name: Install external tools from toolchain + run: | + cd toolchain + ./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run -j8 + ./scripts/stage4/install_stage4.sh + cd .. - name: Configure & Build run: | nvidia-smi + source toolchain/install/setup rm -rf build cmake -B build -DUSE_CUDA=ON -DBUILD_TESTING=ON cmake --build build -j4 diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index 6df6d72305e..edb701fb29e 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -9,6 +9,10 @@ on: - 'v*' workflow_dispatch: +defaults: + run: + shell: bash + jobs: build_container_and_push: runs-on: X64 diff --git a/.github/workflows/doxygen.yml b/.github/workflows/doxygen.yml index ff262e70d4d..d2f5ddbee2c 100644 --- a/.github/workflows/doxygen.yml +++ b/.github/workflows/doxygen.yml @@ -10,6 +10,10 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: +defaults: + run: + shell: bash + # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read diff --git a/.github/workflows/dynamic.yml b/.github/workflows/dynamic.yml index e25b358a671..3dba0d11b6d 100644 --- a/.github/workflows/dynamic.yml +++ b/.github/workflows/dynamic.yml @@ -5,6 +5,10 @@ on: - cron: '0 16 * * 0' workflow_dispatch: +defaults: + run: + shell: bash + jobs: test: name: Dynamic analysis @@ -14,8 +18,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v6 + - name: Install external tools from toolchain + run: | + apt update && apt install -y xz-utils + cd toolchain + ./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run -j8 + ./scripts/stage4/install_stage4.sh + cd .. - name: Building run: | + source toolchain/install/setup cmake -B build -DENABLE_ASAN=1 -DENABLE_MLALGO=1 -DENABLE_LIBXC=1 cmake --build build -j8 cmake --install build diff --git a/.github/workflows/interface.yml b/.github/workflows/interface.yml index d8e90c0c075..d0c898ad39e 100644 --- a/.github/workflows/interface.yml +++ b/.github/workflows/interface.yml @@ -3,6 +3,10 @@ name: interface on: workflow_dispatch: +defaults: + run: + shell: bash + jobs: wannier-interface: name: "wannier interface — ${{ matrix.name }}" diff --git a/.github/workflows/mirror_gitee.yml b/.github/workflows/mirror_gitee.yml index 6546a12e3e5..cbfd599cb1b 100644 --- a/.github/workflows/mirror_gitee.yml +++ b/.github/workflows/mirror_gitee.yml @@ -2,6 +2,10 @@ name: Mirror to Gitee Repository on: [ push, delete, create ] +defaults: + run: + shell: bash + # Ensures that only one mirror task will run at a time. concurrency: group: git-mirror diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 9312caefe8c..c06a8d6246d 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -3,6 +3,10 @@ name: Performance test on: workflow_dispatch: +defaults: + run: + shell: bash + jobs: test: name: Performance test diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 23c1074b75e..00662e16f52 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -3,6 +3,10 @@ name: Pyabacus Build and Test on: pull_request: +defaults: + run: + shell: bash + jobs: test: name: PyTest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3c71534aa81..7ba35601031 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,11 +39,11 @@ jobs: sudo apt-get install -y gfortran ccache ca-certificates python-is-python3 python3-pip sudo pip install clang-format clang-tidy - - name: Install dftd4 from toolchain + - name: Install external tools from toolchain run: | cd toolchain ./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run -j8 - ./scripts/stage4/install_dftd4.sh + ./scripts/stage4/install_stage4.sh cd .. - name: Configure diff --git a/.github/workflows/toolchain_full.yaml b/.github/workflows/toolchain_full.yaml index 3793b22eafb..f1a0cf855e1 100644 --- a/.github/workflows/toolchain_full.yaml +++ b/.github/workflows/toolchain_full.yaml @@ -8,6 +8,11 @@ on: description: "Comma-separated variants: gnu,intel,cuda" required: false default: "gnu,intel,cuda" + +defaults: + run: + shell: bash + jobs: full-build-gnu: if: contains(inputs.variants || 'gnu,intel,cuda', 'gnu') diff --git a/.github/workflows/toolchain_quick.yaml b/.github/workflows/toolchain_quick.yaml index 3c2b58a8106..bf4a01b1b08 100644 --- a/.github/workflows/toolchain_quick.yaml +++ b/.github/workflows/toolchain_quick.yaml @@ -11,6 +11,11 @@ on: - toolchain/** - .github/workflows/toolchain_quick.yaml workflow_dispatch: + +defaults: + run: + shell: bash + jobs: lint-and-sanity: runs-on: ubuntu-latest diff --git a/.github/workflows/version_check.yml b/.github/workflows/version_check.yml index 6062ccc643d..937529da343 100644 --- a/.github/workflows/version_check.yml +++ b/.github/workflows/version_check.yml @@ -3,6 +3,10 @@ on: release: types: [published] +defaults: + run: + shell: bash + jobs: validate_version: runs-on: ubuntu-latest @@ -42,4 +46,4 @@ jobs: if [[ "${{ steps.versions.outputs.prev_tag}}" == "${{ steps.versions.outputs.current_tag }}" ]]; then echo "::error::Version unchanged: ${{ steps.versions.outputs.current_tag }}" exit 1 - fi \ No newline at end of file + fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f3f511331f..44434a4107b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,29 +63,8 @@ endif() # enable json support if(ENABLE_RAPIDJSON) - find_package(RapidJSON) - if(NOT RapidJSON_FOUND) - message( - WARNING - "Rapidjson is not found, trying downloading from github, or you can install Rapidjson first and reinstall abacus." - ) - include(FetchContent) - FetchContent_Declare( - rapidjson - URL https://codeload.github.com/Tencent/rapidjson/tar.gz/24b5e7a - ) - set(RAPIDJSON_BUILD_TESTS - OFF - CACHE INTERNAL "") - set(RAPIDJSON_BUILD_EXAMPLES - OFF - CACHE INTERNAL "") - FetchContent_MakeAvailable(rapidjson) - endif() - set(RapidJSON_INCLUDE_PATH "${rapidjson_SOURCE_DIR}/include") + find_package(RapidJSON REQUIRED) add_compile_definitions(__RAPIDJSON) - add_definitions(-DRAPIDJSON_HAS_CXX11_NOEXCEPT=0) - include_directories(${RapidJSON_INCLUDE_PATH}) endif() # get commit info @@ -311,9 +290,7 @@ if(WIN32) endif() if(ENABLE_LCAO) - find_package(Cereal REQUIRED) - include_directories(${CEREAL_INCLUDE_DIR}) - add_compile_definitions(USE_CEREAL_SERIALIZATION) + find_package(cereal REQUIRED) add_compile_definitions(__LCAO) if(USE_ELPA) find_package(ELPA REQUIRED) diff --git a/cmake/FindCereal.cmake b/cmake/FindCereal.cmake deleted file mode 100644 index 204a1233f24..00000000000 --- a/cmake/FindCereal.cmake +++ /dev/null @@ -1,29 +0,0 @@ -############################################################################### -# - Find cereal -# Find the native cereal headers. -# -# CEREAL_FOUND - True if cereal is found. -# CEREAL_INCLUDE_DIR - Where to find cereal headers. - -find_path(CEREAL_INCLUDE_DIR - cereal/cereal.hpp - HINTS ${CEREAL_INCLUDE_DIR} - HINTS ${Cereal_INCLUDE_DIR} -) - -if(NOT CEREAL_INCLUDE_DIR) - include(FetchContent) - FetchContent_Declare( - cereal - URL https://codeload.github.com/USCiLab/cereal/tar.gz/22a1b36 - ) - FetchContent_Populate(cereal) - set(CEREAL_INCLUDE_DIR ${cereal_SOURCE_DIR}/include) -endif() -# Handle the QUIET and REQUIRED arguments and -# set Cereal_FOUND to TRUE if all variables are non-zero. -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Cereal DEFAULT_MSG CEREAL_INCLUDE_DIR) - -# Copy the results to the output variables and target. -mark_as_advanced(CEREAL_INCLUDE_DIR) diff --git a/source/source_io/module_json/test/CMakeLists.txt b/source/source_io/module_json/test/CMakeLists.txt index 288009206ee..ea973b4a909 100644 --- a/source/source_io/module_json/test/CMakeLists.txt +++ b/source/source_io/module_json/test/CMakeLists.txt @@ -5,7 +5,6 @@ remove_definitions(-D__EXX) AddTest( TARGET MODULE_IO_JSON_OUTPUT_TEST - LIBS parameter ${math_libs} base device cell_info - SOURCES para_json_test.cpp ../general_info.cpp ../init_info.cpp ../readin_info.cpp - ../para_json.cpp ../abacusjson.cpp ../../module_output/output.cpp + LIBS parameter ${math_libs} base device cell_info json_output + SOURCES para_json_test.cpp ../para_json.cpp ../../module_output/output.cpp ) diff --git a/toolchain/build_abacus_gcc-aocl.sh b/toolchain/build_abacus_gcc-aocl.sh index 174cfafd33d..47b7d51f69b 100755 --- a/toolchain/build_abacus_gcc-aocl.sh +++ b/toolchain/build_abacus_gcc-aocl.sh @@ -23,9 +23,7 @@ rm -rf $BUILD_DIR PREFIX=$ABACUS_DIR ELPA=${ELPA_ROOT} -CEREAL=${CEREAL_ROOT}/include LIBXC=${LIBXC_ROOT} -RAPIDJSON=${RAPIDJSON_ROOT} LAPACK=$AOCLhome/lib SCALAPACK=$AOCLhome/lib FFTW3=$AOCLhome @@ -68,14 +66,12 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DSCALAPACK_DIR=$SCALAPACK \ -DFFTW3_DIR=$FFTW3 \ -DELPA_DIR=$ELPA \ - -DCEREAL_INCLUDE_DIR=$CEREAL \ -DLibxc_DIR=$LIBXC \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ -DUSE_OPENMP=ON \ -DUSE_ELPA=ON \ -DENABLE_RAPIDJSON=ON \ - -DRapidJSON_DIR=$RAPIDJSON \ -DENABLE_LIBRI=ON \ -DLIBRI_DIR=$LIBRI \ -DLIBCOMM_DIR=$LIBCOMM \ diff --git a/toolchain/build_abacus_gcc-mkl.sh b/toolchain/build_abacus_gcc-mkl.sh index df71a0d65ff..ffedc126874 100755 --- a/toolchain/build_abacus_gcc-mkl.sh +++ b/toolchain/build_abacus_gcc-mkl.sh @@ -23,9 +23,7 @@ rm -rf $BUILD_DIR PREFIX=$ABACUS_DIR ELPA=${ELPA_ROOT} -CEREAL=${CEREAL_ROOT}/include LIBXC=${LIBXC_ROOT} -RAPIDJSON=${RAPIDJSON_ROOT} LIBRI=${LIBRI_ROOT} LIBCOMM=${LIBCOMM_ROOT} USE_CUDA=OFF # set ON to enable gpu-abacus @@ -64,7 +62,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DMKLROOT=$MKLROOT \ -DENABLE_FLOAT_FFTW=ON \ -DELPA_DIR=$ELPA \ - -DCEREAL_INCLUDE_DIR=$CEREAL \ -DLibxc_DIR=$LIBXC \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ @@ -72,7 +69,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DUSE_ELPA=ON \ -DENABLE_DFTD4=ON \ -DENABLE_RAPIDJSON=ON \ - -DRapidJSON_DIR=$RAPIDJSON \ -DENABLE_LIBRI=ON \ -DLIBRI_DIR=$LIBRI \ -DLIBCOMM_DIR=$LIBCOMM \ diff --git a/toolchain/build_abacus_gnu.sh b/toolchain/build_abacus_gnu.sh index f621fbe2cc0..ede19a0d6de 100755 --- a/toolchain/build_abacus_gnu.sh +++ b/toolchain/build_abacus_gnu.sh @@ -24,9 +24,7 @@ LAPACK=${OPENBLAS_ROOT}/lib SCALAPACK=${SCALAPACK_ROOT}/lib ELPA=${ELPA_ROOT} FFTW3=${FFTW_ROOT} -CEREAL=${CEREAL_ROOT}/include LIBXC=${LIBXC_ROOT} -RAPIDJSON=${RAPIDJSON_ROOT} LIBRI=${LIBRI_ROOT} LIBCOMM=${LIBCOMM_ROOT} USE_CUDA=OFF # set ON to enable gpu-abacus @@ -66,7 +64,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DSCALAPACK_DIR=$SCALAPACK \ -DELPA_DIR=$ELPA \ -DFFTW3_DIR=$FFTW3 \ - -DCEREAL_INCLUDE_DIR=$CEREAL \ -DLibxc_DIR=$LIBXC \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ @@ -74,7 +71,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DUSE_ELPA=ON \ -DENABLE_DFTD4=ON \ -DENABLE_RAPIDJSON=ON \ - -DRapidJSON_DIR=$RAPIDJSON \ -DENABLE_LIBRI=ON \ -DLIBRI_DIR=$LIBRI \ -DLIBCOMM_DIR=$LIBCOMM \ diff --git a/toolchain/build_abacus_intel.sh b/toolchain/build_abacus_intel.sh index f034988522a..a047d0449cd 100755 --- a/toolchain/build_abacus_intel.sh +++ b/toolchain/build_abacus_intel.sh @@ -23,9 +23,7 @@ rm -rf $BUILD_DIR PREFIX=$ABACUS_DIR ELPA=${ELPA_ROOT} -CEREAL=${CEREAL_ROOT}/include LIBXC=${LIBXC_ROOT} -RAPIDJSON=${RAPIDJSON_ROOT} LIBRI=${LIBRI_ROOT} LIBCOMM=${LIBCOMM_ROOT} USE_CUDA=OFF # set ON to enable gpu-abacus @@ -65,7 +63,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DMKLROOT=$MKLROOT \ -DENABLE_FLOAT_FFTW=ON \ -DELPA_DIR=$ELPA \ - -DCEREAL_INCLUDE_DIR=$CEREAL \ -DLibxc_DIR=$LIBXC \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ @@ -73,7 +70,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DUSE_ELPA=ON \ -DENABLE_DFTD4=ON \ -DENABLE_RAPIDJSON=ON \ - -DRapidJSON_DIR=$RAPIDJSON \ -DENABLE_LIBRI=ON \ -DLIBRI_DIR=$LIBRI \ -DLIBCOMM_DIR=$LIBCOMM \ diff --git a/toolchain/root_requirements/install_requirements_fedora.sh b/toolchain/root_requirements/install_requirements_fedora.sh index 71b531ed73e..5b712f0965a 100755 --- a/toolchain/root_requirements/install_requirements_fedora.sh +++ b/toolchain/root_requirements/install_requirements_fedora.sh @@ -28,6 +28,7 @@ dnf -qy install \ vim-common \ wget \ which \ + xz \ zlib-devel \ zlib-static diff --git a/toolchain/root_requirements/install_requirements_ubuntu.sh b/toolchain/root_requirements/install_requirements_ubuntu.sh index 8f97db1ec50..db372516f86 100755 --- a/toolchain/root_requirements/install_requirements_ubuntu.sh +++ b/toolchain/root_requirements/install_requirements_ubuntu.sh @@ -32,6 +32,7 @@ apt-get install -qq --no-install-recommends \ unzip \ wget \ xxd \ + xz-utils \ zlib1g-dev rm -rf /var/lib/apt/lists/* diff --git a/toolchain/scripts/stage4/install_cereal.sh b/toolchain/scripts/stage4/install_cereal.sh index 54ee3d6e8bc..7bfd22ba518 100755 --- a/toolchain/scripts/stage4/install_cereal.sh +++ b/toolchain/scripts/stage4/install_cereal.sh @@ -66,10 +66,20 @@ case "$with_cereal" in echo "Installing from scratch into ${pkg_install_dir}" [ -d $dirname ] && rm -rf $dirname tar -xzf $filename - cd "${BUILDDIR}" + cd "${dirname}" # - mkdir -p "${pkg_install_dir}" - cp -r $dirname/* "${pkg_install_dir}/" + mkdir build && cd build + cmake \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DBUILD_DOC=OFF \ + -DBUILD_SANDBOX=OFF \ + -DBUILD_TESTS=OFF \ + -DTHREAD_SAFE=ON \ + -DSKIP_PORTABILITY_TEST=ON \ + -DSKIP_PERFORMANCE_COMPARISON=ON \ + .. > cmake.log 2>&1 || tail -n ${LOG_LINES} cmake.log + make install -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" fi CEREAL_CFLAGS="-I'${pkg_install_dir}/include'" @@ -106,7 +116,6 @@ esac if [ "$with_cereal" != "__DONTUSE__" ]; then if [ "$with_cereal" != "__SYSTEM__" ]; then cat << EOF > "${BUILDDIR}/setup_cereal" -prepend_path CPATH "${pkg_install_dir}/include" prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}" EOF fi diff --git a/toolchain/scripts/stage4/install_rapidjson.sh b/toolchain/scripts/stage4/install_rapidjson.sh index 2ee5eb0467e..fd520b2571f 100755 --- a/toolchain/scripts/stage4/install_rapidjson.sh +++ b/toolchain/scripts/stage4/install_rapidjson.sh @@ -69,14 +69,15 @@ case "$with_rapidjson" in [ -d $dirname ] && rm -rf $dirname tar -xzf $filename #unzip -q $filename - mkdir -p "${pkg_install_dir}" - cp -r $dirname/* "${pkg_install_dir}/" - # for rapidjson found in cmake - cat << EOF > "${pkg_install_dir}/RapidJSONConfig.cmake" -get_filename_component(RAPIDJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -set(RAPIDJSON_INCLUDE_DIRS "@INCLUDE_INSTALL_DIR@") -message(STATUS "RapidJSON found. Headers: ${RAPIDJSON_INCLUDE_DIRS}") -EOF + cd "${dirname}" + mkdir build && cd build + cmake \ + -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DRAPIDJSON_BUILD_DOC=OFF \ + -DRAPIDJSON_BUILD_EXAMPLES=OFF \ + -DRAPIDJSON_BUILD_TESTS=OFF \ + .. > cmake.log 2>&1 || tail -n ${LOG_LINES} cmake.log + make install -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" fi RAPIDJSON_CFLAGS="-I'${pkg_install_dir}/include'" @@ -113,7 +114,6 @@ esac if [ "$with_rapidjson" != "__DONTUSE__" ]; then if [ "$with_rapidjson" != "__SYSTEM__" ]; then cat << EOF > "${BUILDDIR}/setup_rapidjson" -prepend_path CPATH "${pkg_install_dir}/include" prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}" EOF fi From 833f30e74867668df95056c4f4e1913dfca728fe Mon Sep 17 00:00:00 2001 From: Growl Date: Mon, 8 Jun 2026 01:26:43 +0800 Subject: [PATCH 2/3] Remove FindLibxc.cmake --- CMakeLists.txt | 5 --- cmake/FindLibxc.cmake | 39 ------------------- toolchain/build_abacus_aocc-aocl.sh | 2 - toolchain/build_abacus_gcc-aocl.sh | 2 - toolchain/build_abacus_gcc-mkl.sh | 2 - toolchain/build_abacus_gnu.sh | 2 - toolchain/build_abacus_intel.sh | 2 - toolchain/scripts/stage4/install_cereal.sh | 1 + toolchain/scripts/stage4/install_rapidjson.sh | 1 + 9 files changed, 2 insertions(+), 54 deletions(-) delete mode 100644 cmake/FindLibxc.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 44434a4107b..0761115871e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -750,18 +750,13 @@ if(ENABLE_LIBCOMM) endif() -if(DEFINED Libxc_DIR) - set(ENABLE_LIBXC ON) -endif() if(ENABLE_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) message(FATAL_ERROR "LibXC >= 5.1.7 is required.") endif() target_link_libraries(${ABACUS_BIN_NAME} Libxc::xc) - include_directories(${Libxc_INCLUDE_DIRS}) add_compile_definitions(USE_LIBXC) endif() diff --git a/cmake/FindLibxc.cmake b/cmake/FindLibxc.cmake deleted file mode 100644 index 18a0ace4a3d..00000000000 --- a/cmake/FindLibxc.cmake +++ /dev/null @@ -1,39 +0,0 @@ -include(FindPackageHandleStandardArgs) - -if(DEFINED Libxc_DIR) - string(APPEND CMAKE_PREFIX_PATH ";${Libxc_DIR}") -endif() -# Using pkg-config interface as default, to -# avoid linking to wrong global visible Libxc instead of -# specified one. -# NO REQUIRED here, otherwhile it would throw error -# with no LibXC found. -find_package(PkgConfig) -if(PKG_CONFIG_FOUND) - pkg_search_module(Libxc IMPORTED_TARGET GLOBAL libxc) - find_package_handle_standard_args(Libxc DEFAULT_MSG Libxc_LINK_LIBRARIES Libxc_FOUND) -endif() -if(NOT Libxc_FOUND) - find_package(Libxc REQUIRED HINTS - ${Libxc_DIR}/share/cmake/Libxc - ${Libxc_DIR}/lib/cmake/Libxc - ${Libxc_DIR}/lib64/cmake/Libxc - ) -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}) - 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) diff --git a/toolchain/build_abacus_aocc-aocl.sh b/toolchain/build_abacus_aocc-aocl.sh index 07e086e3fe3..b32295bf119 100755 --- a/toolchain/build_abacus_aocc-aocl.sh +++ b/toolchain/build_abacus_aocc-aocl.sh @@ -24,7 +24,6 @@ rm -rf $BUILD_DIR PREFIX=$ABACUS_DIR ELPA=${ELPA_ROOT} CEREAL=${CEREAL_ROOT}/include -LIBXC=${LIBXC_ROOT} RAPIDJSON=${RAPIDJSON_ROOT} LAPACK=$AOCLhome/lib SCALAPACK=$AOCLhome/lib @@ -71,7 +70,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DFFTW3_DIR=$FFTW3 \ -DELPA_DIR=$ELPA \ -DCEREAL_INCLUDE_DIR=$CEREAL \ - -DLibxc_DIR=$LIBXC \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ -DUSE_OPENMP=ON \ diff --git a/toolchain/build_abacus_gcc-aocl.sh b/toolchain/build_abacus_gcc-aocl.sh index 47b7d51f69b..fe7397f0543 100755 --- a/toolchain/build_abacus_gcc-aocl.sh +++ b/toolchain/build_abacus_gcc-aocl.sh @@ -23,7 +23,6 @@ rm -rf $BUILD_DIR PREFIX=$ABACUS_DIR ELPA=${ELPA_ROOT} -LIBXC=${LIBXC_ROOT} LAPACK=$AOCLhome/lib SCALAPACK=$AOCLhome/lib FFTW3=$AOCLhome @@ -66,7 +65,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DSCALAPACK_DIR=$SCALAPACK \ -DFFTW3_DIR=$FFTW3 \ -DELPA_DIR=$ELPA \ - -DLibxc_DIR=$LIBXC \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ -DUSE_OPENMP=ON \ diff --git a/toolchain/build_abacus_gcc-mkl.sh b/toolchain/build_abacus_gcc-mkl.sh index ffedc126874..db6f104351f 100755 --- a/toolchain/build_abacus_gcc-mkl.sh +++ b/toolchain/build_abacus_gcc-mkl.sh @@ -23,7 +23,6 @@ rm -rf $BUILD_DIR PREFIX=$ABACUS_DIR ELPA=${ELPA_ROOT} -LIBXC=${LIBXC_ROOT} LIBRI=${LIBRI_ROOT} LIBCOMM=${LIBCOMM_ROOT} USE_CUDA=OFF # set ON to enable gpu-abacus @@ -62,7 +61,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DMKLROOT=$MKLROOT \ -DENABLE_FLOAT_FFTW=ON \ -DELPA_DIR=$ELPA \ - -DLibxc_DIR=$LIBXC \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ -DUSE_OPENMP=ON \ diff --git a/toolchain/build_abacus_gnu.sh b/toolchain/build_abacus_gnu.sh index ede19a0d6de..11eebdd17b3 100755 --- a/toolchain/build_abacus_gnu.sh +++ b/toolchain/build_abacus_gnu.sh @@ -24,7 +24,6 @@ LAPACK=${OPENBLAS_ROOT}/lib SCALAPACK=${SCALAPACK_ROOT}/lib ELPA=${ELPA_ROOT} FFTW3=${FFTW_ROOT} -LIBXC=${LIBXC_ROOT} LIBRI=${LIBRI_ROOT} LIBCOMM=${LIBCOMM_ROOT} USE_CUDA=OFF # set ON to enable gpu-abacus @@ -64,7 +63,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DSCALAPACK_DIR=$SCALAPACK \ -DELPA_DIR=$ELPA \ -DFFTW3_DIR=$FFTW3 \ - -DLibxc_DIR=$LIBXC \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ -DUSE_OPENMP=ON \ diff --git a/toolchain/build_abacus_intel.sh b/toolchain/build_abacus_intel.sh index a047d0449cd..918ef9300d6 100755 --- a/toolchain/build_abacus_intel.sh +++ b/toolchain/build_abacus_intel.sh @@ -23,7 +23,6 @@ rm -rf $BUILD_DIR PREFIX=$ABACUS_DIR ELPA=${ELPA_ROOT} -LIBXC=${LIBXC_ROOT} LIBRI=${LIBRI_ROOT} LIBCOMM=${LIBCOMM_ROOT} USE_CUDA=OFF # set ON to enable gpu-abacus @@ -63,7 +62,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DMKLROOT=$MKLROOT \ -DENABLE_FLOAT_FFTW=ON \ -DELPA_DIR=$ELPA \ - -DLibxc_DIR=$LIBXC \ -DENABLE_LCAO=ON \ -DENABLE_LIBXC=ON \ -DUSE_OPENMP=ON \ diff --git a/toolchain/scripts/stage4/install_cereal.sh b/toolchain/scripts/stage4/install_cereal.sh index 7bfd22ba518..3c84b8822b6 100755 --- a/toolchain/scripts/stage4/install_cereal.sh +++ b/toolchain/scripts/stage4/install_cereal.sh @@ -71,6 +71,7 @@ case "$with_cereal" in mkdir build && cd build cmake \ -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR="lib" \ -DCMAKE_VERBOSE_MAKEFILE=ON \ -DBUILD_DOC=OFF \ -DBUILD_SANDBOX=OFF \ diff --git a/toolchain/scripts/stage4/install_rapidjson.sh b/toolchain/scripts/stage4/install_rapidjson.sh index fd520b2571f..ce973c85ddc 100755 --- a/toolchain/scripts/stage4/install_rapidjson.sh +++ b/toolchain/scripts/stage4/install_rapidjson.sh @@ -73,6 +73,7 @@ case "$with_rapidjson" in mkdir build && cd build cmake \ -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ + -DCMAKE_INSTALL_LIBDIR="lib" \ -DRAPIDJSON_BUILD_DOC=OFF \ -DRAPIDJSON_BUILD_EXAMPLES=OFF \ -DRAPIDJSON_BUILD_TESTS=OFF \ From a9fc42c36eb89a6852fde308a45d3fc53158b7a9 Mon Sep 17 00:00:00 2001 From: Growl Date: Mon, 8 Jun 2026 03:34:13 +0800 Subject: [PATCH 3/3] CMake: Use interface target for feature dependencies --- CMakeLists.txt | 235 +++++++++++++----- cmake/SetupCuBlasMp.cmake | 2 +- cmake/SetupCuSolverMp.cmake | 2 + cmake/SetupNccl.cmake | 2 +- cmake/Testing.cmake | 6 +- source/CMakeLists.txt | 12 +- .../source_base/kernels/test/CMakeLists.txt | 2 +- source/source_base/libm/test/CMakeLists.txt | 2 +- .../ATen/kernels/test/CMakeLists.txt | 2 +- .../ATen/ops/test/CMakeLists.txt | 2 +- .../module_container/test/CMakeLists.txt | 2 +- .../module_grid/test/CMakeLists.txt | 2 +- .../module_mixing/test/CMakeLists.txt | 2 +- source/source_base/test/CMakeLists.txt | 2 +- .../module_ao/test/CMakeLists.txt | 2 +- .../module_pw/kernels/test/CMakeLists.txt | 2 +- .../module_pw/test/CMakeLists.txt | 2 +- .../module_pw/test_gpu/CMakeLists.txt | 2 +- .../module_pw/test_serial/CMakeLists.txt | 14 +- .../module_neighbor/test/CMakeLists.txt | 8 +- .../module_neighlist/test/CMakeLists.txt | 6 +- .../module_symmetry/test/CMakeLists.txt | 8 +- source/source_cell/test/CMakeLists.txt | 8 +- source/source_cell/test_pw/CMakeLists.txt | 10 +- source/source_esolver/test/CMakeLists.txt | 4 +- .../source_estate/kernels/test/CMakeLists.txt | 10 +- .../module_dm/test/CMakeLists.txt | 8 +- source/source_estate/test/CMakeLists.txt | 16 +- source/source_estate/test_mpi/CMakeLists.txt | 14 +- .../module_surchem/test/CMakeLists.txt | 4 +- .../module_vdw/test/CMakeLists.txt | 8 +- .../module_xc/test/CMakeLists.txt | 6 +- .../kernels/test/CMakeLists.txt | 4 +- source/source_hsolver/test/CMakeLists.txt | 6 +- .../source_io/module_json/test/CMakeLists.txt | 8 +- .../module_json/test/para_json_test.cpp | 1 - source/source_io/test/CMakeLists.txt | 8 +- source/source_io/test_serial/CMakeLists.txt | 8 +- .../module_deepks/test/CMakeLists.txt | 1 + .../module_gint/test/CMakeLists.txt | 10 +- .../ao_to_mo_transformer/test/CMakeLists.txt | 2 +- .../module_lr/dm_trans/test/CMakeLists.txt | 2 +- .../module_lr/utils/test/CMakeLists.txt | 2 +- .../module_operator_lcao/test/CMakeLists.txt | 2 +- .../module_exx_symmetry/test/CMakeLists.txt | 6 +- .../source_lcao/module_ri/test/CMakeLists.txt | 6 +- .../source_lcao/module_rt/test/CMakeLists.txt | 4 +- source/source_lcao/test/CMakeLists.txt | 6 +- source/source_md/test/CMakeLists.txt | 4 +- .../module_pwdft/kernels/test/CMakeLists.txt | 4 +- .../module_pwdft/test/CMakeLists.txt | 8 +- .../module_stodft/test/CMakeLists.txt | 2 +- source/source_relax/test/CMakeLists.txt | 10 +- 53 files changed, 311 insertions(+), 200 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0761115871e..15947cba072 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,9 @@ if(POLICY CMP0135) # https://cmake.org/cmake/help/git-stage/policy/CMP0135.html cmake_policy(SET CMP0135 NEW) # Otherwise this policy generates a warning on CMake 3.24 endif() +if(POLICY CMP0144) # https://cmake.org/cmake/help/git-stage/policy/CMP0144.html + cmake_policy(SET CMP0144 NEW) +endif() project( ABACUS @@ -61,10 +64,108 @@ if(NOT DEFINED NVHPC_ROOT_DIR AND DEFINED ENV{NVHPC_ROOT}) CACHE PATH "Path to NVIDIA HPC SDK root directory.") endif() +# Collect external dependency usage requirements. Feature macros are applied +# explicitly to targets below so tests can opt out without remove_definitions(). +add_library(abacus_external_deps INTERFACE) +add_library(abacus::external_deps ALIAS abacus_external_deps) + +set_property(GLOBAL PROPERTY ABACUS_FEATURE_DEFINITIONS "") + +function(abacus_normalize_definitions out_var) + set(_defs) + foreach(_def IN LISTS ARGN) + if(_def MATCHES "^-D(.+)") + list(APPEND _defs "${CMAKE_MATCH_1}") + else() + list(APPEND _defs "${_def}") + endif() + endforeach() + set(${out_var} ${_defs} PARENT_SCOPE) +endfunction() + +function(abacus_add_feature_definitions) + abacus_normalize_definitions(_defs ${ARGN}) + set_property(GLOBAL APPEND PROPERTY ABACUS_FEATURE_DEFINITIONS ${_defs}) +endfunction() + +define_property( + DIRECTORY + PROPERTY ABACUS_DISABLED_FEATURE_DEFINITIONS + INHERITED + BRIEF_DOCS "ABACUS feature definitions disabled for targets in this directory" + FULL_DOCS "Feature definitions disabled for targets created in this directory.") + +define_property( + DIRECTORY + PROPERTY ABACUS_LOCAL_FEATURE_DEFINITIONS + INHERITED + BRIEF_DOCS "Additional ABACUS feature definitions for targets in this directory" + FULL_DOCS "Additional feature definitions for targets created in this directory.") + +function(abacus_disable_feature_definitions) + abacus_normalize_definitions(_defs ${ARGN}) + set_property(DIRECTORY APPEND PROPERTY ABACUS_DISABLED_FEATURE_DEFINITIONS ${_defs}) +endfunction() + +function(abacus_add_local_feature_definitions) + abacus_normalize_definitions(_defs ${ARGN}) + set_property(DIRECTORY APPEND PROPERTY ABACUS_LOCAL_FEATURE_DEFINITIONS ${_defs}) +endfunction() + +function(abacus_apply_build_options target) + if(NOT TARGET "${target}") + return() + endif() + + get_target_property(_type "${target}" TYPE) + if(_type STREQUAL "INTERFACE_LIBRARY" OR _type STREQUAL "UTILITY") + return() + endif() + + get_target_property(_imported "${target}" IMPORTED) + if(_imported) + return() + endif() + + get_target_property(_source_dir "${target}" SOURCE_DIR) + get_property(_defs GLOBAL PROPERTY ABACUS_FEATURE_DEFINITIONS) + get_property(_disabled DIRECTORY "${_source_dir}" PROPERTY ABACUS_DISABLED_FEATURE_DEFINITIONS) + get_property(_local DIRECTORY "${_source_dir}" PROPERTY ABACUS_LOCAL_FEATURE_DEFINITIONS) + + if(_disabled) + list(REMOVE_ITEM _defs ${_disabled}) + endif() + if(_local) + list(APPEND _defs ${_local}) + endif() + if(_defs) + list(REMOVE_DUPLICATES _defs) + target_compile_definitions("${target}" PRIVATE ${_defs}) + endif() + + target_link_libraries("${target}" PRIVATE abacus::external_deps) +endfunction() + +function(abacus_apply_build_options_to_dir dir) + get_property(_targets DIRECTORY "${dir}" PROPERTY BUILDSYSTEM_TARGETS) + foreach(_target IN LISTS _targets) + abacus_apply_build_options("${_target}") + endforeach() + + get_property(_subdirs DIRECTORY "${dir}" PROPERTY SUBDIRECTORIES) + foreach(_subdir IN LISTS _subdirs) + abacus_apply_build_options_to_dir("${_subdir}") + endforeach() +endfunction() + # enable json support if(ENABLE_RAPIDJSON) - find_package(RapidJSON REQUIRED) - add_compile_definitions(__RAPIDJSON) + find_package(RapidJSON CONFIG REQUIRED) + if(NOT TARGET RapidJSON) + message(FATAL_ERROR "RapidJSON was found, but target RapidJSON is missing.") + endif() + abacus_add_feature_definitions(__RAPIDJSON) + target_link_libraries(abacus_external_deps INTERFACE RapidJSON) endif() # get commit info @@ -173,11 +274,11 @@ if (USE_DSP) endif() if (USE_CUDA_ON_DCU) - add_compile_definitions(__CUDA_ON_DCU) + abacus_add_feature_definitions(__CUDA_ON_DCU) endif() if (USE_CUDA_MPI) - add_compile_definitions(__CUDA_MPI) + abacus_add_feature_definitions(__CUDA_MPI) endif() list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) @@ -274,7 +375,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Intel) endif() if(USE_ABACUS_LIBM) - add_definitions(-DUSE_ABACUS_LIBM) + abacus_add_feature_definitions(USE_ABACUS_LIBM) endif() if(ENABLE_NATIVE_OPTIMIZATION) @@ -290,24 +391,28 @@ if(WIN32) endif() if(ENABLE_LCAO) - find_package(cereal REQUIRED) - add_compile_definitions(__LCAO) + find_package(cereal CONFIG REQUIRED) + if(NOT TARGET cereal::cereal) + message(FATAL_ERROR "cereal was found, but target cereal::cereal is missing.") + endif() + abacus_add_feature_definitions(__LCAO) + target_link_libraries(abacus_external_deps INTERFACE cereal::cereal) if(USE_ELPA) find_package(ELPA REQUIRED) include_directories(${ELPA_INCLUDE_DIR}) - target_link_libraries(${ABACUS_BIN_NAME} ELPA::ELPA) - add_compile_definitions(__ELPA) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ELPA::ELPA) + abacus_add_feature_definitions(__ELPA) endif() if(ENABLE_FFT_TWO_CENTER) - add_compile_definitions(USE_NEW_TWO_CENTER) + abacus_add_feature_definitions(USE_NEW_TWO_CENTER) endif() if(ENABLE_PEXSI) find_package(PEXSI REQUIRED) - target_link_libraries(${ABACUS_BIN_NAME} ${PEXSI_LIBRARY} ${SuperLU_DIST_LIBRARY} ${ParMETIS_LIBRARY} ${METIS_LIBRARY} pexsi) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${PEXSI_LIBRARY} ${SuperLU_DIST_LIBRARY} ${ParMETIS_LIBRARY} ${METIS_LIBRARY} pexsi) include_directories(${PEXSI_INCLUDE_DIR} ${ParMETIS_INCLUDE_DIR}) - add_compile_definitions(__PEXSI) + abacus_add_feature_definitions(__PEXSI) set(CMAKE_CXX_STANDARD 14) endif() else() @@ -316,30 +421,30 @@ else() endif() if(DEBUG_INFO) - add_compile_definitions(__DEBUG) + abacus_add_feature_definitions(__DEBUG) endif() if(ENABLE_MPI) find_package(MPI COMPONENTS CXX REQUIRED) include_directories(${MPI_CXX_INCLUDE_PATH}) - target_link_libraries(${ABACUS_BIN_NAME} MPI::MPI_CXX) - add_compile_definitions(__MPI) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE MPI::MPI_CXX) + abacus_add_feature_definitions(__MPI) list(APPEND math_libs MPI::MPI_CXX) endif() if (USE_DSP) - add_compile_definitions(__DSP) - target_link_libraries(${ABACUS_BIN_NAME} ${OMPI_LIBRARY1}) + abacus_add_feature_definitions(__DSP) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${OMPI_LIBRARY1}) include_directories(${MTBLAS_FFT_DIR}/libmtblas/include) include_directories(${MT_HOST_DIR}/include) - target_link_libraries(${ABACUS_BIN_NAME} ${MT_HOST_DIR}/hthreads/lib/libhthread_device.a) - target_link_libraries(${ABACUS_BIN_NAME} ${MT_HOST_DIR}/hthreads/lib/libhthread_host.a) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${MT_HOST_DIR}/hthreads/lib/libhthread_device.a) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${MT_HOST_DIR}/hthreads/lib/libhthread_host.a) endif() if(USE_KML) - add_compile_definitions(__KML) + abacus_add_feature_definitions(__KML) message(STATUS "Huawei KML support enabled. Defining __KML.") # TODO: Create FindKML.cmake # if(NOT DEFINED KML_ROOT) @@ -381,20 +486,20 @@ endif(USE_KML) if (USE_SW) - add_compile_definitions(__SW) + abacus_add_feature_definitions(__SW) set(SW ON) include_directories(${SW_MATH}/include) include_directories(${SW_FFT}/include) - target_link_libraries(${ABACUS_BIN_NAME} ${SW_FFT}/lib/libfftw3.a) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${SW_FFT}/lib/libfftw3.a) endif() find_package(Threads REQUIRED) -target_link_libraries(${ABACUS_BIN_NAME} Threads::Threads) +target_link_libraries(${ABACUS_BIN_NAME} PRIVATE Threads::Threads) if(USE_OPENMP) find_package(OpenMP REQUIRED) - target_link_libraries(${ABACUS_BIN_NAME} OpenMP::OpenMP_CXX) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE OpenMP::OpenMP_CXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") add_link_options(${OpenMP_CXX_LIBRARIES}) endif() @@ -475,9 +580,9 @@ if(USE_CUDA) set_property(TARGET ${ABACUS_BIN_NAME} PROPERTY CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES}) if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL 12.9) - target_link_libraries(${ABACUS_BIN_NAME} cudart) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE cudart) else () - target_link_libraries(${ABACUS_BIN_NAME} cudart nvToolsExt) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE cudart nvToolsExt) endif () include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 13.0) @@ -486,8 +591,8 @@ if(USE_CUDA) endif() endif() if(USE_CUDA) - add_compile_definitions(__CUDA) - add_compile_definitions(__UT_USE_CUDA) + abacus_add_feature_definitions(__CUDA) + abacus_add_feature_definitions(__UT_USE_CUDA) target_compile_definitions(${ABACUS_BIN_NAME} PRIVATE __USE_NVTX) if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -g -G" CACHE STRING "CUDA flags for debug build" FORCE) @@ -500,7 +605,7 @@ if(USE_CUDA) message(FATAL_ERROR "ENABLE_NCCL_PARALLEL_DEVICE requires ENABLE_MPI=ON.") endif() - add_compile_definitions(__NCCL_PARALLEL_DEVICE) + abacus_add_feature_definitions(__NCCL_PARALLEL_DEVICE) include(cmake/SetupNccl.cmake) abacus_setup_nccl(${ABACUS_BIN_NAME}) endif() @@ -570,11 +675,11 @@ if(USE_ROCM) endif() include_directories(${ROCM_PATH}/include) - target_link_libraries(${ABACUS_BIN_NAME} hip::host hip::device hip::hipfft + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE hip::host hip::device hip::hipfft roc::hipblas roc::hipsolver) - add_compile_definitions(__ROCM) - add_compile_definitions(__UT_USE_ROCM) - add_compile_definitions(__HIP_PLATFORM_HCC__) + abacus_add_feature_definitions(__ROCM) + abacus_add_feature_definitions(__UT_USE_ROCM) + abacus_add_feature_definitions(__HIP_PLATFORM_HCC__) endif() if(ENABLE_ASAN) @@ -587,7 +692,7 @@ if(ENABLE_ASAN) add_compile_options(-fsanitize=address -fno-omit-frame-pointer) add_link_options(-fsanitize=address) # `add_link_options` only affects executables added after. - target_link_libraries(${ABACUS_BIN_NAME} -fsanitize=address) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE -fsanitize=address) endif() if(DEFINED ENV{MKLROOT} AND NOT DEFINED MKLROOT) @@ -597,7 +702,7 @@ if(MKLROOT) set(MKL_INTERFACE lp64) set(ENABLE_SCALAPACK ON) find_package(MKL REQUIRED) - add_definitions(-D__MKL) + abacus_add_feature_definitions(__MKL) include_directories(${MKL_INCLUDE} ${MKL_INCLUDE}/fftw) list(APPEND math_libs MKL::MKL) if(CMAKE_CXX_COMPILER_ID MATCHES Intel) @@ -633,12 +738,12 @@ elseif(NOT USE_SW) endif() if(ENABLE_FLOAT_FFTW) - add_definitions(-D__ENABLE_FLOAT_FFTW) + abacus_add_feature_definitions(__ENABLE_FLOAT_FFTW) endif() if(ENABLE_MLALGO) - target_link_libraries(${ABACUS_BIN_NAME} deepks) # deepks - target_link_libraries(${ABACUS_BIN_NAME} hamilt_mlkedf) # mlkedf + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE deepks) # deepks + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE hamilt_mlkedf) # mlkedf find_path(libnpy_SOURCE_DIR npy.hpp HINTS ${libnpy_INCLUDE_DIR}) if(NOT libnpy_SOURCE_DIR) @@ -654,7 +759,7 @@ if(ENABLE_MLALGO) endif() include_directories(${libnpy_SOURCE_DIR}/include) - add_compile_definitions(__MLALGO) + abacus_add_feature_definitions(__MLALGO) endif() # Torch uses outdated components to detect CUDA arch, causing failure on @@ -696,8 +801,8 @@ if (ENABLE_CNPY) # find ZLIB and link find_package(ZLIB REQUIRED) - target_link_libraries(${ABACUS_BIN_NAME} cnpy ZLIB::ZLIB) - add_compile_definitions(__USECNPY) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE cnpy ZLIB::ZLIB) + abacus_add_feature_definitions(__USECNPY) endif() function(git_submodule_update) @@ -733,9 +838,9 @@ if(ENABLE_LIBRI) find_package(LibRI REQUIRED) endif() include_directories(${LIBRI_DIR}/include) - target_link_libraries(${ABACUS_BIN_NAME} ri module_exx_symmetry) - add_compile_definitions(__EXX EXX_DM=3 EXX_H_COMM=2 TEST_EXX_LCAO=0 - TEST_EXX_RADIAL=1) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ri module_exx_symmetry) + abacus_add_feature_definitions(__EXX EXX_DM=3 EXX_H_COMM=2 TEST_EXX_LCAO=0 + TEST_EXX_RADIAL=1) endif() if(ENABLE_LIBRI OR DEFINED LIBCOMM_DIR) @@ -756,20 +861,20 @@ if(ENABLE_LIBXC) if(${Libxc_VERSION} VERSION_LESS 5.1.7) message(FATAL_ERROR "LibXC >= 5.1.7 is required.") endif() - target_link_libraries(${ABACUS_BIN_NAME} Libxc::xc) - add_compile_definitions(USE_LIBXC) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE Libxc::xc) + abacus_add_feature_definitions(USE_LIBXC) endif() if(DEFINED DeePMD_DIR) - add_compile_definitions(__DPMD HIGH_PREC) + abacus_add_feature_definitions(__DPMD HIGH_PREC) add_compile_options(-Wl,--no-as-needed) find_package(DeePMD REQUIRED) include_directories(${DeePMD_DIR}/include) if(DeePMDC_FOUND) - target_link_libraries(${ABACUS_BIN_NAME} DeePMD::deepmd_c) - add_compile_definitions(__DPMDC) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE DeePMD::deepmd_c) + abacus_add_feature_definitions(__DPMDC) else() - target_link_libraries(${ABACUS_BIN_NAME} DeePMD::deepmd_cc) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE DeePMD::deepmd_cc) endif() endif() @@ -777,8 +882,8 @@ if(DEFINED NEP_DIR) find_package(NEP REQUIRED) if(NEP_FOUND) - add_compile_definitions(__NEP) - target_link_libraries(${ABACUS_BIN_NAME} NEP::nep) + abacus_add_feature_definitions(__NEP) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE NEP::nep) endif() endif() @@ -786,27 +891,30 @@ if(DEFINED TensorFlow_DIR) find_package(TensorFlow REQUIRED) include_directories(${TensorFlow_DIR}/include) if(TensorFlow_FOUND) - target_link_libraries(${ABACUS_BIN_NAME} TensorFlow::tensorflow_cc) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE TensorFlow::tensorflow_cc) endif() endif() -add_compile_definitions(__FFTW3 __SELINV METIS) +abacus_add_feature_definitions(__FFTW3 __SELINV METIS) if(INFO) message(STATUS "Will gather math lib info.") - add_compile_definitions(GATHER_INFO) + abacus_add_feature_definitions(GATHER_INFO) # modifications on blas_connector and lapack_connector endif() include(cmake/Testing.cmake) add_subdirectory(source) +abacus_apply_build_options_to_dir("${CMAKE_CURRENT_SOURCE_DIR}/source") +abacus_apply_build_options(${ABACUS_BIN_NAME}) include(cmake/BuildInfo.cmake) setup_build_info() target_link_libraries( ${ABACUS_BIN_NAME} + PRIVATE base parameter cell @@ -840,6 +948,7 @@ target_link_libraries( if(ENABLE_LCAO) target_link_libraries( ${ABACUS_BIN_NAME} + PRIVATE hamilt_lcao tddft orb @@ -849,21 +958,21 @@ if(ENABLE_LCAO) lr rdmft) if(USE_ELPA) - target_link_libraries(${ABACUS_BIN_NAME} genelpa) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE genelpa) endif() if(USE_CUDA) - target_link_libraries(${ABACUS_BIN_NAME} diag_cusolver) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE diag_cusolver) endif() endif() if(ENABLE_RAPIDJSON) - target_link_libraries(${ABACUS_BIN_NAME} json_output) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE json_output) endif() if (USE_SW) - target_link_libraries(${ABACUS_BIN_NAME} ${SW_MATH}/libswfft.a) - target_link_libraries(${ABACUS_BIN_NAME} ${SW_MATH}/libswscalapack.a) - target_link_libraries(${ABACUS_BIN_NAME} ${SW_MATH}/libswlapack.a) - target_link_libraries(${ABACUS_BIN_NAME} ${SW_MATH}/libswblas.a) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${SW_MATH}/libswfft.a) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${SW_MATH}/libswscalapack.a) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${SW_MATH}/libswlapack.a) + target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${SW_MATH}/libswblas.a) list(APPEND math_libs gfortran) endif() @@ -871,7 +980,7 @@ endif() if(NOT MSVC) list(APPEND math_libs m) endif() -target_link_libraries(${ABACUS_BIN_NAME} ${math_libs}) +target_link_libraries(${ABACUS_BIN_NAME} PRIVATE ${math_libs}) install(PROGRAMS ${ABACUS_BIN_PATH} TYPE BIN diff --git a/cmake/SetupCuBlasMp.cmake b/cmake/SetupCuBlasMp.cmake index 7937a02936a..563e593de1f 100644 --- a/cmake/SetupCuBlasMp.cmake +++ b/cmake/SetupCuBlasMp.cmake @@ -73,6 +73,6 @@ function(abacus_setup_cublasmp target_name) endif() # 5. Link the library to the target - target_link_libraries(${target_name} cublasMp::cublasMp) + target_link_libraries(${target_name} PRIVATE cublasMp::cublasMp) endfunction() diff --git a/cmake/SetupCuSolverMp.cmake b/cmake/SetupCuSolverMp.cmake index 004665686b6..5c2b3f43c01 100644 --- a/cmake/SetupCuSolverMp.cmake +++ b/cmake/SetupCuSolverMp.cmake @@ -129,10 +129,12 @@ function(abacus_setup_cusolvermp target_name) # === Link libraries === if(_use_cal) target_link_libraries(${target_name} + PRIVATE CAL::CAL cusolverMp::cusolverMp) else() target_link_libraries(${target_name} + PRIVATE NCCL::NCCL cusolverMp::cusolverMp) endif() diff --git a/cmake/SetupNccl.cmake b/cmake/SetupNccl.cmake index 56e8e10e7b0..7b13c7d608a 100644 --- a/cmake/SetupNccl.cmake +++ b/cmake/SetupNccl.cmake @@ -45,5 +45,5 @@ function(abacus_setup_nccl target_name) include_directories(${NCCL_INCLUDE_DIR}) target_include_directories(${target_name} PRIVATE ${NCCL_INCLUDE_DIR}) endif() - target_link_libraries(${target_name} NCCL::NCCL) + target_link_libraries(${target_name} PRIVATE NCCL::NCCL) endfunction() diff --git a/cmake/Testing.cmake b/cmake/Testing.cmake index 551b1d7182d..72d77084ade 100644 --- a/cmake/Testing.cmake +++ b/cmake/Testing.cmake @@ -39,15 +39,15 @@ endif() endif() # dependencies & link library - target_link_libraries(${UT_TARGET} ${UT_LIBS} Threads::Threads + target_link_libraries(${UT_TARGET} PRIVATE ${UT_LIBS} Threads::Threads GTest::gtest_main GTest::gmock_main) if(ENABLE_GOOGLEBENCH) target_link_libraries( - ${UT_TARGET} benchmark::benchmark) + ${UT_TARGET} PRIVATE benchmark::benchmark) endif() if(USE_OPENMP) - target_link_libraries(${UT_TARGET} OpenMP::OpenMP_CXX) + target_link_libraries(${UT_TARGET} PRIVATE OpenMP::OpenMP_CXX) endif() # Link to build info if needed diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 6f127a17223..f6aab11ace1 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -132,15 +132,17 @@ add_library(device OBJECT ${device_srcs}) if(USE_CUDA) target_link_libraries( - device - cusolver - cublas + device + PRIVATE + cusolver + cublas cufft ) elseif(USE_ROCM) target_link_libraries( - device - device_rocm + device + PRIVATE + device_rocm hip::host hip::device hip::hipfft diff --git a/source/source_base/kernels/test/CMakeLists.txt b/source/source_base/kernels/test/CMakeLists.txt index fc5b49a33a3..e8d311cfdaf 100644 --- a/source/source_base/kernels/test/CMakeLists.txt +++ b/source/source_base/kernels/test/CMakeLists.txt @@ -1,4 +1,4 @@ -remove_definitions(-D__MPI) +abacus_disable_feature_definitions(__MPI) AddTest( TARGET MODULE_BASE_KERNELS_Unittests diff --git a/source/source_base/libm/test/CMakeLists.txt b/source/source_base/libm/test/CMakeLists.txt index 70e9172d559..8454ca0e2d8 100644 --- a/source/source_base/libm/test/CMakeLists.txt +++ b/source/source_base/libm/test/CMakeLists.txt @@ -1,4 +1,4 @@ -remove_definitions(-D__MPI) +abacus_disable_feature_definitions(__MPI) AddTest( TARGET MODULE_BASE_LIBM_UTs diff --git a/source/source_base/module_container/ATen/kernels/test/CMakeLists.txt b/source/source_base/module_container/ATen/kernels/test/CMakeLists.txt index 0ca3d97c26f..8fcfb667f5f 100644 --- a/source/source_base/module_container/ATen/kernels/test/CMakeLists.txt +++ b/source/source_base/module_container/ATen/kernels/test/CMakeLists.txt @@ -5,4 +5,4 @@ AddTest( memory_test.cpp linalg_test.cpp ) -target_link_libraries(MODULE_BASE_container_kernels_uts container base device) +target_link_libraries(MODULE_BASE_container_kernels_uts PRIVATE container base device) diff --git a/source/source_base/module_container/ATen/ops/test/CMakeLists.txt b/source/source_base/module_container/ATen/ops/test/CMakeLists.txt index d5103acfdd1..89babce953c 100644 --- a/source/source_base/module_container/ATen/ops/test/CMakeLists.txt +++ b/source/source_base/module_container/ATen/ops/test/CMakeLists.txt @@ -4,4 +4,4 @@ AddTest( SOURCES einsum_op_test.cpp linalg_op_test.cpp ../../kernels/lapack.cpp ) -target_link_libraries(MODULE_BASE_container_ops_uts container base device) +target_link_libraries(MODULE_BASE_container_ops_uts PRIVATE container base device) diff --git a/source/source_base/module_container/test/CMakeLists.txt b/source/source_base/module_container/test/CMakeLists.txt index 9a9505870ba..63aeec80aee 100644 --- a/source/source_base/module_container/test/CMakeLists.txt +++ b/source/source_base/module_container/test/CMakeLists.txt @@ -1,4 +1,4 @@ -remove_definitions(-D__MPI) +abacus_disable_feature_definitions(__MPI) AddTest( TARGET MODULE_BASE_CONTAINER_Unittests diff --git a/source/source_base/module_grid/test/CMakeLists.txt b/source/source_base/module_grid/test/CMakeLists.txt index 068feb96349..721658e1234 100644 --- a/source/source_base/module_grid/test/CMakeLists.txt +++ b/source/source_base/module_grid/test/CMakeLists.txt @@ -1,4 +1,4 @@ -remove_definitions(-D__MPI) +abacus_disable_feature_definitions(__MPI) AddTest( TARGET MODULE_BASE_GRID_test_delley diff --git a/source/source_base/module_mixing/test/CMakeLists.txt b/source/source_base/module_mixing/test/CMakeLists.txt index 86d201e1f79..c32640b9c64 100644 --- a/source/source_base/module_mixing/test/CMakeLists.txt +++ b/source/source_base/module_mixing/test/CMakeLists.txt @@ -1,4 +1,4 @@ -remove_definitions(-D__MPI) +abacus_disable_feature_definitions(__MPI) AddTest( TARGET MODULE_BASE_MIXING_unittests LIBS parameter base device ${math_libs} diff --git a/source/source_base/test/CMakeLists.txt b/source/source_base/test/CMakeLists.txt index 2647d0a2d9c..be21f047f67 100644 --- a/source/source_base/test/CMakeLists.txt +++ b/source/source_base/test/CMakeLists.txt @@ -1,4 +1,4 @@ -remove_definitions(-D__MPI) +abacus_disable_feature_definitions(__MPI) install(DIRECTORY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) AddTest( TARGET MODULE_BASE_blas_connector diff --git a/source/source_basis/module_ao/test/CMakeLists.txt b/source/source_basis/module_ao/test/CMakeLists.txt index bbc7d4f2fb8..dc3a5e458ff 100644 --- a/source/source_basis/module_ao/test/CMakeLists.txt +++ b/source/source_basis/module_ao/test/CMakeLists.txt @@ -1,4 +1,4 @@ -remove_definitions(-D__EXX) +abacus_disable_feature_definitions(__EXX) list(APPEND depend_files ../../../source_base/math_integral.cpp diff --git a/source/source_basis/module_pw/kernels/test/CMakeLists.txt b/source/source_basis/module_pw/kernels/test/CMakeLists.txt index 448b60499f6..4cba49d5a2f 100644 --- a/source/source_basis/module_pw/kernels/test/CMakeLists.txt +++ b/source/source_basis/module_pw/kernels/test/CMakeLists.txt @@ -1,4 +1,4 @@ -add_definitions(-D__NORMAL) +abacus_add_local_feature_definitions(__NORMAL) AddTest( TARGET MODULE_PW_PW_Kernels_UTs diff --git a/source/source_basis/module_pw/test/CMakeLists.txt b/source/source_basis/module_pw/test/CMakeLists.txt index b126791088f..41321a6450a 100644 --- a/source/source_basis/module_pw/test/CMakeLists.txt +++ b/source/source_basis/module_pw/test/CMakeLists.txt @@ -1,4 +1,4 @@ -add_definitions(-D__NORMAL) +abacus_add_local_feature_definitions(__NORMAL) AddTest( TARGET MODULE_PW_pw_test LIBS parameter ${math_libs} planewave device diff --git a/source/source_basis/module_pw/test_gpu/CMakeLists.txt b/source/source_basis/module_pw/test_gpu/CMakeLists.txt index a0b5cb75a64..0adb3362ff9 100644 --- a/source/source_basis/module_pw/test_gpu/CMakeLists.txt +++ b/source/source_basis/module_pw/test_gpu/CMakeLists.txt @@ -1,4 +1,4 @@ -add_definitions(-D__NORMAL) +abacus_add_local_feature_definitions(__NORMAL) if (USE_CUDA) AddTest( TARGET pw_test_gpu diff --git a/source/source_basis/module_pw/test_serial/CMakeLists.txt b/source/source_basis/module_pw/test_serial/CMakeLists.txt index 52e594afb99..34b0641ee45 100644 --- a/source/source_basis/module_pw/test_serial/CMakeLists.txt +++ b/source/source_basis/module_pw/test_serial/CMakeLists.txt @@ -1,10 +1,10 @@ -remove_definitions(-D__MPI) -remove_definitions(-D__EXX) -remove_definitions(-D__CUDA) -remove_definitions(-D__UT_USE_CUDA) -remove_definitions(-D__ROCM) -remove_definitions(-D__UT_USE_ROCM) -remove_definitions(-D__MLALGO) +abacus_disable_feature_definitions(__MPI) +abacus_disable_feature_definitions(__EXX) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__UT_USE_CUDA) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__UT_USE_ROCM) +abacus_disable_feature_definitions(__MLALGO) add_library( planewave_serial diff --git a/source/source_cell/module_neighbor/test/CMakeLists.txt b/source/source_cell/module_neighbor/test/CMakeLists.txt index 3d891aa20c3..c13666b9908 100644 --- a/source/source_cell/module_neighbor/test/CMakeLists.txt +++ b/source/source_cell/module_neighbor/test/CMakeLists.txt @@ -1,8 +1,8 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) #include "module_/.h" -remove_definitions(-D__ROCM) -remove_definitions(-D__EXX) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__EXX) AddTest( TARGET MODULE_CELL_NEIGHBOR_sltk_atom diff --git a/source/source_cell/module_neighlist/test/CMakeLists.txt b/source/source_cell/module_neighlist/test/CMakeLists.txt index a8462c59f7f..5eb49a3bcf0 100644 --- a/source/source_cell/module_neighlist/test/CMakeLists.txt +++ b/source/source_cell/module_neighlist/test/CMakeLists.txt @@ -1,6 +1,6 @@ -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) -remove_definitions(-D__EXX) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__EXX) diff --git a/source/source_cell/module_symmetry/test/CMakeLists.txt b/source/source_cell/module_symmetry/test/CMakeLists.txt index 890395dd28a..a9764a46e13 100644 --- a/source/source_cell/module_symmetry/test/CMakeLists.txt +++ b/source/source_cell/module_symmetry/test/CMakeLists.txt @@ -1,7 +1,7 @@ -remove_definitions(-D__LCAO) -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) +abacus_disable_feature_definitions(__LCAO) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) AddTest( TARGET MODULE_CELL_SYMMETRY_analysis LIBS parameter base ${math_libs} device symmetry diff --git a/source/source_cell/test/CMakeLists.txt b/source/source_cell/test/CMakeLists.txt index d508a115a2e..ed269348ae1 100644 --- a/source/source_cell/test/CMakeLists.txt +++ b/source/source_cell/test/CMakeLists.txt @@ -1,7 +1,7 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) -remove_definitions(-D__EXX) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__EXX) find_program(BASH bash) install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/source/source_cell/test_pw/CMakeLists.txt b/source/source_cell/test_pw/CMakeLists.txt index 9bcfd022101..da088942c25 100644 --- a/source/source_cell/test_pw/CMakeLists.txt +++ b/source/source_cell/test_pw/CMakeLists.txt @@ -1,8 +1,8 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) -remove_definitions(-D__EXX) -remove_definitions(-D__LCAO) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__EXX) +abacus_disable_feature_definitions(__LCAO) install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) install(FILES unitcell_test_pw_para.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/source/source_esolver/test/CMakeLists.txt b/source/source_esolver/test/CMakeLists.txt index 38506e2ea0a..f666b206f59 100644 --- a/source/source_esolver/test/CMakeLists.txt +++ b/source/source_esolver/test/CMakeLists.txt @@ -1,5 +1,5 @@ -remove_definitions(-D__MPI) -remove_definitions(-D__LCAO) +abacus_disable_feature_definitions(__MPI) +abacus_disable_feature_definitions(__LCAO) install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/source/source_estate/kernels/test/CMakeLists.txt b/source/source_estate/kernels/test/CMakeLists.txt index 9957bc03f73..5b938eaa79e 100644 --- a/source/source_estate/kernels/test/CMakeLists.txt +++ b/source/source_estate/kernels/test/CMakeLists.txt @@ -1,8 +1,8 @@ -remove_definitions(-D__MPI) -remove_definitions(-D__EXX) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) -remove_definitions(-D__MLALGO) +abacus_disable_feature_definitions(__MPI) +abacus_disable_feature_definitions(__EXX) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__MLALGO) AddTest( TARGET Elecstate_Kernels_UTs diff --git a/source/source_estate/module_dm/test/CMakeLists.txt b/source/source_estate/module_dm/test/CMakeLists.txt index bb95272936c..58d8c5cb2d9 100644 --- a/source/source_estate/module_dm/test/CMakeLists.txt +++ b/source/source_estate/module_dm/test/CMakeLists.txt @@ -1,11 +1,11 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) if(TARGET MODULE_ESTATE_dm_io_test_serial) - remove_definitions(-D__MPI) + abacus_disable_feature_definitions(__MPI) endif() AddTest( diff --git a/source/source_estate/test/CMakeLists.txt b/source/source_estate/test/CMakeLists.txt index 9bd76ae2486..c7b49d64e59 100644 --- a/source/source_estate/test/CMakeLists.txt +++ b/source/source_estate/test/CMakeLists.txt @@ -1,11 +1,11 @@ -remove_definitions(-D__MPI) -remove_definitions(-D__EXX) -remove_definitions(-D__CUDA) -remove_definitions(-D__UT_USE_CUDA) -remove_definitions(-D__UT_USE_ROCM) -remove_definitions(-D__ROCM) -remove_definitions(-D__MLALGO) -remove_definitions(-D_OPENMP) +abacus_disable_feature_definitions(__MPI) +abacus_disable_feature_definitions(__EXX) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__UT_USE_CUDA) +abacus_disable_feature_definitions(__UT_USE_ROCM) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(_OPENMP) if (ENABLE_MPI) diff --git a/source/source_estate/test_mpi/CMakeLists.txt b/source/source_estate/test_mpi/CMakeLists.txt index 6d2073592bf..cc7ed7a4bb7 100644 --- a/source/source_estate/test_mpi/CMakeLists.txt +++ b/source/source_estate/test_mpi/CMakeLists.txt @@ -1,10 +1,10 @@ -remove_definitions(-D__EXX) -remove_definitions(-D__CUDA) -remove_definitions(-D__UT_USE_CUDA) -remove_definitions(-D__UT_USE_ROCM) -remove_definitions(-D__ROCM) -remove_definitions(-D__MLALGO) -remove_definitions(-D_OPENMP) +abacus_disable_feature_definitions(__EXX) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__UT_USE_CUDA) +abacus_disable_feature_definitions(__UT_USE_ROCM) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(_OPENMP) AddTest( TARGET MODULE_ESTATE_charge_mpi_test diff --git a/source/source_hamilt/module_surchem/test/CMakeLists.txt b/source/source_hamilt/module_surchem/test/CMakeLists.txt index eb667b7c2ab..1d557cd36c1 100644 --- a/source/source_hamilt/module_surchem/test/CMakeLists.txt +++ b/source/source_hamilt/module_surchem/test/CMakeLists.txt @@ -1,5 +1,5 @@ -remove_definitions(-D__LCAO ) -remove_definitions(-DUSE_LIBXC) +abacus_disable_feature_definitions(__LCAO) +abacus_disable_feature_definitions(USE_LIBXC) install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) list(APPEND depend_files diff --git a/source/source_hamilt/module_vdw/test/CMakeLists.txt b/source/source_hamilt/module_vdw/test/CMakeLists.txt index 4b61f7f3000..e4242374554 100644 --- a/source/source_hamilt/module_vdw/test/CMakeLists.txt +++ b/source/source_hamilt/module_vdw/test/CMakeLists.txt @@ -1,6 +1,6 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) install(FILES c6.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) install(FILES r0.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) @@ -13,5 +13,5 @@ AddTest( if(ENABLE_DFTD4) target_compile_definitions(MODULE_HAMILT_vdwTest PRIVATE __DFTD4) - target_link_libraries(MODULE_HAMILT_vdwTest dftd4::dftd4) + target_link_libraries(MODULE_HAMILT_vdwTest PRIVATE dftd4::dftd4) endif() diff --git a/source/source_hamilt/module_xc/test/CMakeLists.txt b/source/source_hamilt/module_xc/test/CMakeLists.txt index 93b1d546678..7da00cc109e 100644 --- a/source/source_hamilt/module_xc/test/CMakeLists.txt +++ b/source/source_hamilt/module_xc/test/CMakeLists.txt @@ -1,20 +1,20 @@ AddTest( TARGET MODULE_HAMILT_XCTest_PBE - LIBS parameter MPI::MPI_CXX Libxc::xc # required by global.h; for details, `remove_definitions(-D__MPI)`. + LIBS parameter MPI::MPI_CXX Libxc::xc # required by global.h; for details, `abacus_disable_feature_definitions(__MPI)`. SOURCES test_xc.cpp ../xc_functional.cpp ../xc_functional_wrapper_xc.cpp ../xc_functional_wrapper_gcxc.cpp ../xc_funct_corr_gga.cpp ../xc_funct_corr_lda.cpp ../xc_funct_exch_gga.cpp ../xc_funct_exch_lda.cpp ../xc_funct_hcth.cpp ../xc_functional_libxc_wrapper_gcxc.cpp ../xc_functional_libxc.cpp ) AddTest( TARGET MODULE_HAMILT_XCTest_HSE - LIBS parameter MPI::MPI_CXX Libxc::xc # required by global.h; for details, `remove_definitions(-D__MPI)`. + LIBS parameter MPI::MPI_CXX Libxc::xc # required by global.h; for details, `abacus_disable_feature_definitions(__MPI)`. SOURCES test_xc1.cpp ../xc_functional.cpp ../xc_functional_libxc.cpp ) AddTest( TARGET MODULE_HAMILT_XCTest_PZ_SPN - LIBS parameter MPI::MPI_CXX Libxc::xc # required by global.h; for details, `remove_definitions(-D__MPI)`. + LIBS parameter MPI::MPI_CXX Libxc::xc # required by global.h; for details, `abacus_disable_feature_definitions(__MPI)`. SOURCES test_xc2.cpp ../xc_functional.cpp ../xc_functional_wrapper_xc.cpp ../xc_functional_wrapper_gcxc.cpp ../xc_funct_corr_gga.cpp ../xc_funct_corr_lda.cpp ../xc_funct_exch_gga.cpp ../xc_funct_exch_lda.cpp ../xc_funct_hcth.cpp ../xc_functional_libxc_wrapper_gcxc.cpp ../xc_functional_libxc_wrapper_xc.cpp ../xc_functional_libxc.cpp ) diff --git a/source/source_hsolver/kernels/test/CMakeLists.txt b/source/source_hsolver/kernels/test/CMakeLists.txt index 851c30c731c..987f42da157 100644 --- a/source/source_hsolver/kernels/test/CMakeLists.txt +++ b/source/source_hsolver/kernels/test/CMakeLists.txt @@ -1,5 +1,5 @@ -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) if(USE_CUDA OR USE_ROCM) AddTest( diff --git a/source/source_hsolver/test/CMakeLists.txt b/source/source_hsolver/test/CMakeLists.txt index 1b1529adb4a..e17e58d3941 100644 --- a/source/source_hsolver/test/CMakeLists.txt +++ b/source/source_hsolver/test/CMakeLists.txt @@ -1,6 +1,6 @@ -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) -remove_definitions(-D__EXX) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__EXX) if (ENABLE_MPI) AddTest( diff --git a/source/source_io/module_json/test/CMakeLists.txt b/source/source_io/module_json/test/CMakeLists.txt index ea973b4a909..b1d1b029d7f 100644 --- a/source/source_io/module_json/test/CMakeLists.txt +++ b/source/source_io/module_json/test/CMakeLists.txt @@ -1,7 +1,7 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) -remove_definitions(-D__EXX) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__EXX) AddTest( TARGET MODULE_IO_JSON_OUTPUT_TEST diff --git a/source/source_io/module_json/test/para_json_test.cpp b/source/source_io/module_json/test/para_json_test.cpp index 1b6a5b71d2b..0f5b52fa52f 100644 --- a/source/source_io/module_json/test/para_json_test.cpp +++ b/source/source_io/module_json/test/para_json_test.cpp @@ -1,7 +1,6 @@ #include "gtest/gtest.h" #define private public -#define __RAPIDJSON 1 #include "source_io/module_json/abacusjson.h" #include "source_io/module_json/general_info.h" #include "source_io/module_json/init_info.h" diff --git a/source/source_io/test/CMakeLists.txt b/source/source_io/test/CMakeLists.txt index e9afa10db23..91b344c38dc 100644 --- a/source/source_io/test/CMakeLists.txt +++ b/source/source_io/test/CMakeLists.txt @@ -1,7 +1,7 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) -remove_definitions(-D__EXX) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__EXX) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) configure_file(INPUTs ${CMAKE_CURRENT_BINARY_DIR}/INPUTs COPYONLY) diff --git a/source/source_io/test_serial/CMakeLists.txt b/source/source_io/test_serial/CMakeLists.txt index aaa170883e0..aac91f2dcbf 100644 --- a/source/source_io/test_serial/CMakeLists.txt +++ b/source/source_io/test_serial/CMakeLists.txt @@ -1,7 +1,7 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) -remove_definitions(-D__MPI) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__MPI) add_library( io_input_serial diff --git a/source/source_lcao/module_deepks/test/CMakeLists.txt b/source/source_lcao/module_deepks/test/CMakeLists.txt index 2a1dae6e6db..28b1b8a67c9 100644 --- a/source/source_lcao/module_deepks/test/CMakeLists.txt +++ b/source/source_lcao/module_deepks/test/CMakeLists.txt @@ -46,6 +46,7 @@ add_executable( target_link_libraries( test_deepks + PRIVATE base device parameter deepks psi planewave neighbor container orb gint numerical_atomic_orbitals ${math_libs} diff --git a/source/source_lcao/module_gint/test/CMakeLists.txt b/source/source_lcao/module_gint/test/CMakeLists.txt index a6c0267ec32..87a547d7b43 100644 --- a/source/source_lcao/module_gint/test/CMakeLists.txt +++ b/source/source_lcao/module_gint/test/CMakeLists.txt @@ -1,8 +1,8 @@ -remove_definitions(-D__MPI) -remove_definitions(-D__CUDA) -remove_definitions(-D__UT_USE_CUDA) -remove_definitions(-D__UT_USE_ROCM) -remove_definitions(-D__ROCM) +abacus_disable_feature_definitions(__MPI) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__UT_USE_CUDA) +abacus_disable_feature_definitions(__UT_USE_ROCM) +abacus_disable_feature_definitions(__ROCM) if(ENABLE_LCAO) diff --git a/source/source_lcao/module_lr/ao_to_mo_transformer/test/CMakeLists.txt b/source/source_lcao/module_lr/ao_to_mo_transformer/test/CMakeLists.txt index a9999731bc0..ef1e405fdcb 100644 --- a/source/source_lcao/module_lr/ao_to_mo_transformer/test/CMakeLists.txt +++ b/source/source_lcao/module_lr/ao_to_mo_transformer/test/CMakeLists.txt @@ -1,4 +1,4 @@ -remove_definitions(-DUSE_LIBXC) +abacus_disable_feature_definitions(USE_LIBXC) AddTest( TARGET MODULE_LR_ao_to_mo_test LIBS parameter base ${math_libs} container device psi diff --git a/source/source_lcao/module_lr/dm_trans/test/CMakeLists.txt b/source/source_lcao/module_lr/dm_trans/test/CMakeLists.txt index 034e8e3fedd..380fc48336b 100644 --- a/source/source_lcao/module_lr/dm_trans/test/CMakeLists.txt +++ b/source/source_lcao/module_lr/dm_trans/test/CMakeLists.txt @@ -1,4 +1,4 @@ -remove_definitions(-DUSE_LIBXC) +abacus_disable_feature_definitions(USE_LIBXC) AddTest( TARGET MODULE_LR_dm_trans_test LIBS parameter psi base ${math_libs} device container diff --git a/source/source_lcao/module_lr/utils/test/CMakeLists.txt b/source/source_lcao/module_lr/utils/test/CMakeLists.txt index b0c2e4dbfb7..2ce675b9c05 100644 --- a/source/source_lcao/module_lr/utils/test/CMakeLists.txt +++ b/source/source_lcao/module_lr/utils/test/CMakeLists.txt @@ -1,4 +1,4 @@ -remove_definitions(-DUSE_LIBXC) +abacus_disable_feature_definitions(USE_LIBXC) AddTest( TARGET MODULE_LR_lr_util_phys_test LIBS parameter base ${math_libs} device container planewave #for FFT diff --git a/source/source_lcao/module_operator_lcao/test/CMakeLists.txt b/source/source_lcao/module_operator_lcao/test/CMakeLists.txt index a1c52935cf1..64404baa4ad 100644 --- a/source/source_lcao/module_operator_lcao/test/CMakeLists.txt +++ b/source/source_lcao/module_operator_lcao/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(ENABLE_LCAO) -remove_definitions(-DUSE_NEW_TWO_CENTER) +abacus_disable_feature_definitions(USE_NEW_TWO_CENTER) AddTest( TARGET MODULE_LCAO_operator_overlap_test diff --git a/source/source_lcao/module_ri/module_exx_symmetry/test/CMakeLists.txt b/source/source_lcao/module_ri/module_exx_symmetry/test/CMakeLists.txt index 822bd6afde6..7f7404816b1 100644 --- a/source/source_lcao/module_ri/module_exx_symmetry/test/CMakeLists.txt +++ b/source/source_lcao/module_ri/module_exx_symmetry/test/CMakeLists.txt @@ -1,6 +1,6 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) AddTest( TARGET MODULE_RI_EXX_SYMMETRY_rotation LIBS base ${math_libs} device symmetry neighbor parameter diff --git a/source/source_lcao/module_ri/test/CMakeLists.txt b/source/source_lcao/module_ri/test/CMakeLists.txt index b1a0f3f90e6..e903a173dee 100644 --- a/source/source_lcao/module_ri/test/CMakeLists.txt +++ b/source/source_lcao/module_ri/test/CMakeLists.txt @@ -1,6 +1,6 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) AddTest( TARGET MODULE_RI_dm_mixing_test LIBS parameter base ${math_libs} device diff --git a/source/source_lcao/module_rt/test/CMakeLists.txt b/source/source_lcao/module_rt/test/CMakeLists.txt index cb24761d718..ce5c7ac76fa 100644 --- a/source/source_lcao/module_rt/test/CMakeLists.txt +++ b/source/source_lcao/module_rt/test/CMakeLists.txt @@ -1,7 +1,5 @@ -remove_definitions(-D __MPI) - add_library(tddft_test_lib tddft_test.cpp) -target_link_libraries(tddft_test_lib Threads::Threads GTest::gtest_main GTest::gmock_main) +target_link_libraries(tddft_test_lib PRIVATE Threads::Threads GTest::gtest_main GTest::gmock_main) #target_include_directories(tddft_test_lib PUBLIC $<$:${GTEST_INCLUDE_DIRS}>) AddTest( diff --git a/source/source_lcao/test/CMakeLists.txt b/source/source_lcao/test/CMakeLists.txt index 483430f4f7f..c7898ee6bed 100644 --- a/source/source_lcao/test/CMakeLists.txt +++ b/source/source_lcao/test/CMakeLists.txt @@ -1,6 +1,6 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) if(ENABLE_LCAO) AddTest( diff --git a/source/source_md/test/CMakeLists.txt b/source/source_md/test/CMakeLists.txt index c4e3a1c2d2f..440cb14aeb4 100644 --- a/source/source_md/test/CMakeLists.txt +++ b/source/source_md/test/CMakeLists.txt @@ -1,5 +1,5 @@ -remove_definitions(-D__MPI -D__LCAO ) -add_definitions(-D__NORMAL) +abacus_disable_feature_definitions(__MPI __LCAO) +abacus_add_local_feature_definitions(__NORMAL) list(APPEND depend_files ../md_func.cpp diff --git a/source/source_pw/module_pwdft/kernels/test/CMakeLists.txt b/source/source_pw/module_pwdft/kernels/test/CMakeLists.txt index bd97cff1a69..30a2beaf80c 100644 --- a/source/source_pw/module_pwdft/kernels/test/CMakeLists.txt +++ b/source/source_pw/module_pwdft/kernels/test/CMakeLists.txt @@ -1,5 +1,5 @@ -remove_definitions(-D__LCAO) -remove_definitions(-D__MLALGO) +abacus_disable_feature_definitions(__LCAO) +abacus_disable_feature_definitions(__MLALGO) AddTest( TARGET MODULE_PW_Hamilt_Kernels_UTs diff --git a/source/source_pw/module_pwdft/test/CMakeLists.txt b/source/source_pw/module_pwdft/test/CMakeLists.txt index 2699d58998b..c6203ffaf89 100644 --- a/source/source_pw/module_pwdft/test/CMakeLists.txt +++ b/source/source_pw/module_pwdft/test/CMakeLists.txt @@ -1,7 +1,7 @@ -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) -remove_definitions(-D__EXX) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) +abacus_disable_feature_definitions(__EXX) AddTest( TARGET MODULE_PW_pwdft_soc diff --git a/source/source_pw/module_stodft/test/CMakeLists.txt b/source/source_pw/module_stodft/test/CMakeLists.txt index 7063ebf13a5..c5e07e626ed 100644 --- a/source/source_pw/module_stodft/test/CMakeLists.txt +++ b/source/source_pw/module_stodft/test/CMakeLists.txt @@ -1,4 +1,4 @@ -remove_definitions(-D__MPI) +abacus_disable_feature_definitions(__MPI) AddTest( TARGET MODULE_PW_Sto_Tool_UTs diff --git a/source/source_relax/test/CMakeLists.txt b/source/source_relax/test/CMakeLists.txt index 777e24d7cf9..b718e1efc70 100644 --- a/source/source_relax/test/CMakeLists.txt +++ b/source/source_relax/test/CMakeLists.txt @@ -1,8 +1,8 @@ -remove_definitions(-D__MPI) -remove_definitions(-D__LCAO) -remove_definitions(-D__MLALGO) -remove_definitions(-D__CUDA) -remove_definitions(-D__ROCM) +abacus_disable_feature_definitions(__MPI) +abacus_disable_feature_definitions(__LCAO) +abacus_disable_feature_definitions(__MLALGO) +abacus_disable_feature_definitions(__CUDA) +abacus_disable_feature_definitions(__ROCM) install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR})