CMake: Centralize target linkage in source/CMakeLists.txt#7584
CMake: Centralize target linkage in source/CMakeLists.txt#7584Growl1234 wants to merge 10 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the CMake build layout to centralize all ABACUS target construction and final link ordering in source/CMakeLists.txt, leaving the top-level CMakeLists.txt focused on option/package discovery and feature resolution. It also updates unit-test CMake fragments to stop manually appending ${math_libs} and instead rely on the centralized link interface.
Changes:
- Introduces centralized dependency interface targets (
abacus::linalg_libs,abacus::feature_libs,abacus::link_libs) and moves the ABACUS executable + final ordered link closure intosource/CMakeLists.txt. - Updates the
AddTest()helper to link tests againstabacus::link_libs, and removes${math_libs}from many per-testLIBSlists. - Adjusts auxiliary CMake modules to align with the new “centralized linkage” model (e.g., NCCL/cuBLASMp/cuSOLVERMp setup and build-info include path).
Reviewed changes
Copilot reviewed 62 out of 65 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| source/source_relax/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists to rely on centralized link interface. |
| source/source_relax/CMakeLists.txt | Whitespace-only cleanup. |
| source/source_pw/module_stodft/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_pw/module_pwdft/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_pw/module_pwdft/kernels/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_psi/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_md/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_rt/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_ri/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists / normalizes ordering. |
| source/source_lcao/module_ri/module_exx_symmetry/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_ri/module_exx_symmetry/CMakeLists.txt | Whitespace-only cleanup. |
| source/source_lcao/module_ri/CMakeLists.txt | Whitespace-only cleanup. |
| source/source_lcao/module_operator_lcao/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_lr/utils/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_lr/ri_benchmark/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_lr/dm_trans/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_lr/ao_to_mo_transformer/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_hcontainer/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_gint/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_dftu/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_deltaspin/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_lcao/module_deepks/test/CMakeLists.txt | Removes ${math_libs} from the DEEPKS unit-test library list. |
| source/source_io/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_io/test_serial/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_io/module_json/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_hsolver/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists (incl. ELPA/PEXSI branches). |
| source/source_hsolver/kernels/test/CMakeLists.txt | Removes ${math_libs} from unit-test/perf-test link lists. |
| source/source_hamilt/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists; formatting cleanup. |
| source/source_hamilt/module_xc/test/CMakeLists.txt | Removes ${math_libs} from XC unit-test link lists; formatting cleanup. |
| source/source_hamilt/module_xc/kernels/test/CMakeLists.txt | Removes ${math_libs} from XC kernels unit-test link lists. |
| source/source_hamilt/module_vdw/test/CMakeLists.txt | Removes ${math_libs} from vdw unit-test link lists. |
| source/source_hamilt/module_surchem/test/CMakeLists.txt | Removes ${math_libs} from surchem unit-test link lists. |
| source/source_estate/test/CMakeLists.txt | Removes ${math_libs} from elecstate unit-test link lists. |
| source/source_estate/test_mpi/CMakeLists.txt | Removes ${math_libs} from MPI unit-test link lists. |
| source/source_estate/module_dm/test/CMakeLists.txt | Removes ${math_libs} from dm unit-test link lists. |
| source/source_estate/kernels/test/CMakeLists.txt | Removes ${math_libs} from kernels unit-test link lists. |
| source/source_esolver/test/CMakeLists.txt | Removes ${math_libs} from esolver unit-test link lists. |
| source/source_cell/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_cell/test_pw/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_cell/module_symmetry/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_cell/module_neighlist/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_cell/module_neighbor/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_basis/module_pw/test/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_basis/module_pw/test_serial/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_basis/module_pw/test_gpu/CMakeLists.txt | Removes ${math_libs} from unit-test link lists. |
| source/source_basis/module_pw/kernels/test/CMakeLists.txt | Removes ${math_libs} from kernels unit-test link lists. |
| source/source_basis/module_nao/test/CMakeLists.txt | Removes ${math_libs} from NAO unit-test link lists. |
| source/source_basis/module_ao/test/CMakeLists.txt | Removes ${math_libs} from AO unit-test link lists. |
| source/source_base/test/CMakeLists.txt | Removes ${math_libs} from base unit-test link lists. |
| source/source_base/test_parallel/CMakeLists.txt | Removes ${math_libs} from parallel unit-test link lists. |
| source/source_base/module_mixing/test/CMakeLists.txt | Removes ${math_libs} from mixing unit-test link lists. |
| source/source_base/module_grid/test/CMakeLists.txt | Drops ${math_libs} link list from grid unit test (now relies on centralized closure). |
| source/source_base/module_device/test/CMakeLists.txt | Removes ${math_libs} from device unit-test link lists. |
| source/source_base/module_container/test/CMakeLists.txt | Removes ${math_libs} from container unit-test link lists. |
| source/source_base/module_container/ATen/ops/test/CMakeLists.txt | Removes ${math_libs} from ops unit-test link lists. |
| source/source_base/module_container/ATen/kernels/test/CMakeLists.txt | Removes ${math_libs} from kernels unit-test link lists. |
| source/source_base/kernels/test/CMakeLists.txt | Removes ${math_libs} from kernels unit-test link lists. |
| source/CMakeLists.txt | New central “single source of truth” for ABACUS target linkage, dependency interfaces, final ordered link closure, and test registration. |
| CMakeLists.txt | Refocuses top-level configuration on options/packages/feature resolution; moves target construction/linkage into source/. |
| cmake/Testing.cmake | Updates AddTest() to link with abacus::link_libs and removes per-test OpenMP/Threads handling. |
| cmake/SetupNccl.cmake | Adjusts NCCL setup function signature to align with centralized linkage. |
| cmake/SetupCuSolverMp.cmake | Adjusts cuSOLVERMp setup function signature; stops directly linking into the old global deps interface. |
| cmake/SetupCuBlasMp.cmake | Adjusts cuBLASMp setup function signature; stops directly linking into the old global deps interface. |
| cmake/BuildInfo.cmake | Uses ${PROJECT_SOURCE_DIR} for a stable include path to CollectBuildInfoVars.cmake. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
716736b to
79f474e
Compare
|
The testing failure seems to be related to conflict symbols between OpenBLAS and pre-built libtorch: Details |
23f3d5a to
5721bbb
Compare
|
Are there still ways I can make the current checklist green? |
This refactors the CMake layout so that the top-level CMakeLists.txt is limited
to project configuration: options, feature resolution, platform/compiler setup,
and package discovery.
Target construction and linkage are centralized in source/CMakeLists.txt, which
now owns:
- the common linear-algebra dependency interface;
- optional external feature dependencies;
- the final external link closure;
- the ABACUS executable and its ordered internal target linkage;
- unit-test setup and registration of the top-level integration tests.
The final link closure is kept in one explicit location. Its order is part of
the build contract, especially for static or mixed static/shared builds:
1. internal ABACUS targets, from higher-level consumers to lower-level
providers;
2. optional external feature libraries;
3. numerical backends and their MPI, OpenMP, compiler-runtime, and system
dependencies.
Dependencies are therefore no longer accumulated through the legacy
`${math_libs}` path or scattered between the root CMakeLists.txt, test
directories, and setup modules. The old global OpenMP flag/link-option handling
is also removed in favour of imported targets and their usage requirements.
The top-level integration-test directory is registered only after the final
executable and its path are available. No integration-test cases are changed.
This is a structural cleanup only. It does not redesign dependency discovery or
change the current provider-selection logic for MKL, cuSOLVERMp, PEXSI, ELPA,
FFTW, ScaLAPACK, KML, or GPU dependencies, part of which need to be revised
seperately .
Shared DeePKS test helpers include GoogleTest headers.
| set(_abacus_feature_include_dirs) | ||
| set(_abacus_feature_compile_options) | ||
|
|
||
| if(ENABLE_RAPIDJSON) |
There was a problem hiding this comment.
No .so files in Rapidjson?
There was a problem hiding this comment.
Sorry, a guard in configuration step is missing; fortunately, #7583 has added it.
Reminder
Linked Issue
Fix #7585.
Unit Tests and/or Case Tests for my changes
What's changed?
This refactors the CMake layout so that the top-level
CMakeLists.txtis limited to project configuration: options, feature resolution, platform/compiler setup, and package discovery.Target construction and linkage are centralized in
source/CMakeLists.txt, which now owns:The final link closure is kept in one explicit location. Its order is part of the build contract, especially for static or mixed static/shared builds:
Dependencies are therefore no longer accumulated through the legacy
${math_libs}path or scattered between the rootCMakeLists.txt, test directories, and setup modules. The old global OpenMP flag/link-option handling is also removed in favour of imported targets and their usage requirements.The top-level integration-test directory is registered only after the final executable and its path are available. No integration-test cases are changed.
This is a structural cleanup only. It does not touch dependency discovery or change the current provider-selection logic, part of which need to be revised seperately .
Any changes of core modules? (ignore if not applicable)