Merge pull request #4344 from lammps/cmake-cpp-std-deprecation

Prepare development branch for requiring C++17 and deprecating GNU make support for some packages
This commit is contained in:
Axel Kohlmeyer
2025-01-13 01:05:07 -05:00
committed by GitHub
21 changed files with 231 additions and 33 deletions

View File

@ -3,6 +3,9 @@
# CMake build system
# This file is part of LAMMPS
cmake_minimum_required(VERSION 3.16)
if(CMAKE_VERSION VERSION_LESS 3.20)
message(WARNING "LAMMPS is planning to require at least CMake version 3.20 by Summer 2025. Please upgrade!")
endif()
########################################
# set policy to silence warnings about ignoring <PackageName>_ROOT but use it
if(POLICY CMP0074)
@ -144,16 +147,28 @@ if((PKG_KOKKOS) AND (Kokkos_ENABLE_CUDA) AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL
set(CMAKE_TUNE_DEFAULT "${CMAKE_TUNE_DEFAULT}" "-Xcudafe --diag_suppress=unrecognized_pragma,--diag_suppress=128")
endif()
# we require C++11 without extensions. Kokkos requires at least C++17 (currently)
# we *require* C++11 without extensions but prefer C++17.
# Kokkos requires at least C++17 (currently)
if(NOT CMAKE_CXX_STANDARD)
if(cxx_std_17 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 11)
endif()
endif()
if(CMAKE_CXX_STANDARD LESS 11)
message(FATAL_ERROR "C++ standard must be set to at least 11")
endif()
if(CMAKE_CXX_STANDARD LESS 17)
message(WARNING "Selecting C++17 standard is preferred over C++${CMAKE_CXX_STANDARD}")
endif()
if(PKG_KOKKOS AND (CMAKE_CXX_STANDARD LESS 17))
set(CMAKE_CXX_STANDARD 17)
endif()
# turn off C++17 check in lmptype.h
if(LAMMPS_CXX11)
add_compile_definitions(LAMMPS_CXX11)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Use compiler extensions")
# ugly hacks for MSVC which by default always reports an old C++ standard in the __cplusplus macro
@ -347,6 +362,17 @@ foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES})
option(PKG_${PKG} "Build ${PKG} Package" OFF)
endforeach()
set(DEPRECATED_PACKAGES AWPMD ATC POEMS)
foreach(PKG ${DEPRECATED_PACKAGES})
if(PKG_${PKG})
message(WARNING
"The ${PKG} package will be removed from LAMMPS in Summer 2025 due to lack of "
"maintenance and use of code constructs that conflict with modern C++ compilers "
"and standards. Please contact developers@lammps.org if you have any concerns "
"about this step.")
endif()
endforeach()
######################################################
# packages with special compiler needs or external libs
######################################################

View File

@ -1,10 +1,14 @@
Build LAMMPS
============
LAMMPS is built as a library and an executable from source code using
either traditional makefiles for use with GNU make (which may require
manual editing), or using a build environment generated by CMake (Unix
Makefiles, Ninja, Xcode, Visual Studio, KDevelop, CodeBlocks and more).
LAMMPS is built as a library and an executable from source code using a
build environment generated by CMake (Unix Makefiles, Ninja, Xcode,
Visual Studio, KDevelop, CodeBlocks and more depending on the platform).
Using CMake is the preferred way to build LAMMPS. In addition, LAMMPS
can be compiled using the legacy build system based on traditional
makefiles for use with GNU make (which may require manual editing).
Support for the legacy build system is slowly being phased out and may
not be available for all optional features.
As an alternative, you can download a package with pre-built executables
or automated build trees, as described in the :doc:`Install <Install>`

View File

@ -16,7 +16,7 @@ environments is on a :doc:`separate page <Howto_cmake>`.
.. note::
LAMMPS currently requires that CMake version 3.16 or later is available.
LAMMPS currently requires that CMake version 3.20 or later is available.
.. warning::
@ -32,11 +32,11 @@ environments is on a :doc:`separate page <Howto_cmake>`.
Advantages of using CMake
^^^^^^^^^^^^^^^^^^^^^^^^^
CMake is an alternative to compiling LAMMPS in the traditional way
through :doc:`(manually customized) makefiles <Build_make>`. Using
CMake has multiple advantages that are specifically helpful for
people with limited experience in compiling software or for people
that want to modify or extend LAMMPS.
CMake is the preferred way of compiling LAMMPS in contrast to the legacy
build system based on GNU make and through :doc:`(manually customized)
makefiles <Build_make>`. Using CMake has multiple advantages that are
specifically helpful for people with limited experience in compiling
software or for people that want to modify or extend LAMMPS.
- CMake can detect available hardware, tools, features, and libraries
and adapt the LAMMPS default build configuration accordingly.

