diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 13e1d1539f..44c864941c 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -2,7 +2,7 @@ # CMake build system # This file is part of LAMMPS # Created by Christoph Junghans and Richard Berger -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.10) project(lammps CXX) set(SOVERSION 0) @@ -55,12 +55,9 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict -std=c++11") endif() -option(DISABLE_CXX11_REQUIREMENT "Disable check that requires C++11 for compiling LAMMPS" OFF) -if(DISABLE_CXX11_REQUIREMENT) - add_definitions(-DLAMMPS_CXX98) -# else() -# set(CMAKE_CXX_STANDARD 11) -endif() +# we require C++11 +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) # GNU compiler features if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") @@ -355,9 +352,6 @@ endforeach(HEADER) set(MATH_LIBRARIES "m" CACHE STRING "math library") mark_as_advanced( MATH_LIBRARIES ) include(CheckLibraryExists) -if (CMAKE_VERSION VERSION_LESS "3.4") - enable_language(C) # check_library_exists isn't supported without a C compiler before v3.4 -endif() # RB: disabled this check because it breaks with KOKKOS CUDA enabled #foreach(FUNC sin cos) # check_library_exists(${MATH_LIBRARIES} ${FUNC} "" FOUND_${FUNC}_${MATH_LIBRARIES}) diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index dab9d51a3f..200d8fb51e 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -1,7 +1,4 @@ if(PKG_GPU) - if (CMAKE_VERSION VERSION_LESS "3.1") - message(FATAL_ERROR "For the GPU package you need at least cmake-3.1") - endif() set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU) set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h ${GPU_SOURCES_DIR}/fix_gpu.h diff --git a/cmake/Modules/Packages/LATTE.cmake b/cmake/Modules/Packages/LATTE.cmake index de7116780b..8bcda84cdc 100644 --- a/cmake/Modules/Packages/LATTE.cmake +++ b/cmake/Modules/Packages/LATTE.cmake @@ -8,9 +8,6 @@ if(PKG_LATTE) endif() option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT}) if(DOWNLOAD_LATTE) - if (CMAKE_VERSION VERSION_LESS "3.7") # due to SOURCE_SUBDIR - message(FATAL_ERROR "For downlading LATTE you need at least cmake-3.7") - endif() if(CMAKE_GENERATOR STREQUAL "Ninja") message(FATAL_ERROR "Cannot build downloaded LATTE library with Ninja build tool") endif() diff --git a/cmake/Modules/Packages/MSCG.cmake b/cmake/Modules/Packages/MSCG.cmake index b442580583..99d98659ee 100644 --- a/cmake/Modules/Packages/MSCG.cmake +++ b/cmake/Modules/Packages/MSCG.cmake @@ -8,9 +8,6 @@ if(PKG_MSCG) endif() option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" ${DOWNLOAD_MSCG_DEFAULT}) if(DOWNLOAD_MSCG) - if (CMAKE_VERSION VERSION_LESS "3.7") # due to SOURCE_SUBDIR - message(FATAL_ERROR "For downlading MSCG you need at least cmake-3.7") - endif() if(CMAKE_GENERATOR STREQUAL "Ninja") message(FATAL_ERROR "Cannot build downloaded MSCG library with Ninja build tool") endif() diff --git a/cmake/Modules/Packages/USER-MOLFILE.cmake b/cmake/Modules/Packages/USER-MOLFILE.cmake index b8c4234d26..16ffc34994 100644 --- a/cmake/Modules/Packages/USER-MOLFILE.cmake +++ b/cmake/Modules/Packages/USER-MOLFILE.cmake @@ -1,8 +1,4 @@ if(PKG_USER-MOLFILE) - if (CMAKE_VERSION VERSION_LESS "3.10") # due to INTERFACE without a library - message(FATAL_ERROR "For configuring USER-MOLFILE you need CMake 3.10 or later") - endif() - set(MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers") add_library(molfile INTERFACE) target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS}) diff --git a/doc/src/Build_cmake.rst b/doc/src/Build_cmake.rst index 8314afaa0e..939431c6b3 100644 --- a/doc/src/Build_cmake.rst +++ b/doc/src/Build_cmake.rst @@ -95,10 +95,8 @@ this directory or sub-directories within it that CMake creates. directory to un-install all packages. The purge removes all the \*.h files auto-generated by make. -You must have CMake version 2.8 or later on your system to build -LAMMPS. A handful of LAMMPS packages (KOKKOS, LATTE, MSCG) require a -later version. CMake will print a message telling you if a later -version is required. Installation instructions for CMake are below. +You must have CMake version 3.10 or later on your system to build +LAMMPS. Installation instructions for CMake are below. After the initial build, if you edit LAMMPS source files, or add your own new files to the source directory, you can just re-type make from diff --git a/doc/src/Build_settings.rst b/doc/src/Build_settings.rst index 1e668ee95d..5f835f76a0 100644 --- a/doc/src/Build_settings.rst +++ b/doc/src/Build_settings.rst @@ -23,11 +23,11 @@ explain how to do this for building both with CMake and make. C++11 standard compliance ------------------------------------------ -The LAMMPS developers plan to transition to make the C++11 standard the -minimum requirement for compiling LAMMPS. Currently this only applies to -some packages like KOKKOS while the rest aims to be compatible with the C++98 -standard. Most currently used compilers are compatible with C++11; some need -to set extra flags to enable C++11 compliance. Example for GNU c++: +A C++11 standard compatible compiler is a requirement for compiling LAMMPS. +LAMMPS version 3 March 2020 is the last version compatible with the previous +C++98 standard for the core code and most packages. Most currently used +C++ compilers are compatible with C++11, but some older ones may need extra +flags to enable C++11 compliance. Example for GNU c++ 4.8.x: .. code-block:: make diff --git a/src/lmptype.h b/src/lmptype.h index 65e46535fc..5c19ab7483 100644 --- a/src/lmptype.h +++ b/src/lmptype.h @@ -28,6 +28,12 @@ #ifndef LMP_LMPTYPE_H #define LMP_LMPTYPE_H +// C++11 check + +#if __cplusplus < 201103L +#error LAMMPS requires a C++11 (or later) compliant compiler. Enable C++11 compatibility or upgrade the compiler. +#endif + #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS #endif @@ -38,8 +44,8 @@ #include #include -#include // requires C++-11 -#include // requires C++-11 +#include +#include // grrr - IBM Power6 does not provide this def in their system header files