Merge pull request #1915 from akohlmey/cpp-11-cmake-3.10
Require C++11 and CMake 3.10
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
# CMake build system
|
# CMake build system
|
||||||
# This file is part of LAMMPS
|
# This file is part of LAMMPS
|
||||||
# Created by Christoph Junghans and Richard Berger
|
# Created by Christoph Junghans and Richard Berger
|
||||||
cmake_minimum_required(VERSION 2.8.12)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
project(lammps CXX)
|
project(lammps CXX)
|
||||||
set(SOVERSION 0)
|
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")
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict -std=c++11")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(DISABLE_CXX11_REQUIREMENT "Disable check that requires C++11 for compiling LAMMPS" OFF)
|
# we require C++11
|
||||||
if(DISABLE_CXX11_REQUIREMENT)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
add_definitions(-DLAMMPS_CXX98)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
# else()
|
|
||||||
# set(CMAKE_CXX_STANDARD 11)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# GNU compiler features
|
# GNU compiler features
|
||||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
||||||
@ -355,9 +352,6 @@ endforeach(HEADER)
|
|||||||
set(MATH_LIBRARIES "m" CACHE STRING "math library")
|
set(MATH_LIBRARIES "m" CACHE STRING "math library")
|
||||||
mark_as_advanced( MATH_LIBRARIES )
|
mark_as_advanced( MATH_LIBRARIES )
|
||||||
include(CheckLibraryExists)
|
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
|
# RB: disabled this check because it breaks with KOKKOS CUDA enabled
|
||||||
#foreach(FUNC sin cos)
|
#foreach(FUNC sin cos)
|
||||||
# check_library_exists(${MATH_LIBRARIES} ${FUNC} "" FOUND_${FUNC}_${MATH_LIBRARIES})
|
# check_library_exists(${MATH_LIBRARIES} ${FUNC} "" FOUND_${FUNC}_${MATH_LIBRARIES})
|
||||||
|
|||||||
@ -1,7 +1,4 @@
|
|||||||
if(PKG_GPU)
|
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_DIR ${LAMMPS_SOURCE_DIR}/GPU)
|
||||||
set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h
|
set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h
|
||||||
${GPU_SOURCES_DIR}/fix_gpu.h
|
${GPU_SOURCES_DIR}/fix_gpu.h
|
||||||
|
|||||||
@ -8,9 +8,6 @@ if(PKG_LATTE)
|
|||||||
endif()
|
endif()
|
||||||
option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT})
|
option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT})
|
||||||
if(DOWNLOAD_LATTE)
|
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")
|
if(CMAKE_GENERATOR STREQUAL "Ninja")
|
||||||
message(FATAL_ERROR "Cannot build downloaded LATTE library with Ninja build tool")
|
message(FATAL_ERROR "Cannot build downloaded LATTE library with Ninja build tool")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -8,9 +8,6 @@ if(PKG_MSCG)
|
|||||||
endif()
|
endif()
|
||||||
option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" ${DOWNLOAD_MSCG_DEFAULT})
|
option(DOWNLOAD_MSCG "Download MSCG library instead of using an already installed one)" ${DOWNLOAD_MSCG_DEFAULT})
|
||||||
if(DOWNLOAD_MSCG)
|
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")
|
if(CMAKE_GENERATOR STREQUAL "Ninja")
|
||||||
message(FATAL_ERROR "Cannot build downloaded MSCG library with Ninja build tool")
|
message(FATAL_ERROR "Cannot build downloaded MSCG library with Ninja build tool")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -1,8 +1,4 @@
|
|||||||
if(PKG_USER-MOLFILE)
|
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")
|
set(MOLFILE_INCLUDE_DIRS "${LAMMPS_LIB_SOURCE_DIR}/molfile" CACHE STRING "Path to VMD molfile plugin headers")
|
||||||
add_library(molfile INTERFACE)
|
add_library(molfile INTERFACE)
|
||||||
target_include_directories(molfile INTERFACE ${MOLFILE_INCLUDE_DIRS})
|
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
|
directory to un-install all packages. The purge removes all the \*.h
|
||||||
files auto-generated by make.
|
files auto-generated by make.
|
||||||
|
|
||||||
You must have CMake version 2.8 or later on your system to build
|
You must have CMake version 3.10 or later on your system to build
|
||||||
LAMMPS. A handful of LAMMPS packages (KOKKOS, LATTE, MSCG) require a
|
LAMMPS. Installation instructions for CMake are below.
|
||||||
later version. CMake will print a message telling you if a later
|
|
||||||
version is required. Installation instructions for CMake are below.
|
|
||||||
|
|
||||||
After the initial build, if you edit LAMMPS source files, or add your
|
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
|
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
|
C++11 standard compliance
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
The LAMMPS developers plan to transition to make the C++11 standard the
|
A C++11 standard compatible compiler is a requirement for compiling LAMMPS.
|
||||||
minimum requirement for compiling LAMMPS. Currently this only applies to
|
LAMMPS version 3 March 2020 is the last version compatible with the previous
|
||||||
some packages like KOKKOS while the rest aims to be compatible with the C++98
|
C++98 standard for the core code and most packages. Most currently used
|
||||||
standard. Most currently used compilers are compatible with C++11; some need
|
C++ compilers are compatible with C++11, but some older ones may need extra
|
||||||
to set extra flags to enable C++11 compliance. Example for GNU c++:
|
flags to enable C++11 compliance. Example for GNU c++ 4.8.x:
|
||||||
|
|
||||||
.. code-block:: make
|
.. code-block:: make
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,12 @@
|
|||||||
#ifndef LMP_LMPTYPE_H
|
#ifndef LMP_LMPTYPE_H
|
||||||
#define 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
|
#ifndef __STDC_LIMIT_MACROS
|
||||||
#define __STDC_LIMIT_MACROS
|
#define __STDC_LIMIT_MACROS
|
||||||
#endif
|
#endif
|
||||||
@ -38,8 +44,8 @@
|
|||||||
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <stdint.h> // <cstdint> requires C++-11
|
#include <cstdint>
|
||||||
#include <inttypes.h> // <cinttypes> requires C++-11
|
#include <cinttypes>
|
||||||
|
|
||||||
// grrr - IBM Power6 does not provide this def in their system header files
|
// grrr - IBM Power6 does not provide this def in their system header files
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user