Skip to content

Commit

Permalink
Increase cmake minimum to 3.6.0.
Browse files Browse the repository at this point in the history
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 QMCPACK#832
  • Loading branch information
markdewing committed Oct 19, 2018
1 parent 15f9f6b commit d29e5af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 45 deletions.
36 changes: 6 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
15 changes: 4 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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() #}}}
6 changes: 2 additions & 4 deletions src/QMCDrivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d29e5af

Please sign in to comment.