View File

@ -8,6 +8,10 @@ Building LAMMPS with traditional makefiles requires that you have a
for customizing your LAMMPS build with a number of global compilation
options and features.
This build system is slowly being phased out and may not support all
optional features and packages in LAMMPS. It is recommended to switch
to the :doc:`CMake based build system <Build_cmake>`.
Requirements
^^^^^^^^^^^^

View File

@ -208,20 +208,21 @@ Build system (strict)
LAMMPS currently supports two build systems: one that is based on
:doc:`traditional Makefiles <Build_make>` and one that is based on
:doc:`CMake <Build_cmake>`. Therefore, your contribution must be
compatible with and support both build systems.
:doc:`CMake <Build_cmake>`. As of fall 2024, it is no longer required
to support the traditional make build system. New packages may choose
to only support building with CMake. Additions to existing packages
must follow the requirements set by that package.
For a single pair of header and implementation files that are an
independent feature, it is usually only required to add them to
``src/.gitignore``.
For traditional make, if your contributed files or package depend on
other LAMMPS style files or packages also being installed
(e.g. because your file is a derived class from the other LAMMPS
class), then an ``Install.sh`` file is also needed to check for those
dependencies and modifications to ``src/Depend.sh`` to trigger the checks.
See other README and Install.sh files in other directories as
examples.
other LAMMPS style files or packages also being installed (e.g. because
your file is a derived class from the other LAMMPS class), then an
``Install.sh`` file is also needed to check for those dependencies and
modifications to ``src/Depend.sh`` to trigger the checks. See other
README and Install.sh files in other directories as examples.
Similarly, for CMake support, changes may need to be made to
``cmake/CMakeLists.txt``, some of the files in ``cmake/presets``, and

View File

