From ad060ce4bebaf59e4e2b99e4a6a8f6a9fb6de668 Mon Sep 17 00:00:00 2001 From: Peter Doak Date: Fri, 6 Aug 2021 15:36:48 -0400 Subject: [PATCH 1/8] the easy part --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfed9611a4..28c68f0572 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() @@ -410,7 +410,7 @@ include(CMake/Testlibstdc++.cmake) if(QMC_CXX_STANDARD GREATER_EQUAL 17) include(CMake/TestCxx17Library.cmake) else() - include(CMake/TestCxx14Library.cmake) + message(FATAL_ERROR "QMCPACK requires compiler support of c++17 or greater.") endif() if(ENABLE_GCOV) From 39ef7ac78d3e01e1a1c47d99725b080f43a54cca Mon Sep 17 00:00:00 2001 From: Peter Doak Date: Fri, 6 Aug 2021 17:04:25 -0400 Subject: [PATCH 2/8] partial update of documenation for c++17 --- docs/installation.rst | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/installation.rst b/docs/installation.rst index 92037271d2..f8f4744d60 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 (I think its actually higher). Most computer installations have a sufficiently recent CMake, though it might not be the default. From 9046c86ffeac8f13aa7254d60714e13948ccd543 Mon Sep 17 00:00:00 2001 From: Peter Doak Date: Fri, 6 Aug 2021 17:22:22 -0400 Subject: [PATCH 3/8] update libstdc++ compatibility check --- CMake/Testlibstdc++.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/Testlibstdc++.cmake b/CMake/Testlibstdc++.cmake index 1f7c6f6a63..f52429aeee 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 + 17 CXX_STANDARD_REQUIRED ON OUTPUT_VARIABLE COMPILE_OUTPUT) From 0a12b196ae72501d75e72447be0bd79ed62eaa56 Mon Sep 17 00:00:00 2001 From: Peter Doak Date: Fri, 6 Aug 2021 17:25:49 -0400 Subject: [PATCH 4/8] simplified check --- CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28c68f0572..58c7978d6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() - message(FATAL_ERROR "QMCPACK requires compiler support of c++17 or greater.") -endif() +include(CMake/TestCxx17Library.cmake) if(ENABLE_GCOV) if(NOT GCOV_SUPPORTED) From 70f2cf55250be82272f4883fa310e30e52413e73 Mon Sep 17 00:00:00 2001 From: Peter Doak Date: Fri, 6 Aug 2021 17:27:42 -0400 Subject: [PATCH 5/8] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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/ From 2713e5031284b57bbcdb0759b8fc6dea2baffc30 Mon Sep 17 00:00:00 2001 From: "Paul R. C. Kent" Date: Tue, 10 Aug 2021 13:38:47 -0400 Subject: [PATCH 6/8] Update Changlog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 173919b82e310ee9be1cc924f2cfd05b3447a3e3 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Tue, 10 Aug 2021 13:31:54 -0500 Subject: [PATCH 7/8] More flexible check and remove used file. --- CMake/TestCxx14Library.cmake | 48 ------------------------------------ CMake/Testlibstdc++.cmake | 2 +- 2 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 CMake/TestCxx14Library.cmake 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 f52429aeee..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 - 17 + ${QMC_CXX_STANDARD} CXX_STANDARD_REQUIRED ON OUTPUT_VARIABLE COMPILE_OUTPUT) From d6715b12c170d68e97503fd1feec89a2a347ef71 Mon Sep 17 00:00:00 2001 From: Ye Luo Date: Tue, 10 Aug 2021 16:00:22 -0500 Subject: [PATCH 8/8] Correct docs. --- docs/installation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/installation.rst b/docs/installation.rst index f8f4744d60..9b237d5ac1 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -186,7 +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.14.0 (I think its actually higher). 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.