From d29e5af0c7a2cca4b2d8f2ad19f7356fd522bb44 Mon Sep 17 00:00:00 2001 From: Mark Dewing Date: Fri, 19 Oct 2018 17:03:50 -0500 Subject: [PATCH] Increase cmake minimum to 3.6.0. Remove the unneeded cmake version tests. Switch to the cmake mechanism for specifying the C++11 standard 3.6.0 is the first version that gets the C++11 flags correct for the Intel compiler Addresses #832 --- CMakeLists.txt | 36 ++++++----------------------------- src/CMakeLists.txt | 15 ++++----------- src/QMCDrivers/CMakeLists.txt | 6 ++---- 3 files changed, 12 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b5fd3d3fa..db87259832 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,15 +2,15 @@ PROJECT(qmcpack) ##################################################### -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10) +CMAKE_MINIMUM_REQUIRED(VERSION 3.6.0) IF(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) - IF(CMAKE_VERSION VERSION_GREATER 3.1.3 AND NOT $ENV{CRAYPE_VERSION} MATCHES ".") + IF(NOT $ENV{CRAYPE_VERSION} MATCHES ".") cmake_policy(SET CMP0056 NEW) # This policy insures that the CMAKE_EXE_LINKER_FLAGS of the calling project # are used in try_compile test cmake projects. # CHECK_CXX_SOURCE_COMPILES and others depend on try_compile - endif(CMAKE_VERSION VERSION_GREATER 3.1.3 AND NOT $ENV{CRAYPE_VERSION} MATCHES ".") + endif(NOT $ENV{CRAYPE_VERSION} MATCHES ".") IF(CMAKE_GENERATOR MATCHES "Ninja") cmake_policy(SET CMP0058 NEW) ENDIF(CMAKE_GENERATOR MATCHES "Ninja") @@ -374,33 +374,9 @@ ELSE(CMAKE_TOOLCHAIN_FILE) MESSAGE(WARNING "No default file for compiler (${COMPILER})") ENDIF() - # Check for the compiler C++11 flag, if we go to requiring >= cmake 3.1.3 we could drop this - # and just write - # set(CMAKE_CXX_STANDARD_REQUIRED 11 CACHE INTEGER "C++ stangard must be at least 11") - SET(CXX11_FLAG "-std=c++11") - #check if the CXX compiler supports -std=c++11 option - include(CheckCXXCompilerFlag) # works with clean load paths and non system compilers with CMP0056 - CHECK_CXX_COMPILER_FLAG(${CXX11_FLAG} CXX_COMPILER_SUPPORT_CXX11) - - # Force the flag on Cray with Intel compiler, because the Cray wrapper - # prints an warning that interferes with the flag detection code - # with older versions of CMake. - IF($ENV{CRAYPE_VERSION} MATCHES ".") - IF( ${COMPILER} MATCHES "Intel" AND NOT CXX_COMPILER_SUPPORT_CXX11) - SET(CXX_COMPILER_SUPPORT_CXX11 TRUE) - MESSAGE(STATUS "Forcing C++11 support on Cray with Intel") - ENDIF() - ENDIF() - - IF (CXX_COMPILER_SUPPORT_CXX11) - # avoid repeated -std=c++11 flag - STRING(REPLACE "++" "\\+\\+" CXX11_FLAG_MATCH ${CXX11_FLAG}) - IF(NOT CMAKE_CXX_FLAGS MATCHES ${CXX11_FLAG_MATCH}) - SET (CMAKE_CXX_FLAGS "${CXX11_FLAG} ${CMAKE_CXX_FLAGS}") - ENDIF() - ELSE() - MESSAGE(FATAL_ERROR "A compiler supporting C++11 is required. Use a newer C++ compiler.") - ENDIF() + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) #------------------------------------------------------------------- # check MPI installation diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 44c90657dd..95974d6f52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -327,11 +327,6 @@ ENDIF() #ENDIF(BUILD_QMCTOOLS) if (BUILD_UNIT_TESTS) #{ - SET(HAS_TARGET_COMPILE_DEFINITIONS 1) - IF (CMAKE_VERSION VERSION_LESS "2.8.11") - MESSAGE("CMake version 2.8.10 - some unit tests will not be built") - SET(HAS_TARGET_COMPILE_DEFINITIONS 0) - ENDIF() #Unit test directories INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/external_codes/catch) INCLUDE(${PROJECT_SOURCE_DIR}/CMake/unit_test.cmake) @@ -349,12 +344,10 @@ ENDIF() SUBDIRS(QMCHamiltonians/tests) SUBDIRS(type_traits/tests) - IF (HAS_TARGET_COMPILE_DEFINITIONS) - SUBDIRS(ParticleBase/tests) - SUBDIRS(Estimators/tests) - SUBDIRS(QMCDrivers/tests) - SUBDIRS(QMCApp/tests) - ENDIF() + SUBDIRS(ParticleBase/tests) + SUBDIRS(Estimators/tests) + SUBDIRS(QMCDrivers/tests) + SUBDIRS(QMCApp/tests) endif() #} endif() #}}} diff --git a/src/QMCDrivers/CMakeLists.txt b/src/QMCDrivers/CMakeLists.txt index 5e46c6e9bf..66f81d50c3 100644 --- a/src/QMCDrivers/CMakeLists.txt +++ b/src/QMCDrivers/CMakeLists.txt @@ -95,10 +95,8 @@ ENDIF(QMC_BUILD_LEVEL GREATER 1) # create libqmc #################################### ADD_LIBRARY(qmcdriver ${QMCDRIVERS}) -IF (HAS_TARGET_COMPILE_DEFINITIONS) - ADD_LIBRARY(qmcdriver_unit ${QMCDRIVERS}) - USE_FAKE_RNG(qmcdriver_unit) -ENDIF() +ADD_LIBRARY(qmcdriver_unit ${QMCDRIVERS}) +USE_FAKE_RNG(qmcdriver_unit) #IF(QMC_BUILD_STATIC) # ADD_LIBRARY(qmcdriver STATIC ${QMCDRIVERS}) #ELSE(QMC_BUILD_STATIC)