@ -449,12 +449,6 @@ class PyLammps(object):
"""
def __init__(self, name="", cmdargs=None, ptr=None, comm=None, verbose=False):
print("WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING")
print()
print("The PyLammps interface is deprecated and will be removed in future versions.")
print("Please use the lammps Python class instead.")
print()
print("WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING")
self.has_echo = False
self.verbose = verbose
@ -476,6 +470,12 @@ class PyLammps(object):
self.comm_nprocs = self.lmp.extract_setting("world_size")
self.comm_me = self.lmp.extract_setting("world_rank")
if self.comm_me == 0:
print("\nWARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING")
print("WARNING:")
print("WARNING: The PyLammps class is obsolete and will be removed from LAMMPS soon.")
print("WARNING: Please use the lammps Python class instead.")
print("WARNING:")
print("WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING\n")
print("LAMMPS output is captured by PyLammps wrapper")
if self.comm_nprocs > 1:
print("WARNING: Using PyLammps with multiple MPI ranks is experimental. Not all functionality is supported.")

View File

@ -9,6 +9,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
The ATC package will be removed from LAMMPS in Summer 2025 due to lack of
maintenance and use of code constructs that conflict with modern C++ compilers
and standards. Please contact developers@lammps.org if you have any concerns
about this step.
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
action () {
if (test $mode = 0) then
rm -f ../$1

View File

@ -9,6 +9,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
The AWPMD package will be removed from LAMMPS in Summer 2025 due to lack of
maintenance and use of code constructs that conflict with modern C++ compilers
and standards. Please contact developers@lammps.org if you have any concerns
about this step.
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
action () {
if (test $mode = 0) then
rm -f ../$1

View File

@ -9,6 +9,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
Support for building the COLVARS package with the legacy build system using GNU
make will be removed in Summer 2025. Please switch to using CMake to build
LAMMPS as soon as possible and report any problems to developers@lammps.org
or post a bug report issue at https://github.com/lammps/lammps/issues
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
action () {
if (test $mode = 0) then
rm -f ../$1

View File

@ -7,6 +7,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
Support for building the COMPRESS package with the legacy build system using
GNU make will be removed in Summer 2025. Please switch to using CMake to build
LAMMPS as soon as possible and report any problems to developers@lammps.org
or post a bug report issue at https://github.com/lammps/lammps/issues
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
# arg1 = file, arg2 = file it depends on
action () {

View File

@ -11,6 +11,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
Support for building the ELECTRODE package with the legacy build system using
GNU make will be removed in Summer 2025. Please switch to using CMake to build
LAMMPS as soon as possible and report any problems to developers@lammps.org
or post a bug report issue at https://github.com/lammps/lammps/issues
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
# arg1 = file, arg2 = file it depends on
action () {

View File

@ -7,6 +7,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
Support for building the GPU package with the legacy build system using GNU
make will be removed in Summer 2025. Please switch to using CMake to build
LAMMPS as soon as possible and report any problems to developers@lammps.org
or post a bug report issue at https://github.com/lammps/lammps/issues
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
# arg1 = file, arg2 = file it depends on
action () {

View File

@ -7,6 +7,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
Support for building the KOKKOS package with the legacy build system using GNU
make will be removed in Summer 2025. Please switch to using CMake to build
LAMMPS as soon as possible and report any problems to developers@lammps.org
or post a bug report issue at https://github.com/lammps/lammps/issues
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
# arg1 = file, arg2 = file it depends on
action () {

View File

@ -9,6 +9,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
Support for building the LEPTON package with the legacy build system using GNU
make will be removed in Summer 2025. Please switch to using CMake to build
LAMMPS as soon as possible and report any problems to developers@lammps.org
or post a bug report issue at https://github.com/lammps/lammps/issues
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
action () {
if (test $mode = 0) then
rm -f ../$1

View File

@ -7,12 +7,12 @@ SHELL = /bin/sh
# specify flags and libraries needed for your compiler
CC = mpicxx
CCFLAGS = -g -O3 -std=c++11
CCFLAGS = -g -O3 # -std=c++17
SHFLAGS = -fPIC
DEPFLAGS = -M
LINK = mpicxx
LINKFLAGS = -g -O3 -std=c++11
LINKFLAGS = -g -O3 # -std=c++17
LIB =
SIZE = size
@ -28,7 +28,7 @@ SHLIBFLAGS = -shared -rdynamic
# LAMMPS ifdef settings
# see possible settings in Section 3.5 of the manual
LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 # -DLAMMPS_CXX98
LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 # -DLAMMPS_CXX11
# MPI library
# see discussion in Section 3.4 of the manual

View File

@ -7,12 +7,12 @@ SHELL = /bin/sh
# specify flags and libraries needed for your compiler
CC = g++
CCFLAGS = -g -O3 -std=c++11
CCFLAGS = -g -O3 # -std=c++17
SHFLAGS = -fPIC
DEPFLAGS = -M
LINK = g++
LINKFLAGS = -g -O -std=c++11
LINKFLAGS = -g -O # -std=c++17
LIB =
SIZE = size
@ -28,7 +28,7 @@ SHLIBFLAGS = -shared -rdynamic
# LAMMPS ifdef settings
# see possible settings in Section 3.5 of the manual
LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 # -DLAMMPS_CXX98
LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 # -DLAMMPS_CXX11
# MPI library
# see discussion in Section 3.4 of the manual

View File

@ -7,6 +7,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
Support for building the ML-POD package with the legacy build system using GNU
make will be removed in Summer 2025. Please switch to using CMake to build
LAMMPS as soon as possible and report any problems to developers@lammps.org
or post a bug report issue at https://github.com/lammps/lammps/issues
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
# arg1 = file, arg2 = file it depends on
action () {

View File

@ -7,6 +7,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
Support for building the PLUMED package with the legacy build system using GNU
make will be removed in Summer 2025. Please switch to using CMake to build
LAMMPS as soon as possible and report any problems to developers@lammps.org
or post a bug report issue at https://github.com/lammps/lammps/issues
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
# arg1 = file, arg2 = file it depends on
action () {

View File

@ -9,6 +9,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
The POEMS package will be removed from LAMMPS in Summer 2025 due to lack of
maintenance and use of code constructs that conflict with modern C++ compilers
and standards. Please contact developers@lammps.org if you have any concerns
about this step.
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
action () {
if (test $mode = 0) then
rm -f ../$1

View File

@ -7,6 +7,19 @@ mode=$1
LC_ALL=C
export LC_ALL
cat <<EOF
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
Support for building the VTK package with the legacy build system using GNU
make will be removed in Summer 2025. Please switch to using CMake to build
LAMMPS as soon as possible and report any problems to developers@lammps.org
or post a bug report issue at https://github.com/lammps/lammps/issues
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING
EOF
# arg1 = file, arg2 = file it depends on
action () {

View File

@ -34,6 +34,13 @@
#error LAMMPS requires a C++11 (or later) compliant compiler. Enable C++11 compatibility or upgrade the compiler.
#endif
// C++17 check
#ifndef LAMMPS_CXX11
#if __cplusplus < 201703L
#error LAMMPS is planning to transition to requiring C++17. To disable this error please use a C++17 compliant compiler, enable C++17 support, or define -DLAMMPS_CXX11 in your makefile or when running cmake
#endif
#endif
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif