more details about current and future compiler requirements

This commit is contained in:
Axel Kohlmeyer
2025-01-23 12:02:51 -05:00
parent dac011b865
commit f8484de195
2 changed files with 31 additions and 11 deletions

View File

@ -196,13 +196,18 @@ LAMMPS.
.. tab:: CMake build .. tab:: CMake build
By default CMake will use the compiler it finds according to By default CMake will use the compiler it finds according to its
internal preferences, and it will add optimization flags internal preferences, and it will add optimization flags
appropriate to that compiler and any :doc:`accelerator packages appropriate to that compiler and any :doc:`accelerator packages
<Speed_packages>` you have included in the build. CMake will <Speed_packages>` you have included in the build. CMake will
check if the detected or selected compiler is compatible with the check if the detected or selected compiler is compatible with the
C++ support requirements of LAMMPS and stop with an error, if this C++ support requirements of LAMMPS and stop with an error, if this
is not the case. is not the case. A C++11 compatible compiler is currently
required, but a transition to require C++17 is in progess and
planned to be completed in Summer 2025. Currently, setting
``-DLAMMPS_CXX11=yes`` is required when configuring with CMake while
using a C++11 compatible compiler that does not support C++17,
otherwise setting ``-DCMAKE_CXX_STANDARD=17`` is preferred.
You can tell CMake to look for a specific compiler with setting You can tell CMake to look for a specific compiler with setting
CMake variables (listed below) during configuration. For a few CMake variables (listed below) during configuration. For a few
@ -223,6 +228,8 @@ LAMMPS.
-D CMAKE_C_COMPILER=name # name of C compiler -D CMAKE_C_COMPILER=name # name of C compiler
-D CMAKE_Fortran_COMPILER=name # name of Fortran compiler -D CMAKE_Fortran_COMPILER=name # name of Fortran compiler
-D CMAKE_CXX_STANDARD=17 # put compiler in C++17 mode
-D LAMMPS_CXX11=yes # enforce compilation in C++11 mode
-D CMAKE_CXX_FLAGS=string # flags to use with C++ compiler -D CMAKE_CXX_FLAGS=string # flags to use with C++ compiler
-D CMAKE_C_FLAGS=string # flags to use with C compiler -D CMAKE_C_FLAGS=string # flags to use with C compiler
-D CMAKE_Fortran_FLAGS=string # flags to use with Fortran compiler -D CMAKE_Fortran_FLAGS=string # flags to use with Fortran compiler
@ -321,15 +328,23 @@ LAMMPS.
you would have to install a newer compiler that supports C++11; you would have to install a newer compiler that supports C++11;
either as a binary package or through compiling from source. either as a binary package or through compiling from source.
If you build LAMMPS with any :doc:`Speed_packages` included, While a C++11 compatible compiler is currently sufficient to compile
there may be specific compiler or linker flags that are either LAMMPS, a transition to require C++17 is in progess and planned to
required or recommended to enable required features and to be completed in Summer 2025. Currently, setting ``-DLAMMPS_CXX11``
achieve optimal performance. You need to include these in the in the ``LMP_INC =`` line in the machine makefile is required when
``CCFLAGS`` and ``LINKFLAGS`` settings above. For details, see the using a C++11 compatible compiler that does not support C++17.
documentation for the individual packages listed on the Otherwise, to enable C++17 support (if not enabled by default) using
:doc:`Speed_packages` page. Or examine these files in the a compiler flag like ``-std=c++17`` in CCFLAGS may needed.
``src/MAKE/OPTIONS`` directory. They correspond to each of the 5
accelerator packages and their hardware variants: If you build LAMMPS with any :doc:`Speed_packages` included,
there may be specific compiler or linker flags that are either
required or recommended to enable required features and to
achieve optimal performance. You need to include these in the
``CCFLAGS`` and ``LINKFLAGS`` settings above. For details, see the
documentation for the individual packages listed on the
:doc:`Speed_packages` page. Or examine these files in the
``src/MAKE/OPTIONS`` directory. They correspond to each of the 5
accelerator packages and their hardware variants:
.. code-block:: bash .. code-block:: bash

View File

@ -313,6 +313,11 @@ way than the varargs mechanism of the C library. Finally, {fmt} has
been included into the C++20 language standard, so changes to adopt it been included into the C++20 language standard, so changes to adopt it
are future-proof. are future-proof.
The long-term plan is to switch to using ``std::format()`` instead of
``fmt::format()`` when the minimum C++ standard required for LAMMPS will
be set to C++20. See the :ref:`basic build instructions <compile>` for
more details.
Formatted strings are frequently created by calling the Formatted strings are frequently created by calling the
``fmt::format()`` function, which will return a string as a ``fmt::format()`` function, which will return a string as a
``std::string`` class instance. In contrast to the ``%`` placeholder in ``std::string`` class instance. In contrast to the ``%`` placeholder in