Skip to content

CMake: Introduce CMake dependent options and print build summary#7626

Open
Growl1234 wants to merge 7 commits into
deepmodeling:developfrom
Growl1234:cmake
Open

CMake: Introduce CMake dependent options and print build summary#7626
Growl1234 wants to merge 7 commits into
deepmodeling:developfrom
Growl1234:cmake

Conversation

@Growl1234

Copy link
Copy Markdown

This PR introduces cmake_dependent_option with intention to make the dependency handling logic clearer from the beginning of CMake logic.

Example:

cmake_dependent_option(EXX_DEV "Enable LibRI developing features" OFF "ENABLE_LIBRI" OFF)

This means EXX_DEV is available only when ENABLE_LIBRI is set to ON, and defaults to OFF; if ENABLE_LIBRI=OFF, the EXX_DEV option will be forced to be off. So if one passes -DENABLE_LIBRI=OFF -DEXX_DEV=ON to CMake (by mistake?), the actual resulting logic will be -DENABLE_LIBRI=OFF -DEXX_DEV=OFF.

cmake_dependent_option(ENABLE_ELPA "Enable ELPA for LCAO" ON "ENABLE_LCAO;ENABLE_MPI" OFF)

This means ENABLE_ELPA is available only when both ENABLE_LCAO and ENABLE_MPI are set to ON.

@Growl1234

Growl1234 commented Jul 13, 2026

Copy link
Copy Markdown
Author

There is one RFC about how we should detect and show the version of MPI, as existing version detection logic seems invalid.

I currently choose to show the real MPI-standard what an MPI implementation follows, as this is generally available for any MPI implementations through a single ${MPI_CXX_VERSION}. For example:

  • MPICH 5.0.1 follows MPI-5.0 standard (therefore MPICH (MPI standard: 5.0))
  • OpenMPI 5.0.10 follows MPI-3.1 standard (therefore OpenMPI (MPI standard: 3.1))
  • Intel MPI 2021.18 follows MPI-4.1 standard (therefore Intel MPI (MPI standard: 4.1))

However, one concern is that users might not be used to it, so might there be other easier way?

@Growl1234 Growl1234 changed the title CMake: Introduce CMake dependent options CMake: Introduce CMake dependent options and print build summary Jul 13, 2026
@Growl1234 Growl1234 force-pushed the cmake branch 4 times, most recently from 0db16ca to b2be2ef Compare July 14, 2026 04:19
- Output crucial information as a build summary
- Make MPI implementation detection valid (at least for non-cross build)
- Use version of MPI standard one MPI implementation follows [RFC]
@Growl1234

Copy link
Copy Markdown
Author

Side note: an inconsistent change is made here: ENLABLE_LIBRI will requrie ENABLE_MPI.

If enable LibRI support without MPI, compilation will report error:

[303/692] Building CXX object source/source_lcao/CMakeFiles/hamilt_lcao.dir/hamilt_lcao.cpp.o
FAILED: source/source_lcao/CMakeFiles/hamilt_lcao.dir/hamilt_lcao.cpp.o 
/usr/bin/c++ -DCOMMIT_INFO -DEXX_DM=3 -DEXX_H_COMM=2 -DMETIS -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 -DUSE_NEW_TWO_CENTER -D__EXX -D__FFTW3 -D__LCAO -D__MKL -D__SELINV -I/root/GitHub/abacus-dev/source -I/root/GitHub/abacus-dev/source/source_base/module_container -I/root/GitHub/abacus-dev/build -I/opt/intel/oneapi/mkl/2026.1/include/fftw -I/root/GitHub/abacus-dev/build/_deps/libri-src/include -I/root/GitHub/abacus-dev/build/_deps/libcomm-src/include -std=gnu++14 -O3 -g -fopenmp -MD -MT source/source_lcao/CMakeFiles/hamilt_lcao.dir/hamilt_lcao.cpp.o -MF source/source_lcao/CMakeFiles/hamilt_lcao.dir/hamilt_lcao.cpp.o.d -o source/source_lcao/CMakeFiles/hamilt_lcao.dir/hamilt_lcao.cpp.o -c /root/GitHub/abacus-dev/source/source_lcao/hamilt_lcao.cpp
In file included from /root/GitHub/abacus-dev/source/source_lcao/module_ri/Exx_LRI.h:10,
                 from /root/GitHub/abacus-dev/source/source_lcao/module_ri/Exx_LRI_interface.h:4,
                 from /root/GitHub/abacus-dev/source/source_lcao/hamilt_lcao.cpp:21:
/root/GitHub/abacus-dev/source/source_lcao/module_ri/ewald_Vq.h:19:10: fatal error: mpi.h: No such file or directory
   19 | #include <mpi.h>
      |          ^~~~~~~
compilation terminated.

Also, require out-of-source CMake build as in-source is dangerous and might affect the real source code in the build process.

@Growl1234 Growl1234 marked this pull request as ready for review July 16, 2026 07:21
Copilot AI review requested due to automatic review settings July 16, 2026 07:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants