diff --git a/CHANGELOG.md b/CHANGELOG.md index 07ff6a3a60..d3b8d3fa6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Notable changes to QMCPACK are documented in this file. ## [Unreleased] +* C++17 is required [\#3348](https://github.com/QMCPACK/qmcpack/pull/3348). * Quantum ESPRESSO (QE) v6.8 support. [\#3301](https://github.com/QMCPACK/qmcpack/pull/3301). * To aid coexistence of real and complex builds, the qmcpack executable is now named qmcpack_complex for builds with QMC_COMPLEX=1 diff --git a/CMake/TestCxx14Library.cmake b/CMake/TestCxx14Library.cmake deleted file mode 100644 index 9ae8ff005f..0000000000 --- a/CMake/TestCxx14Library.cmake +++ /dev/null @@ -1,48 +0,0 @@ -# Test that the compiler is configured with a C++ 14 standard library - -set(TEST_CXX14_SOURCE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/try_cxx14_library.cpp) -file( - WRITE ${TEST_CXX14_SOURCE} - "// Test for C++14 standard library support -#include - -int main(int argc, char **argv) -{ - std::tuple t(1, 3.5); - // Accessing a tuple member by type is a C++14 feature - int j = std::get(t); - return 0; -} -") - -try_compile( - CXX14_LIBRARY_OKAY - ${CMAKE_BINARY_DIR} - ${TEST_CXX14_SOURCE} - CXX_STANDARD - 14 - CXX_STANDARD_REQUIRED - ON - OUTPUT_VARIABLE COMPILE_OUTPUT) - -if(NOT CXX14_LIBRARY_OKAY) - set(COMPILE_FAIL_OUTPUT cpp14_compile_fail.txt) - file(WRITE "${CMAKE_BINARY_DIR}/${COMPILE_FAIL_OUTPUT}" "${COMPILE_OUTPUT}") - - message(STATUS "C++14 standard library support not found") - message("compiler is ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") - if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - message("Compiler detected is g++.\n Use version 5.0 or newer for a C++14 standard library") - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - message( - "Compiler detected is clang++.\n If not using libcxx, ensure a g++ version greater than 5.0 is on the path") - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - message( - "Compiler detected is icpc.\n Ensure a gcc version greater than 5.0 is on the path. Or use the -cxxlib switch to point to a newer gcc install." - ) - endif() - message(" Output of test compile is in ${COMPILE_FAIL_OUTPUT}") - message(FATAL_ERROR "stopping") -else() - message(STATUS "C++14 standard library supported") -endif() diff --git a/CMake/Testlibstdc++.cmake b/CMake/Testlibstdc++.cmake index 1f7c6f6a63..abfb9574d6 100644 --- a/CMake/Testlibstdc++.cmake +++ b/CMake/Testlibstdc++.cmake @@ -5,7 +5,7 @@ try_compile( ${CMAKE_BINARY_DIR} ${PROJECT_CMAKE}/try_compile_sources/check_libstdcxx.cpp CXX_STANDARD - 14 + ${QMC_CXX_STANDARD} CXX_STANDARD_REQUIRED ON OUTPUT_VARIABLE COMPILE_OUTPUT) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfed9611a4..58c7978d6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,10 +127,10 @@ set(EXECUTABLE_OUTPUT_PATH # Set C++ standard used by QMCPACK ################################## set(QMC_CXX_STANDARD - 14 + 17 CACHE STRING "QMCPACK C++ language standard") -if(NOT QMC_CXX_STANDARD EQUAL 14) - message(WARNING "C++14 is the only language standard officially supported by this QMCPACK version. " +if(NOT QMC_CXX_STANDARD EQUAL 17) + message(WARNING "C++17 is the only language standard officially supported by this QMCPACK version. " "Using other versions of the C++ standard is unsupported and done entirely at user's own risk.") endif() @@ -407,11 +407,7 @@ include(CMake/Testlibstdc++.cmake) #--------------------------------------------------------- # Check that a C++ standard library is configured properly #--------------------------------------------------------- -if(QMC_CXX_STANDARD GREATER_EQUAL 17) - include(CMake/TestCxx17Library.cmake) -else() - include(CMake/TestCxx14Library.cmake) -endif() +include(CMake/TestCxx17Library.cmake) if(ENABLE_GCOV) if(NOT GCOV_SUPPORTED) diff --git a/README.md b/README.md index b07e68454b..c3f1b60c1d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ particular emphasis is placed on code quality and reproducibility. # Prerequisites - * C++ 14 and C99 capable compilers. + * C++ 17 and C99 capable compilers. * CMake v3.14.0 or later, build utility, http://www.cmake.org * BLAS/LAPACK, numerical library. Use platform-optimized libraries. * LibXml2, XML parser, http://xmlsoft.org/ diff --git a/docs/installation.rst b/docs/installation.rst index 92037271d2..9b237d5ac1 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -111,7 +111,7 @@ newer versions are faster; see :ref:`buildperformance` for performance suggestio unsupported and untested by the developers although they may still work. - C/C++ compilers such as GNU, Clang, Intel, and IBM XL. C++ compilers - are required to support the C++ 14 standard. Use of recent (“current + are required to support the C++ 17 standard. Use of recent (“current year version”) compilers is strongly encouraged. - An MPI library such as OpenMPI (http://open-mpi.org) or a @@ -143,7 +143,7 @@ Many of the utilities provided with QMCPACK require Python (v3). The numpy and matplotlib libraries are required for full functionality. -C++ 14 standard library +C++ 17 standard library ----------------------- The C++ standard consists of language features—which are implemented in @@ -151,15 +151,15 @@ the compiler—and library features—which are implemented in the standard library. GCC includes its own standard library and headers, but many compilers do not and instead reuse those from an existing GCC install. Depending on setup and installation, some of these compilers might not -default to using a GCC with C++ 14 headers (e.g., GCC 4.8 is common as a +default to using a GCC with C++ 17 headers (e.g., GCC 4.8 is common as a base system compiler, but its standard library only supports C++ 11). -The symptom of having header files that do not support the C++ 14 +The symptom of having header files that do not support the C++ 17 standard is usually compile errors involving standard include header files. Look for the GCC library version, which should be present in the -path to the include file in the error message, and ensure that it is 5.0 +path to the include file in the error message, and ensure that it is 8.1 or greater. To avoid these errors occurring at compile time, QMCPACK -tests for a C++ 14 standard library during configuration and will halt +tests for a C++ 17 standard library during configuration and will halt with an error if one is not found. At sites that use modules, it is often sufficient to simply load a newer @@ -168,14 +168,14 @@ GCC. Intel compiler ~~~~~~~~~~~~~~ -The Intel compiler version must be 19 or newer due to use of C++14 and bugs and limitations in earlier versions. +The Intel compiler version must be 19 or newer due to use of C++17 and bugs and limitations in earlier versions. If a newer GCC is needed, the ``-cxxlib`` option can be used to point to a different GCC installation. (Alternately, the ``-gcc-name`` or ``-gxx-name`` options can be used.) Be sure to pass this flag to the C compiler in addition to the C++ compiler. This is necessary because CMake extracts some library paths from the C compiler, and those paths usually also contain to the C++ library. The -symptom of this problem is C++ 14 standard library functions not found +symptom of this problem is C++ 17 standard library functions not found at link time. .. _cmake: @@ -186,8 +186,7 @@ Building with CMake The build system for QMCPACK is based on CMake. It will autoconfigure based on the detected compilers and libraries. The most recent version of CMake has the best detection for the greatest variety of systems. The -minimum required version of CMake is 3.6, which is the oldest version to -support correct application of C++ 14 flags for the Intel compiler. Most +minimum required version of CMake is 3.14.0. Most computer installations have a sufficiently recent CMake, though it might not be the default.