Skip to content

Commit

Permalink
Merge pull request #81 from ye-luo/propagate-cmake-changes
Browse files Browse the repository at this point in the history
Propagate cmake changes from QMCPACK.
  • Loading branch information
markdewing authored Jan 9, 2018
2 parents d8de01d + 483a082 commit 66e8ff5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 83 deletions.
13 changes: 6 additions & 7 deletions CMake/ClangCompilers.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Check compiler version
IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.0 )
IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3 )
MESSAGE(STATUS "Compiler Version ${CMAKE_CXX_COMPILER_VERSION}")
MESSAGE(FATAL_ERROR "Require clang 3.0 or higher ")
MESSAGE(FATAL_ERROR "Requires clang 3.3 or higher ")
ENDIF()

# Set the std
Expand All @@ -23,7 +23,10 @@ SET( HAVE_POSIX_MEMALIGN 0 ) # Clang doesn't support -malign-double

# Suppress compile warnings
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated -Wno-unused-value")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-unused-value -Wno-undefined-var-template")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-unused-value")
IF ( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.8 )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-undefined-var-template")
ENDIF()

# Set extra optimization specific flags
SET( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math" )
Expand Down Expand Up @@ -56,10 +59,6 @@ IF(QMC_BUILD_STATIC)
SET(CMAKE_CXX_LINK_FLAGS " -static")
ENDIF(QMC_BUILD_STATIC)

# Add enviornmental flags
SET(CMAKE_CXX_FLAGS "$ENV{CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "$ENV{CC_FLAGS} ${CMAKE_C_FLAGS}")

# Coverage
IF (ENABLE_GCOV)
SET(GCOV_COVERAGE TRUE)
Expand Down
6 changes: 3 additions & 3 deletions CMake/FindMKL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ FILE( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl.cxx"
"#include <iostream>\n #include <mkl.h>\n int main() { return 0; }\n" )
try_compile(HAVE_MKL ${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl.cxx
CMAKE_FLAGS "${CMAKE_CXX_FLAGS} -mkl" )
COMPILE_DEFINITIONS "-mkl" )

# Check for mkl_vml_functions.h
FILE( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_vml.cxx"
"#include <iostream>\n #include <mkl_vml_functions.h>\n int main() { return 0; }\n" )
try_compile(HAVE_MKL_VML ${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_vml.cxx
CMAKE_FLAGS "${CMAKE_CXX_FLAGS} -mkl" )
COMPILE_DEFINITIONS "-mkl" )

# Check for fftw3
FILE( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_fftw3.cxx"
"#include <iostream>\n #include <fftw/fftw3.h>\n int main() { return 0; }\n" )
try_compile(HAVE_MKL_FFTW3 ${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_fftw3.cxx
CMAKE_FLAGS "${CMAKE_CXX_FLAGS} -mkl" )
COMPILE_DEFINITIONS "-mkl" )

IF ( HAVE_MKL )
SET( MKL_FOUND 1 )
Expand Down
8 changes: 2 additions & 6 deletions CMake/GNUCompilers.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Check compiler version
IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4 )
MESSAGE(FATAL_ERROR "Require gcc 4.4 or higher ")
IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8 )
MESSAGE(FATAL_ERROR "Requires gcc 4.8 or higher ")
ENDIF()

# Set the std
Expand Down Expand Up @@ -52,10 +52,6 @@ IF(QMC_BUILD_STATIC)
SET(CMAKE_CXX_LINK_FLAGS " -static")
ENDIF(QMC_BUILD_STATIC)

# Add enviornmental flags
SET(CMAKE_CXX_FLAGS "$ENV{CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "$ENV{CC_FLAGS} ${CMAKE_C_FLAGS}")

# Coverage
IF (ENABLE_GCOV)
SET(GCOV_SUPPORTED TRUE)
Expand Down
4 changes: 2 additions & 2 deletions CMake/IntelCompilers.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Check compiler version
SET(INTEL_COMPILER 1)
IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0 )
MESSAGE(FATAL_ERROR "Require intel 8.0 or higher ")
IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0 )
MESSAGE(FATAL_ERROR "Requires Intel 15.0 or higher ")
ENDIF()

# Set the std
Expand Down
76 changes: 11 additions & 65 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,36 +95,9 @@ SET(ENABLE_GCOV FALSE CACHE BOOL "Enable code coverage")
######################################################################
SET(QMC_MPI 1 CACHE BOOL "Enable/disable MPI")
SET(QMC_OMP 1 CACHE BOOL "Enable/disable OpenMP")
SET(QMC_BITS 64 CACHE INTEGER "Select OS bit")
SET(QMC_COMPLEX 0 CACHE INTEGER "Build for complex binary")
SET(PRINT_DEBUG 0 CACHE BOOL "Enable/disable debug printing")

######################################################################
# set debug printout
# DEBUG_PSIBUFFER_ON keep track buffer's locator
######################################################################
SET(DEBUG_PSIBUFFER_ON 0 CACHE BOOL "Build with GPU support through CUDA")
######################################################################
# check environment variables
# todo: disallow environment
######################################################################
IF($ENV{QMC_MPI})
SET(QMC_MPI $ENV{QMC_MPI})
MESSAGE(STATUS "Found environment QMC_MPI=${QMC_MPI}")
ENDIF($ENV{QMC_MPI})
IF($ENV{QMC_OMP})
SET(QMC_OMP $ENV{QMC_OMP})
MESSAGE(STATUS "Found environment QMC_OMP=${QMC_OMP}")
ENDIF($ENV{QMC_OMP})
IF($ENV{QMC_BITS})
SET(QMC_BITS $ENV{QMC_BITS})
MESSAGE(STATUS "Found environment QMC_BITS=${QMC_BITS}")
ENDIF($ENV{QMC_BITS})
IF($ENV{QMC_COMPLEX})
SET(QMC_COMPLEX $ENV{QMC_COMPLEX})
MESSAGE(STATUS "Found environment QMC_COMPLEX=${QMC_COMPLEX}")
ENDIF($ENV{QMC_COMPLEX})

