forked from lijiext/lammps
Merge pull request #1915 from akohlmey/cpp-11-cmake-3.10
Require C++11 and CMake 3.10
This commit is contained in:
commit
d0160cc208
|
@ -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})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <climits>
|
||||
#include <cstdlib>
|
||||
#include <stdint.h> // <cstdint> requires C++-11
|
||||
#include <inttypes.h> // <cinttypes> requires C++-11
|
||||
#include <cstdint>
|
||||
#include <cinttypes>
|
||||
|
||||
// grrr - IBM Power6 does not provide this def in their system header files
|
||||
|
||||
|
|
Loading…
Reference in New Issue