diff --git a/CMake/ClangCompilers.cmake b/CMake/ClangCompilers.cmake index e23ad3ba3..97a299094 100644 --- a/CMake/ClangCompilers.cmake +++ b/CMake/ClangCompilers.cmake @@ -4,34 +4,26 @@ IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3 ) MESSAGE(FATAL_ERROR "Requires clang 3.3 or higher ") ENDIF() -# Set the std -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") - # Enable OpenMP IF(QMC_OMP) SET(ENABLE_OPENMP 1) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") ENDIF(QMC_OMP) # Set clang specfic flags (which we always want) ADD_DEFINITIONS( -Drestrict=__restrict__ ) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -fstrict-aliasing") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -fstrict-aliasing -D__forceinline=inline") 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") 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" ) SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math" ) -SET( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ffast-math" ) SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-math" ) #-------------------------------------- @@ -40,17 +32,11 @@ SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-ma IF((NOT $ENV{CRAYPE_VERSION} MATCHES ".") AND (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")) #check if the user has already specified -march=XXXX option for cross-compiling. -if(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") - # make sure that the user specifies -march= for both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS. - if(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") - else() #(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") - MESSAGE(FATAL_ERROR "if -march=ARCH is specified by the user, it should be added in both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS!") - endif() #(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") -else() #(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") +if(CMAKE_CXX_FLAGS MATCHES "-march=") +else() #(CMAKE_CXX_FLAGS MATCHES "-march=") # use -march=native - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") -endif() #(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") +endif() #(CMAKE_CXX_FLAGS MATCHES "-march=") ENDIF((NOT $ENV{CRAYPE_VERSION} MATCHES ".") AND (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")) @@ -63,7 +49,6 @@ ENDIF(QMC_BUILD_STATIC) IF (ENABLE_GCOV) SET(GCOV_COVERAGE TRUE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") ENDIF(ENABLE_GCOV) diff --git a/CMake/FindFFTW.cmake b/CMake/FindFFTW.cmake deleted file mode 100644 index ad972dd0b..000000000 --- a/CMake/FindFFTW.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# FFTW_INCLUDE_DIR = fftw3.h -# FFTW_LIBRARIES = libfftw3.a -# FFTW_FOUND = true if FFTW3 is found - -SET(Libfftw fftw3) -IF(QMC_BUILD_STATIC) - SET(Libfftw libfftw3.a) -ENDIF(QMC_BUILD_STATIC) - -IF(FFTW_INCLUDE_DIRS) - FIND_PATH(FFTW_INCLUDE_DIR fftw3.h ${FFTW_INCLUDE_DIRS}) - FIND_LIBRARY(FFTW_LIBRARIES ${Libfftw} ${FFTW_LIBRARY_DIRS}) -ELSE(FFTW_INCLUDE_DIRS) - FIND_PATH(FFTW_INCLUDE_DIR fftw3.h ${FFTW_HOME}/include $ENV{FFTW_HOME}/include) - FIND_LIBRARY(FFTW_LIBRARIES ${Libfftw} ${FFTW_HOME}/lib $ENV{FFTW_HOME}/lib) -ENDIF(FFTW_INCLUDE_DIRS) - -SET(FFTW_FOUND FALSE) -IF(FFTW_INCLUDE_DIR AND FFTW_LIBRARIES) - MESSAGE(STATUS "FFTW_INCLUDE_DIR=${FFTW_INCLUDE_DIR}") - MESSAGE(STATUS "FFTW_LIBRARIES=${FFTW_LIBRARIES}") - SET(FFTW_FOUND TRUE) -ENDIF() - -MARK_AS_ADVANCED( - FFTW_INCLUDE_DIR - FFTW_LIBRARIES - FFTW_FOUND -) diff --git a/CMake/FindLibxml2QMC.cmake b/CMake/FindLibxml2QMC.cmake deleted file mode 100644 index c28d878a5..000000000 --- a/CMake/FindLibxml2QMC.cmake +++ /dev/null @@ -1,57 +0,0 @@ -# -# Find libxml2 (http://www.xmlsoft.org) -# -# Prioritizes LIBXML2_HOME and QMC_BUILD_STATIC -# before calling standard cmake find_package(LibXml2) -# -# Define the following values: -# -# LibXml2_INCLUDE_DIR = where libxml/xpath.h can be found -# LibXml2_LIBRARIES = the library to link against libxml2 -# LibXml2_FOUND = set to 1 if libxml2 is found -# -# Environment variables: -# -# LIBXML2_HOME = directory containing lib/ and include/libxml2 -# - -SET(Libxml2 xml2) -IF(QMC_BUILD_STATIC) - SET(Libxml2 libxml2.a) -ENDIF(QMC_BUILD_STATIC) - -IF(Libxml2_INCLUDE_DIRS) - MESSAGE(STATUS "Trying libxml2 via Libxml2_INCLUDE_DIRS") - FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xpath.h ${Libxml2_INCLUDE_DIRS} NO_DEFAULT_PATH) - FIND_LIBRARY(LIBXML2_LIBRARIES xml2 ${Libxml2_LIBRARY_DIRS} NO_DEFAULT_PATH) -ELSE(Libxml2_INCLUDE_DIRS) - MESSAGE(STATUS "Trying libxml2 via LIBXML2_HOME") - FIND_LIBRARY(LIBXML2_LIBRARIES ${Libxml2} PATHS $ENV{LIBXML2_HOME}/lib NO_DEFAULT_PATH) - FIND_PATH(LIBXML_INCLUDE_DIR libxml2/libxml/xpath.h PATHS ${LIBXML2_HOME}/include $ENV{LIBXML2_HOME}/include NO_DEFAULT_PATH) - if(LIBXML_INCLUDE_DIR) - set(LIBXML2_INCLUDE_DIR ${LIBXML_INCLUDE_DIR}/libxml2) - else(LIBXML_INCLUDE_DIR) - FIND_PATH(LIBXML2_INCLUDE_DIR libxml/xpath.h $ENV{LIBXML2_HOME}/include) - endif(LIBXML_INCLUDE_DIR) -ENDIF(Libxml2_INCLUDE_DIRS) - -SET(LIBXML2_FOUND FALSE) -IF(LIBXML2_INCLUDE_DIR AND LIBXML2_LIBRARIES) - MESSAGE(STATUS "LIBXML2_INCLUDE_DIR=${LIBXML2_INCLUDE_DIR}") - MESSAGE(STATUS "LIBXML2_LIBRARIES=${LIBXML2_LIBRARIES}") - SET(LIBXML2_FOUND TRUE) -ENDIF() - -IF(LIBXML2_FOUND) - MESSAGE(STATUS "Libxml2 found by FindLibxml2QMC") -ELSE(LIBXML2_FOUND) - MESSAGE(STATUS "Locating Libxml2 via FIND_PACKAGE") - FIND_PACKAGE(LibXml2) -ENDIF(LIBXML2_FOUND) - -MARK_AS_ADVANCED( - LIBXML2_INCLUDE_DIR - LIBXML2_LIBRARIES - LIBXML2_FOUND - ) - diff --git a/CMake/FindMKL.cmake b/CMake/FindMKL.cmake index 29b6674ea..dd08d2c05 100644 --- a/CMake/FindMKL.cmake +++ b/CMake/FindMKL.cmake @@ -2,42 +2,85 @@ # This needs a lot of work to make it robust INCLUDE( CheckCXXSourceCompiles ) +if ( NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel" ) + # Extremely Basic Support of common mkl module environment variables + # or -DMKLROOT/-DMKL_HOME instead of prefered -DMKL_ROOT + if (NOT MKL_ROOT) + find_path(MKL_ROOT "mkl.h" + HINTS ${MKLROOT} ${MKL_HOME} $ENV{MKLROOT} $ENV{MKL_ROOT} $ENV{MKL_HOME} + PATH_SUFFIXES include) + string(REPLACE "/include" "" MKL_ROOT ${MKL_ROOT}) + endif (NOT MKL_ROOT) + if (NOT MKL_ROOT) + message (FATAL_ERROR "ENABLE_MKL is TRUE and mkl not found. Set MKL_ROOT." ) + endif (NOT MKL_ROOT) + + # Finding and setting the MKL_LINK_DIRECTORIES + # the directory organization varies with platform and targets + # these suffixes are not exhaustive + set(MKL_FIND_LIB "libmkl_intel_lp64${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(SUFFIXES lib lib/intel64) + find_path(MKL_LINK_DIRECTORIES name "${MKL_FIND_LIB}" HINTS ${MKL_ROOT} + PATH_SUFFIXES ${SUFFIXES}) + if (MKL_LINK_DIRECTORIES-NOTFOUND) + message(FATAL_ERROR "MKL_LINK_DIRECTORIES not set. ${MKL_FIND_LIB} " + "not found in MKL_ROOT/(${SUFFIXES})") + endif (MKL_LINK_DIRECTORIES-NOTFOUND) + message("MKL_LINK_DIRECTORIES: ${MKL_LINK_DIRECTORIES}") + + # Finding and setting the MKL_INCLUDE_DIRECTORIES + set(SUFFIXES include) + find_path(MKL_INCLUDE_DIRECTORIES name "mkl.h" HINTS ${MKL_ROOT} + PATH_SUFFIXES ${SUFFIXES}) + if (MKL_INCLUDE_DIRECTORIES-NOTFOUND) + message(FATAL_ERROR "MKL_INCLUDE_DIRECTORIES not set. \"mkl.h\" not found in MKL_ROOT/(${SUFFIXES})") + endif (MKL_INCLUDE_DIRECTORIES-NOTFOUND) + message("MKL_INCLUDE_DIRECTORIES: ${MKL_INCLUDE_DIRECTORIES}") + + set(MKL_LINKER_FLAGS "-L${MKL_LINK_DIRECTORIES} -Wl,-rpath,${MKL_LINK_DIRECTORIES}") + set(MKL_FLAGS "-I${MKL_INCLUDE_DIRECTORIES}") + set(MKL_LIBRARIES "-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl") +else ( NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel" ) + # this takes away build control for intel but is convenient + set(MKL_FLAGS "-mkl") + set(MKL_COMPILE_DEFINITIONS "-mkl") +endif (NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel" ) + # Check for mkl.h FILE( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl.cxx" - "#include \n #include \n int main() { return 0; }\n" ) + "#include \n #include \n int main() { return 0; }\n" ) try_compile(HAVE_MKL ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl.cxx - COMPILE_DEFINITIONS "-mkl" ) + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl.cxx + CMAKE_FLAGS ${MKL_FLAGS} + "-DINCLUDE_DIRECTORIES=${MKL_INCLUDE_DIRECTORIES} " + "-DLINK_DIRECTORIES=${MKL_LINK_DIRECTORIES}" + LINK_LIBRARIES "${MKL_LIBRARIES}" + COMPILE_DEFINITIONS "${MKL_COMPILE_DEFINITIONS}" + OUTPUT_VARIABLE MKL_OUT) + +if ( NOT HAVE_MKL ) + MESSAGE( "${MKL_OUT}" ) +endif ( NOT HAVE_MKL ) # Check for mkl_vml_functions.h FILE( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_vml.cxx" - "#include \n #include \n int main() { return 0; }\n" ) + "#include \n #include \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 - COMPILE_DEFINITIONS "-mkl" ) - -# Check for fftw3 -FILE( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_fftw3.cxx" - "#include \n #include \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 - COMPILE_DEFINITIONS "-mkl" ) + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src_mkl_vml.cxx + CMAKE_FLAGS ${MKL_FLAGS} + "-DINCLUDE_DIRECTORIES=${MKL_INCLUDE_DIRECTORIES} " + "-DLINK_DIRECTORIES=${MKL_LINK_DIRECTORIES}" + COMPILE_DEFINITIONS "${MKL_COMPILE_DEFINITIONS}" + OUTPUT_VARIABLE MKL_OUT) IF ( HAVE_MKL ) - SET( MKL_FOUND 1 ) - SET( MKL_FLAGS -mkl ) - SET( MKL_LIBRARIES ) - SET( MKL_LINKER_FLAGS -mkl ) - IF ( HAVE_MKL_FFTW3 ) - FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/fftw3.h" "#include \n" ) - INCLUDE_DIRECTORIES( "${CMAKE_CURRENT_BINARY_DIR}/include" ) - ENDIF() - MESSAGE(STATUS "MKL found: HAVE_MKL=${HAVE_MKL}, HAVE_MKL_VML=${HAVE_MKL_VML}, HAVE_MKL_FFTW3=${HAVE_MKL_FFTW3}") -ELSE() - SET( MKL_FOUND 0 ) - SET( MKL_FLAGS ) - SET( MKL_LIBRARIES ) - SET( MKL_LINKER_FLAGS ) - MESSAGE(STATUS "MKL not found") -ENDIF() - + SET( MKL_FOUND 1 ) + SET( MKL_FLAGS ${MKL_FLAGS} ) + MESSAGE(STATUS "MKL found: HAVE_MKL=${HAVE_MKL}, HAVE_MKL_VML=${HAVE_MKL_VML}") +ELSE( HAVE_MKL ) + SET( MKL_FOUND 0 ) + SET( MKL_FLAGS ) + SET( MKL_LIBRARIES ) + SET( MKL_LINKER_FLAGS ) + MESSAGE("MKL not found") +ENDIF( HAVE_MKL ) diff --git a/CMake/GNUCompilers.cmake b/CMake/GNUCompilers.cmake index 8666bf366..e0fb172eb 100755 --- a/CMake/GNUCompilers.cmake +++ b/CMake/GNUCompilers.cmake @@ -3,30 +3,22 @@ IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8 ) MESSAGE(FATAL_ERROR "Requires gcc 4.8 or higher ") ENDIF() -# Set the std -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") - # Enable OpenMP IF(QMC_OMP) SET(ENABLE_OPENMP 1) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") ENDIF(QMC_OMP) # Set gnu specfic flags (which we always want) ADD_DEFINITIONS( -Drestrict=__restrict__ ) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -finline-limit=1000 -fstrict-aliasing -funroll-all-loops") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer -finline-limit=1000 -fstrict-aliasing -funroll-all-loops -D__forceinline=inline") # Suppress compile warnings -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") # Set extra optimization specific flags -SET( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math" ) SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math" ) -SET( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ffast-math" ) SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-math" ) #-------------------------------------- @@ -35,17 +27,11 @@ SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-ma IF((NOT $ENV{CRAYPE_VERSION} MATCHES ".") AND (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")) #check if the user has already specified -march=XXXX option for cross-compiling. -if(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") - # make sure that the user specifies -march= for both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS. - if(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") - else() #(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") - MESSAGE(FATAL_ERROR "if -march=ARCH is specified by the user, it should be added in both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS!") - endif() #(CMAKE_CXX_FLAGS MATCHES "-march=" AND CMAKE_C_FLAGS MATCHES "-march=") -else() #(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") +if(CMAKE_CXX_FLAGS MATCHES "-march=") +else() #(CMAKE_CXX_FLAGS MATCHES "-march=") # use -march=native - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") -endif() #(CMAKE_CXX_FLAGS MATCHES "-march=" OR CMAKE_C_FLAGS MATCHES "-march=") +endif() #(CMAKE_CXX_FLAGS MATCHES "-march=") ENDIF((NOT $ENV{CRAYPE_VERSION} MATCHES ".") AND (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")) @@ -58,7 +44,6 @@ ENDIF(QMC_BUILD_STATIC) IF (ENABLE_GCOV) SET(GCOV_SUPPORTED TRUE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") ENDIF(ENABLE_GCOV) diff --git a/CMake/IBMCompilers.cmake b/CMake/IBMCompilers.cmake index 420c9ca04..d5534a781 100755 --- a/CMake/IBMCompilers.cmake +++ b/CMake/IBMCompilers.cmake @@ -4,10 +4,6 @@ MESSAGE(STATUS "Power8+ system using xlC/xlc/xlf") ADD_DEFINITIONS( -Drestrict=__restrict__ ) # Clean up flags - -IF(CMAKE_C_FLAGS MATCHES "-qhalt=e") - SET(CMAKE_C_FLAGS "") -ENDIF() IF(CMAKE_CXX_FLAGS MATCHES "-qhalt=e") SET(CMAKE_CXX_FLAGS "") ENDIF() @@ -15,18 +11,14 @@ ENDIF() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__forceinline=inline") # 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") # Set extra optimization specific flags -SET( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" ) SET( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" ) -SET( CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O3" ) SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3" ) # Set language standardards -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -qnoxlcompatmacros") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qnoxlcompatmacros") IF(QMC_OMP) SET(ENABLE_OPENMP 1) diff --git a/CMake/IntelCompilers.cmake b/CMake/IntelCompilers.cmake index 8f0e23d17..ef977dece 100755 --- a/CMake/IntelCompilers.cmake +++ b/CMake/IntelCompilers.cmake @@ -4,50 +4,37 @@ IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0 ) MESSAGE(FATAL_ERROR "Requires Intel 15.0 or higher ") ENDIF() -# Set the std -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") - # Enable OpenMP IF(QMC_OMP) SET(ENABLE_OPENMP 1) IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16 ) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -openmp") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -openmp") ELSE() - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qopenmp") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qopenmp") ENDIF() ENDIF(QMC_OMP) # Suppress compile warnings -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") # Set extra optimization specific flags -SET( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -restrict -unroll -ip" ) SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -restrict -unroll -ip" ) -SET( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -restrict -unroll -ip" ) SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -restrict -unroll -ip" ) -SET( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -restrict -unroll -ip" ) SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -restrict -unroll -ip" ) # Use deprecated options prior to 11.1 SET(ICC_DEPRECATED_OPTS FALSE) IF ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.1 ) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -prefetch ") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -prefetch" ) ELSEIF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16 ) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -opt-prefetch" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -opt-prefetch" ) ELSE() -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qopt-prefetch" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qopt-prefetch" ) ENDIF() #check if -ftz is accepted -CHECK_C_COMPILER_FLAG( "${CMAKE_CXX_FLAGS} -ftz" INTEL_FTZ ) +CHECK_CXX_COMPILER_FLAG( "${CMAKE_CXX_FLAGS} -ftz" INTEL_FTZ ) IF( INTEL_FTZ) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftz" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftz" ) ENDIF( INTEL_FTZ) @@ -57,23 +44,13 @@ ENDIF( INTEL_FTZ) IF(NOT $ENV{CRAYPE_VERSION} MATCHES ".") #check if the user has already specified -x option for cross-compiling. -if(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_C_FLAGS MATCHES "-x" OR - CMAKE_CXX_FLAGS MATCHES "-ax" OR CMAKE_C_FLAGS MATCHES "-ax") - # make sure that the user specifies -x for both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS. - if(CMAKE_CXX_FLAGS MATCHES "-x" AND CMAKE_C_FLAGS MATCHES "-x") - else() #(CMAKE_CXX_FLAGS MATCHES "-x" AND CMAKE_C_FLAGS MATCHES "-x") - if(CMAKE_CXX_FLAGS MATCHES "-ax" AND CMAKE_C_FLAGS MATCHES "-ax") - else() - MESSAGE(FATAL_ERROR "if -xcode or -axcode is specified by the user, it should be added in both CMAKE_CXX_FLAGS and CMAKE_C_FLAGS!") - endif() - endif() #(CMAKE_CXX_FLAGS MATCHES "-x" AND CMAKE_C_FLAGS MATCHES "-x") -else() #(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_C_FLAGS MATCHES "-x") +if(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_CXX_FLAGS MATCHES "-ax") +else() #(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_CXX_FLAGS MATCHES "-ax") #check if -xHost is accepted - CHECK_C_COMPILER_FLAG( "-xHost" INTEL_CC_FLAGS ) - IF(INTEL_CC_FLAGS) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xHost") + CHECK_CXX_COMPILER_FLAG( "-xHost" INTEL_CXX_FLAGS ) + IF(INTEL_CXX_FLAGS) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost") - ENDIF(INTEL_CC_FLAGS) -endif() #(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_C_FLAGS MATCHES "-x") + ENDIF(INTEL_CXX_FLAGS) +endif() #(CMAKE_CXX_FLAGS MATCHES "-x" OR CMAKE_CXX_FLAGS MATCHES "-ax") ENDIF(NOT $ENV{CRAYPE_VERSION} MATCHES ".") diff --git a/CMakeLists.txt b/CMakeLists.txt index 343c84bda..0d856dfa3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,18 @@ -PROJECT(qmcpack) - - -##################################################### -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10) -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) +###################################################################### +# GLOBAL +###################################################################### +CMAKE_MINIMUM_REQUIRED(VERSION 3.6.0) +cmake_policy(SET CMP0003 NEW) +#Actually set CXX11 flag for Clang on Apple, even llvm non apple clang +#This is contrary to what the --help-policy says +cmake_policy(SET CMP0025 NEW) +###################################################################### +PROJECT(qmcpack CXX) +###################################################################### ###################################################################### -# Version +# Version ###################################################################### SET(QMCPACK_VERSION_MAJOR 3) SET(QMCPACK_VERSION_MINOR 1) @@ -17,7 +20,7 @@ SET(QMCPACK_VERSION_PATCH 0) SET(QMCPACK_VERSION "${QMCPACK_VERSION_MAJOR}.${QMCPACK_VERSION_MINOR}.${QMCPACK_VERSION_PATCH}") ###################################################################### -# CTest +# CTest ###################################################################### SET( DROP_METHOD "http" ) SET( DROP_SITE "cdash.qmcpack.org" ) @@ -68,9 +71,8 @@ SET (EXECUTABLE_OUTPUT_PATH ${qmcpack_BINARY_DIR}/bin CACHE PATH "Single output # OHMMS_PRECISION = base precision, float, double etc # OHMMS_PRECISION_FULL = full precision, double etc # QMC_COMPLEX = true if using complex wavefunctions -# QMC_MPI = enable MPI -# QMC_OMP = enable OMP -# QMC_BITS = 32/64 bit +# QMC_MPI = enable MPI +# QMC_OMP = enable OMP ###################################################################### SET(OHMMS_DIM 3 CACHE INTEGER "Select physical dimension") SET(OHMMS_INDEXTYPE int) @@ -108,31 +110,17 @@ SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH}) # add macros to compile einspline if necessary ###################################################################### INCLUDE(${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) -INCLUDE(${CMAKE_ROOT}/Modules/CheckTypeSize.cmake) CHECK_FUNCTION_EXISTS(sincos HAVE_SINCOS) CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN) -CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H) -CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H) -CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H) -CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) -CHECK_INCLUDE_FILE(sys/time.h HAVE_SYS_TIME_H) -CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) -CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) - ###################################################################### # Build options # QMC_BUILD_STATIC build static/dynamic libraries # BUILD_QMCTOOLS build utility programs # BUILD_SANDBOX build test programs -# BUILD_MINIAPPS build miniapps (Incomplete) -# MPIP_PROFILE profile mpi performance ###################################################################### -SET(QMC_ADIOS 0 CACHE BOOL "Build with ADIOS") SET(BUILD_UNIT_TESTS 1 CACHE BOOL "Build unit tests") -SET(BUILD_MINIAPPS 1 CACHE BOOL "Build miniapps") SET(BUILD_LMYENGINE_INTERFACE 1 CACHE BOOL "Build LMY engine") iF(MIXED_PRECISION AND BUILD_LMYENGINE_INTERFACE) MESSAGE(STATUS "LMY engine is not compatiable with CPU mixed precision build! Disabling LMY engine") @@ -140,12 +128,6 @@ iF(MIXED_PRECISION AND BUILD_LMYENGINE_INTERFACE) ENDIF() SET(BUILD_AFQMC 0 CACHE BOOL "Build with AFQMC") SET(BUILD_FCIQMC 0 CACHE BOOL "Build with FCIQMC") -#SET(BUILD_QMCTOOLS 1 CACHE BOOL "Build tools for QMCPACK") -#SET(BUILD_SANDBOX 0 CACHE BOOL "Build snadbox for testing") -#SET(MPIP_PROFILE 0 CACHE BOOL "Build with mpip for mpi profile") -#SET(BUILD_QMCTOOLS 1) -#SET(BUILD_SANDBOX 0) -#SET(MPIP_PROFILE 0) SET(QMC_BUILD_STATIC 0 CACHE BOOL "Link to static libraries") SET(ENABLE_TIMERS 1 CACHE BOOL "Enable internal timers") @@ -163,9 +145,6 @@ SET(OHMMS_ORTHO 0) #FindXYZ.cmake will set the values if successful ###################################################################### #SET(ENABLE_PHDF5 0 CACHE BOOL "Enable phdf5 for output") -SET(HAVE_LIBXML2 1) -SET(HAVE_LIBFFTW 0) -SET(HAVE_LIBXMLPP 0) #SET(HAVE_LIBHDF5 0) SET(HAVE_LIBSPRNG 0) SET(HAVE_LIBBLITZ 0) @@ -180,27 +159,6 @@ set(TAU_HOME $ENV{TAU_HOME}) ###################################################### SET (PROJECT_CMAKE ${qmcpack_SOURCE_DIR}/CMake) -###################################################### -# set ADIOS flags -###################################################### -IF(QMC_ADIOS) - IF(NOT HAVE_ADIOS) - SET (ADIOS_FOUND 0) - INCLUDE(${PROJECT_CMAKE}/FindADIOS.cmake) - IF (${ADIOS_FOUND} EQUAL 1) - INCLUDE_DIRECTORIES(${ADIOS_INCLUDES}) - MESSAGE(STATUS "Found ADIOS") - LINK_LIBRARIES(${ADIOS_LIBRARIES}) - ADD_DEFINITIONS(-DHAVE_ADIOS) - ELSE() - MESSAGE(STATUS "Couldn't find required library ADIOS") - MESSAGE(FATAL_ERROR "ADIOS_HOME: export ADIOS_HOME=/path/to/adios") - ENDIF() - ELSE() - ADD_DEFINITIONS(-DHAVE_ADIOS) - ENDIF() -ENDIF(QMC_ADIOS) - SET(QMCPACK_UNIT_TEST_DIR ${qmcpack_BINARY_DIR}/tests/bin) ###################################################### @@ -209,19 +167,16 @@ SET(QMCPACK_UNIT_TEST_DIR ${qmcpack_BINARY_DIR}/tests/bin) ###################################################### FIND_PACKAGE(Git) -SET(IS_GIT_PROJECT false) -IF (EXISTS "${PROJECT_SOURCE_DIR}/.git") - SET(IS_GIT_PROJECT true) +IF (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + SET(IS_GIT_PROJECT 1) ENDIF() - ###################################################### #COMPILER choose one of the cmake files to customize the compiler options #If nothing is chosen, default settings by cmake will be used. #If the automatic detection does not work, comment out everything #upto COMPILER MANUAL SELECTION and use one of the customized cmake file. ###################################################### -INCLUDE(${CMAKE_ROOT}/Modules/CheckCCompilerFlag.cmake) INCLUDE(${CMAKE_ROOT}/Modules/CheckCXXCompilerFlag.cmake) @@ -273,8 +228,6 @@ ELSE(CMAKE_TOOLCHAIN_FILE) SET(BUILD_SHARED_LIBS off) SET(CMAKE_FIND_LIBRARY_SUFFIXES .a) FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE) - SET(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic") - SET(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-static") SET(CMAKE_${type}_LINK_STATIC_CXX_FLAGS "-Wl,-Bstatic") SET(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-static") ENDFOREACH(type) @@ -286,23 +239,23 @@ ELSE(CMAKE_TOOLCHAIN_FILE) #------------------------------------ # Identify the compiler #------------------------------------ - IF ( CMAKE_C_COMPILER_WORKS OR CMAKE_C_COMPILER_WORKS ) - IF( (CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR ( CMAKE_C_COMPILER_ID MATCHES "GNU") ) + IF ( CMAKE_CXX_COMPILER_WORKS ) + IF( CMAKE_CXX_COMPILER_ID MATCHES "GNU" ) SET( COMPILER GNU ) - ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "XL") OR ( CMAKE_C_COMPILER_ID MATCHES "XL") ) + ELSEIF( CMAKE_CXX_COMPILER_ID MATCHES "XL" ) SET( COMPILER IBM ) - ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "Intel") OR (CMAKE_C_COMPILER_ID MATCHES "Intel") ) + ELSEIF( CMAKE_CXX_COMPILER_ID MATCHES "Intel" ) SET( COMPILER Intel ) - ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "PGI") OR (CMAKE_C_COMPILER_ID MATCHES "PGI") ) + ELSEIF( CMAKE_CXX_COMPILER_ID MATCHES "PGI" ) SET( COMPILER PGI ) - ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "Cray") OR (CMAKE_C_COMPILER_ID MATCHES "Cray") ) + ELSEIF( CMAKE_CXX_COMPILER_ID MATCHES "Cray" ) SET( COMPILER Cray ) - ELSEIF( (CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_C_COMPILER_ID MATCHES "Clang") ) + ELSEIF( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) SET( COMPILER Clang ) ELSE() - SET(USING_DEFAULT TRUE) - MESSAGE("${CMAKE_C_COMPILER_ID}") - MESSAGE(WARNING "Unknown C/C++ compiler, default flags will be used") + SET(USING_DEFAULT TRUE) + MESSAGE("${CMAKE_CXX_COMPILER_ID}") + MESSAGE(WARNING "Unknown C++ compiler, default flags will be used") ENDIF() ELSE() MESSAGE(WARNING "No compiler identified") @@ -324,6 +277,11 @@ ELSE(CMAKE_TOOLCHAIN_FILE) MESSAGE(WARNING "No default file for compiler (${COMPILER})") ENDIF() + # requires C++11 standard + SET(CMAKE_CXX_STANDARD 11) + SET(CMAKE_CXX_STANDARD_REQUIRED ON) + SET(CMAKE_CXX_EXTENSIONS OFF) + #------------------------------------------------------------------- # check MPI installation #------------------------------------------------------------------- @@ -343,17 +301,17 @@ ELSE(CMAKE_TOOLCHAIN_FILE) IF(MPI_FOUND) MESSAGE(STATUS "Found mpi.h and libraries. Check for working mpi compiler ") INCLUDE_DIRECTORIES(${MPI_CXX_INCLUDE_PATH}) - FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testmpi.cxx + FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testmpi.cxx "#include " "int main(int argc, char** argv){MPI_Init(&argc,&argv); MPI_Finalize();return 0;}\n") - #TRY_COMPILE(MPI_WORKS ${CMAKE_BINARY_DIR} + #TRY_COMPILE(MPI_WORKS ${CMAKE_BINARY_DIR} #${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testmpi.cxx #OUTPUT_VARIABLE OUTPUT) set(MPI_WORKS 1) SET(MPI_WARNING_LIST "Building MPI version without using MPI compiler wrappers.\n" "This may not build qmcpack correctly. To ensure the correct version, specify the compiler wrappers to cmake.\n" - "For example: cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpic++\n" + "For example: cmake -DCMAKE_CXX_COMPILER=mpic++\n" "To build without MPI, pass '-DQMC_MPI=0' to cmake") MESSAGE(WARNING ${MPI_WARNING_LIST}) @@ -378,13 +336,19 @@ ELSE(CMAKE_TOOLCHAIN_FILE) #------------------------------------------------------------------- # check lapack/blas #------------------------------------------------------------------- - # Quick search for MKL (this will need to be improved). Currently only for Intel compilers + # Quick search for MKL (this will need to be improved). + # This reproduces the old intel -mkl behavior or + # if ENABLE_MKL is set to 1 supports other compilers IF (INTEL_COMPILER) + SET(ENABLE_MKL TRUE CACHE BOOL "ENABLE MKL for Intel compilers") + ELSE (INTEL_COMPILER) + SET(ENABLE_MKL FALSE CACHE BOOL "ENABLE MKL for non-intel compilers (Experimental)") + ENDIF (INTEL_COMPILER) + IF (ENABLE_MKL) INCLUDE(CMake/FindMKL.cmake) - ENDIF(INTEL_COMPILER) + ENDIF(ENABLE_MKL) IF ( HAVE_MKL ) # We found MKL, add the link library - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MKL_FLAGS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MKL_FLAGS}") SET(LAPACK_FOUND 1) SET(LAPACK_LIBRARIES "${MKL_LIBRARIES}") @@ -423,36 +387,6 @@ IF (ENABLE_GCOV) ENDIF() ENDIF(ENABLE_GCOV) -# 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 - include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG(${CXX11_FLAG} CXX_COMPILER_SUPPORT_CXX11) - # Turn on C++11 for this code - - # 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() -ENDIF(CXX11_NEEDED) - # AFQMC requires MKL sparse for good performance (roughly a factor of 2x) IF (BUILD_AFQMC AND NOT MKL_FOUND) MESSAGE(WARNING "AFQMC - MKL not found, using simple sparse matrix routines. Link with MKL sparse libraries for better performance.") @@ -486,7 +420,6 @@ IF ( HAVE_MPI ) ENDIF(HAVE_MPI) MESSAGE(STATUS "CXX compiler flags: ${CMAKE_CXX_FLAGS}") -MESSAGE(STATUS "CC compiler flags: ${CMAKE_C_FLAGS}") SET(HAVE_OOMPI ${HAVE_MPI}) INCLUDE(${CMAKE_ROOT}/Modules/FindThreads.cmake) @@ -498,40 +431,10 @@ INCLUDE(${CMAKE_ROOT}/Modules/FindThreads.cmake) # list of libraries to be linked with the main applications using I/O SET(QMC_UTIL_LIBS ${LAPACK_LIBRARY} ${BLAS_LIBRARY}) - -#SET( FFTW_FOUND 0 ) -#IF ( HAVE_MKL ) -# IF ( HAVE_MKL_FFTW3 ) -# SET( FFTW_FOUND 1 ) -# ENDIF() -#ENDIF() -#IF ( NOT FFTW_FOUND ) -# find_package(FFTW) -#ENDIF() -#IF(FFTW_FOUND) -# SET(HAVE_LIBFFTW 1) -# INCLUDE_DIRECTORIES(${FFTW_INCLUDE_DIR}) -# SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${FFTW_LIBRARIES}) -# MESSAGE(STATUS "Found FFTW") -#ELSE(FFTW_FOUND) -## MESSAGE(STATUS "Disabling FFTW") -# MESSAGE(FATAL_ERROR "Could not find required library FFTW. Verify FFTW_HOME") -#ENDIF(FFTW_FOUND) - SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${FORTRAN_LIBRARIES}) #find_package(ZLIB) -#find_package(LibXml2) -#INCLUDE(CMake/FindLibxml2QMC.cmake) -#IF(LIBXML2_FOUND) -# INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) -# SET(HAVE_LIBXML2 1) -# SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${LIBXML2_LIBRARIES}) -#ELSE() -# MESSAGE(FATAL_ERROR "Could not find required library Libxml2") -#ENDIF(LIBXML2_FOUND) - #set(HDF5_USE_STATIC_LIBRARIES off) #if(QMC_BUILD_STATIC) # set(HDF5_USE_STATIC_LIBRARIES on) @@ -562,48 +465,6 @@ SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${FORTRAN_LIBRARIES}) #ENDIF(HDF5_FOUND) # -#INCLUDE(${PROJECT_CMAKE}/FindPkgConfig.cmake) -################################################################## -# TODO:use profile tools -################################################################## -#IF(MPIP_PROFILE) -# LINK_LIBRARIES("/usr/apps/tools/mpip/lib/cmpi/libmpiP.a") -# LINK_LIBRARIES("/usr/lib/libbfd.a") -# LINK_LIBRARIES("/usr/lib/libiberty.a") -#ENDIF(MPIP_PROFILE) -#if(ENABLE_TAU_PROFILE) -# INCLUDE(${PROJECT_CMAKE}/FindTau.cmake) -#endif(ENABLE_TAU_PROFILE) -# #add tau stuff -# IF(FOUND_TAU) -# ADD_DEFINITIONS( -# -DTAU_MPI -# -DTAU_MPI_THREADED -# -DTAU_MPIGREQUEST -# -DTAU_MPIDATAREP -# -DTAU_MPIERRHANDLER -# -DTAU_MPIATTRFUNCTION -# -DTAU_MPITYPEEX -# -DTAU_MPIADDERROR -# ) -# #build libtau -# subdirs(src/tau) -# LINK_LIBRARIES(tau) -# ENDIF(FOUND_TAU) -#IF(FOUND_TAU) -# INCLUDE_DIRECTORIES(${TAU_INCLUDE_DIR}) -# ADD_DEFINITIONS (-DPROFILING_ON -# -DTAU_STDCXXLIB -# -DTAU_DOT_H_LESS_HEADERS -# -DTAU_CALLPATH -# -DTAU_LARGEFILE64_SOURCE -# -DTAU_BFD -# ) -# if(ENABLE_OPENMP) -# ADD_DEFINITIONS(-DTAU_OPENMP) -# endif(ENABLE_OPENMP) -#ENDIF(FOUND_TAU) - ###################################################### # Add optional macros ###################################################### @@ -611,50 +472,6 @@ SET(QMC_UTIL_LIBS ${QMC_UTIL_LIBS} ${FORTRAN_LIBRARIES}) #include qmcpack/src build/src INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src) -#IF(BUILD_LMYENGINE_INTERFACE) -# ADD_DEFINITIONS(-DHAVE_LMY_ENGINE) -# SET(FORMIC_BINARY_DIR ${qmcpack_BINARY_DIR}) -# SUBDIRS(src/formic/utils) -# SET(QMC_UTIL_LIBS formic_utils ${QMC_UTIL_LIBS}) -#ENDIF(BUILD_LMYENGINE_INTERFACE) - -#include(ExternalProject) -# set(einspline_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/einspline") -# set(einspline_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/einspline") -# set(einspline_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${einspline_INSTALL_DIR}) -#ExternalProject_Add( -# einspline -# SVN_REPOSITORY http://qmctools.googlecode.com/svn/ext-packages/einspline -# ) -# INSTALL_DIR ${einspline_INSTALL_DIR} -# CMAKE_ARGS ${einspline_CMAKE_ARGS} -# ) -# find_package(einspline REQUIRED) -# set(HAVE_EINSPLINE 1) -####################################################################### -## Manage GTK+ and GTKMM packages for GUI -## search headers and libraries -## 1) -lXYZ-${XYZ_VERSION} -## 2) -lXYZ -## example: -lgtk-${GTK_VERSION} | -lgtk -####################################################################### -#SET(GTK_VERSION 2.0) -#SET(PANGO_VERSION 1.0) -# -#SET(GTKMM_VERSION 2.4) -#SET(PANGOMM_VERSION 1.4) -#SET(SIGCPP_VERSION 2.0) -#IF(ENABLE_GTK_GUI) -# INCLUDE(${PROJECT_CMAKE}/FindGTK.cmake) -# #THIS SHOULD GO TO the directory where GUI is built -# IF(GTKMM_FOUND) -# INCLUDE_DIRECTORIES(${GTKMM_INCLUDE_DIR}) -# LINK_LIBRARIES(${GTKMM_LIBRARIES}) -# ENDIF(GTKMM_FOUND) -#ENDIF(ENABLE_GTK_GUI) - - - # To connect the timer regions with VTune sampling, some Task API calls # are present in the code. To enable them, set USE_VTUNE_TASKS and add the # include and lib paths to VTune. @@ -718,43 +535,14 @@ MESSAGE(STATUS "Ready to build qmcpack") # -DMPICH_SKIP_MPICXX : disable C++ binding of MPICH #################################################################### -ADD_DEFINITIONS(-DHAVE_CONFIG_H -DH5_USE_16_API -DUSE_REAL_STRUCT_FACTOR -DINLINE_ALL=inline) - -IF(CMAKE_COMPILER_IS_GNUCXX OR (${COMPILER} STREQUAL "Clang")) - ADD_DEFINITIONS(-DADD_) -ENDIF() +ADD_DEFINITIONS(-DHAVE_CONFIG_H -DH5_USE_16_API -DUSE_REAL_STRUCT_FACTOR -DINLINE_ALL=inline -DADD_) if(HAVE_MPI) ADD_DEFINITIONS(-DMPICH_SKIP_MPICXX) endif() -#ADD_DEFINITIONS(-DDISABLE_WS_CELL) EXECUTE_PROCESS(COMMAND hostname OUTPUT_VARIABLE QMC_HOSTNAME OUTPUT_STRIP_TRAILING_WHITESPACE) CONFIGURE_FILE(${qmcpack_SOURCE_DIR}/qmcpack.settings ${qmcpack_BINARY_DIR}/bin/qmcpack.settings) -######################### -# add definitions for adios profile -# add definitions for adios verification -######################## -IF(QMC_ADIOS) - #ADD_DEFINITIONS(-DIO_PROFILE) - #ADD_DEFINITIONS(-DADIOS_VERIFY) - ADD_DEFINITIONS(-DWRITE_GLOBAL) -ENDIF(QMC_ADIOS) - SUBDIRS(src) -IF(NOT(QMC_BUILD_LEVEL GREATER 4)) - SUBDIRS(tests) - SUBDIRS(examples) -ENDIF() - -#ADD_CUSTOM_TARGET(print_settings ALL -# ${CMAKE_COMMAND} -E echo "Print build settings" -# VERBATIM) -# -#add_custom_command(TARGET print_settings -# POST_BUILD -# COMMAND svn info ${qmcpack_SOURCE_DIR}) -# -#file(APPEND ${qmcpack_BINARY_DIR}/bin/qmcpack.settings ${print_settings}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0e4c1d96f..ecbbcbd22 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,7 +25,12 @@ SET(GITREV_BARE_TMP git-rev-tmp.h) SET(GITREV_FILE ${CMAKE_BINARY_DIR}/src/${GITREV_BARE_FILE}) SET(GITREV_TMP ${CMAKE_BINARY_DIR}/src/${GITREV_BARE_TMP}) -IF (GIT_FOUND AND IS_GIT_PROJECT) +# Always clean up git-rev-tmp.h file when cmake is run +EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E remove ${GITREV_TMP} +) + +IF (IS_GIT_PROJECT) # The following custom command picks up changes to the git revision information # every time the project is rebuilt. Even if the repositiory is updated (git pull) # without re-running cmake. It also appends '-dirty' to the commit hash if there are @@ -40,6 +45,25 @@ IF (GIT_FOUND AND IS_GIT_PROJECT) # Apparently custom commands need to be defined where the output is used. # If this in the main CMakeLists.txt it does not work. + # Sed flags were once an issue and some HPC have old sed's + set(SED_FLAG "-E") + EXECUTE_PROCESS(COMMAND "sed" ${SED_FLAG} "s/\"/\\\\\"/g" "<${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" + OUTPUT_QUIET + ERROR_VARIABLE SED_ERROR) + if ( SED_ERROR MATCHES ".*invalid.*" ) + set(SED_FLAG "-r") + EXECUTE_PROCESS(COMMAND "sed" ${SED_FLAG} "s/\"/\\\\\"/g" "<${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" + OUTPUT_QUIET ERROR_QUIET + ERROR_VARIABLE SED_ERROR) + if ( SED_ERROR MATCHES ".*invalid.*" ) + MESSAGE(WARNING "Your system supports neither the sed -E or -r flag, git revision information will not be included in output") + else ( SED_ERROR MATCHES ".*invalid.*" ) + MESSAGE("sed supports -r") + endif ( SED_ERROR MATCHES ".*invalid.*" ) + else ( SED_ERROR MATCHES ".*invalid.*" ) + MESSAGE("sed supports -E") + endif ( SED_ERROR MATCHES ".*invalid.*" ) + ADD_CUSTOM_COMMAND( OUTPUT ${GITREV_TMP} COMMAND ${CMAKE_COMMAND} -E echo_append "#define GIT_BRANCH_RAW " > ${GITREV_TMP} @@ -52,8 +76,9 @@ IF (GIT_FOUND AND IS_GIT_PROJECT) COMMAND ${GIT_EXECUTABLE} log -1 --format=%ad >> ${GITREV_TMP} COMMAND ${CMAKE_COMMAND} -E echo >> ${GITREV_TMP} COMMAND ${CMAKE_COMMAND} -E echo_append "#define GIT_COMMIT_SUBJECT_RAW \"" >> ${GITREV_TMP} - COMMAND ${GIT_EXECUTABLE} log -1 --format=%s | sed -E "s/\"/\\\\\"/g" | tr -d '\\n' >> ${GITREV_TMP} + COMMAND ${GIT_EXECUTABLE} log -1 --format=%s | sed ${SED_FLAG} "s/\"/\\\\\"/g" | tr -d '\\n' >> ${GITREV_TMP} COMMAND ${CMAKE_COMMAND} -E echo_append "\"" >> ${GITREV_TMP} + COMMAND ${CMAKE_COMMAND} -E echo >> ${GITREV_TMP} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GITREV_TMP} ${GITREV_FILE} COMMAND ${CMAKE_COMMAND} -E remove ${GITREV_TMP} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} @@ -100,21 +125,6 @@ ELSE() ENDIF() -#################################### -# create liboompi -#################################### -#IF(HAVE_OOMPI) -# CONFIGURE_FILE(${qmcpack_SOURCE_DIR}/src/oompi-config.h.cmake.in -# ${qmcpack_BINARY_DIR}/src/oompi-config.h) -# INCLUDE_DIRECTORIES(${qmcpack_SOURCE_DIR}/src/OOMPI) -# SUBDIRS(OOMPI) -# IF ( MPI_LIBRARY ) -# SET(MPI_LIBRARY oompi ${MPI_LIBRARY}) -# ELSE() -# SET(MPI_LIBRARY oompi ) -# ENDIF() -#ENDIF(HAVE_OOMPI) - #################################### # create libqmcutil #################################### @@ -162,17 +172,6 @@ ENDIF() Particle/DistanceTable.cpp ) - - # IF(QMC_BUILD_LEVEL GREATER 2) - # IF(NOT QMC_COMPLEX) - # SET(PARTICLE ${PARTICLE} Particle/Bead_ParticleSet.cpp ) - # ENDIF(NOT QMC_COMPLEX) - # ENDIF(QMC_BUILD_LEVEL GREATER 2) - - #SET(PARTICLEIO - # ParticleIO/ParticleIOUtility.cpp - # ) - ADD_LIBRARY(qmcbase ${PARTICLE} ${PARTICLEIO}) #IF(QMC_BUILD_STATIC) @@ -184,7 +183,7 @@ ENDIF() if(QMC_BUILD_LEVEL GREATER 4) - MESSAGE(STATUS "Minimal build: only minapp drivers") + MESSAGE(STATUS "Minimal build: only miniapp drivers") SUBDIRS(Drivers) else() #{{{ diff --git a/src/Drivers/CMakeLists.txt b/src/Drivers/CMakeLists.txt index 8d82da9c1..b67d0c779 100644 --- a/src/Drivers/CMakeLists.txt +++ b/src/Drivers/CMakeLists.txt @@ -1,5 +1,3 @@ -PROJECT(drivers) - if(QMC_BUILD_LEVEL GREATER 4) # add apps XYZ.cpp, e.g., qmc_particles.cpp #SET(ESTEST einspline_smp einspline_spo qmc_particles moveonsphere twobody ptclset) diff --git a/testing/miniqmc_openshift_rhea.sh b/testing/miniqmc_openshift_rhea.sh index 2d3008378..f66d5c7b0 100755 --- a/testing/miniqmc_openshift_rhea.sh +++ b/testing/miniqmc_openshift_rhea.sh @@ -18,6 +18,7 @@ source /sw/rhea/environment-modules/3.2.10/rhel6.7_gnu4.4.7/init/bash module unload PE-intel module load PE-gnu/5.3.0-1.10.2 module load git +module load cmake/3.6.1 env @@ -31,7 +32,7 @@ echo "" cd build -cmake -DCMAKE_C_COMPILER="mpicc" -DCMAKE_CXX_COMPILER="mpicxx" -DCMAKE_CXX_FLAGS="-std=c++11" -DBLAS_blas_LIBRARY="/usr/lib64/libblas.so.3" -DLAPACK_lapack_LIBRARY="/usr/lib64/atlas/liblapack.so.3" .. +cmake -DCMAKE_CXX_COMPILER="mpicxx" -DBLAS_blas_LIBRARY="/usr/lib64/libblas.so.3" -DLAPACK_lapack_LIBRARY="/usr/lib64/atlas/liblapack.so.3" .. make @@ -81,7 +82,7 @@ rm -rf ./build mkdir -p build cd build -cmake -D QMC_MIXED_PRECISION=1 -DCMAKE_C_COMPILER="mpicc" -DCMAKE_CXX_COMPILER="mpicxx" -DCMAKE_CXX_FLAGS="-std=c++11" -DBLAS_blas_LIBRARY="/usr/lib64/libblas.so.3" -DLAPACK_lapack_LIBRARY="/usr/lib64/atlas/liblapack.so.3" .. +cmake -DQMC_MIXED_PRECISION=1 -DCMAKE_CXX_COMPILER="mpicxx" -DBLAS_blas_LIBRARY="/usr/lib64/libblas.so.3" -DLAPACK_lapack_LIBRARY="/usr/lib64/atlas/liblapack.so.3" .. make