######################################################################
# Standard test
######################################################################
Expand Down Expand Up @@ -176,16 +149,6 @@ SET(BUILD_FCIQMC 0 CACHE BOOL "Build with FCIQMC")
SET(QMC_BUILD_STATIC 0 CACHE BOOL "Link to static libraries")
SET(ENABLE_TIMERS 1 CACHE BOOL "Enable internal timers")

######################################################################
# Performance-related macros
# QMC_SK_USE_RECURSIVE enable/disable recursive evalaution of SK
######################################################################
SET(QMC_SK_USE_RECURSIVE 0)
IF($ENV{QMC_SK_RECURSIVE})
MESSAGE(STATUS "SK structure factor uses a recursive algorithm.")
SET(QMC_SK_USE_RECURSIVE $ENV{QMC_SK_RECURSIVE})
ENDIF($ENV{QMC_SK_RECURSIVE})

######################################################################
# FIXED PARAMETERS for test and legacy reasons
# DO NOT TOUCH THESE
Expand Down Expand Up @@ -317,31 +280,24 @@ ELSE(CMAKE_TOOLCHAIN_FILE)
ENDFOREACH(type)
ELSE(QMC_BUILD_STATIC)
MESSAGE(STATUS "Building CPU code. Linking dynamically.")
SET(CMAKE_EXE_LINKER_FLAGS "-dynamic")
ENDIF(QMC_BUILD_STATIC)
ENDIF($ENV{CRAYPE_VERSION} MATCHES ".")

#------------------------------------
# Identify the compiler
#------------------------------------
IF( $ENV{CXX} MATCHES "icpc" )
SET( COMPILER Intel )
ELSEIF($ENV{CXX} MATCHES "xlC" OR CMAKE_C_COMPILER_ID MATCHES "XL")
SET( COMPILER IBM )
ELSEIF ( CMAKE_C_COMPILER_WORKS OR CMAKE_C_COMPILER_WORKS )
IF( CMAKE_COMPILE_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
IF ( CMAKE_C_COMPILER_WORKS OR CMAKE_C_COMPILER_WORKS )
IF( (CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR ( CMAKE_C_COMPILER_ID MATCHES "GNU") )
SET( COMPILER GNU )
ELSEIF( MSVC OR MSVC_IDE OR MSVC60 OR MSVC70 OR MSVC71 OR MSVC80 OR CMAKE_COMPILER_2005 OR MSVC90 OR MSVC10 )
SET( COMPILER Microsoft )
ELSEIF( (${CMAKE_C_COMPILER_ID} MATCHES "Intel") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Intel") )
ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "XL") OR ( CMAKE_C_COMPILER_ID MATCHES "XL") )
SET( COMPILER IBM )
ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "Intel") OR (CMAKE_C_COMPILER_ID MATCHES "Intel") )
SET( COMPILER Intel )
ELSEIF( (${CMAKE_C_COMPILER_ID} MATCHES "PGI") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "PGI") )
ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "PGI") OR (CMAKE_C_COMPILER_ID MATCHES "PGI") )
SET( COMPILER PGI )
ELSEIF( (${CMAKE_C_COMPILER_ID} MATCHES "CRAY") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "CRAY") OR
(${CMAKE_C_COMPILER_ID} MATCHES "Cray") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Cray") )
ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "Cray") OR (CMAKE_C_COMPILER_ID MATCHES "Cray") )
SET( COMPILER Cray )
ELSEIF( (${CMAKE_C_COMPILER_ID} MATCHES "CLANG") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "CLANG") OR
(${CMAKE_C_COMPILER_ID} MATCHES "Clang") OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") )
ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_C_COMPILER_ID MATCHES "Clang") )
SET( COMPILER Clang )
ELSE()
SET(USING_DEFAULT TRUE)
Expand Down Expand Up @@ -467,12 +423,8 @@ IF (ENABLE_GCOV)
ENDIF()
ENDIF(ENABLE_GCOV)

# check if C++11 is needed by QMCPACK features
#SET(CXX11_NEEDED FALSE)
#IF(BUILD_LMYENGINE_INTERFACE OR BUILD_MINIAPPS OR BUILD_AFQMC OR ENABLE_AA_SOA)
SET(CXX11_NEEDED TRUE)
#ENDIF()
# once C++11 is needed
# Require C++11 while leaving possibility to fall back by modifying this file
SET(CXX11_NEEDED TRUE)
IF(CXX11_NEEDED)
SET(CXX11_FLAG "-std=c++11")
#check if the CXX compiler supports -std=c++11 option
Expand All @@ -497,13 +449,7 @@ IF(CXX11_NEEDED)
SET (CMAKE_CXX_FLAGS "${CXX11_FLAG} ${CMAKE_CXX_FLAGS}")
ENDIF()
ELSE()
MESSAGE(STATUS "Disabling features requring C++11 due to the lack of compiler support")
SET(BUILD_LMYENGINE_INTERFACE 0)
SET(BUILD_MINIAPPS 0)
SET(BUILD_AFQMC 0)
IF(ENABLE_AA_SOA)
MESSAGE(FATAL_ERROR "ENABLE_AA_SOA requires C++11 compiler support!")
ENDIF()
MESSAGE(FATAL_ERROR "A compiler supporting C++11 is required. Use a newer C++ compiler.")
ENDIF()
ENDIF(CXX11_NEEDED)

Expand Down

0 comments on commit 66e8ff5

Please sign in to comment.