Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Require C++17 #834

Merged
merged 9 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CMake/MakefileBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ endforeach()
# =============================================================================
# compile flags : common to all backend
# =============================================================================
# PGI compiler adds --c++14;-A option for C++14, remove ";"
string(REPLACE ";" " " CXX14_STD_FLAGS "${CMAKE_CXX14_STANDARD_COMPILE_OPTION}")
string(JOIN " " CMAKE_CXX17_STANDARD_COMPILE_OPTION_STRING ${CMAKE_CXX17_STANDARD_COMPILE_OPTION})
string(TOUPPER "${CMAKE_BUILD_TYPE}" _BUILD_TYPE)
list(TRANSFORM CORENRN_COMPILE_DEFS PREPEND -D OUTPUT_VARIABLE CORENRN_COMPILE_DEF_FLAGS)
string(
Expand All @@ -85,7 +84,7 @@ string(
CORENRN_CXX_FLAGS
${CMAKE_CXX_FLAGS}
${CMAKE_CXX_FLAGS_${_BUILD_TYPE}}
${CXX14_STD_FLAGS}
${CMAKE_CXX17_STANDARD_COMPILE_OPTION_STRING}
${NVHPC_ACC_COMP_FLAGS}
${NVHPC_CXX_INLINE_FLAGS}
${CORENRN_COMPILE_DEF_FLAGS}
Expand Down
2 changes: 0 additions & 2 deletions CMake/OpenAccHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ if(CORENRN_ENABLE_GPU)
else()
message(FATAL_ERROR "${CORENRN_ACCELERATOR_OFFLOAD} not supported with NVHPC compilers")
endif()
# avoid PGI adding standard compliant "-A" flags
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION --c++14)
string(APPEND CMAKE_EXE_LINKER_FLAGS " ${NVHPC_ACC_COMP_FLAGS}")
# Use `-Mautoinline` option to compile .cpp files generated from .mod files only. This is
# especially needed when we compile with -O0 or -O1 optimisation level where we get link errors.
Expand Down
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ math(EXPR CORENEURON_VERSION_COMBINED
# =============================================================================
# CMake common project settings
# =============================================================================
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_BUILD_TYPE
RelWithDebInfo
CACHE STRING "Empty or one of Debug, Release, RelWithDebInfo")

if(NOT "cxx_std_14" IN_LIST CMAKE_CXX_COMPILE_FEATURES OR NOT "cxx_digit_separators" IN_LIST
CMAKE_CXX_COMPILE_FEATURES)
if(NOT "cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
message(
FATAL_ERROR
"This compiler does not fully support C++14, choose an higher version or an other compiler.")
"This compiler does not fully support C++17, choose a higher version or another compiler.")
endif()

# =============================================================================
Expand Down Expand Up @@ -297,6 +296,11 @@ if(CORENRN_HAVE_NVHPC_COMPILER)
# problem. If GPU support is disabled, we define R123_USE_INTRIN_H=0 to avoid the problem.
list(APPEND CORENRN_COMPILE_DEFS R123_USE_INTRIN_H=0)
endif()
# CMake versions <3.19 used to add -A when using NVHPC/PGI, which makes the compiler excessively
# pedantic. See https://gitlab.kitware.com/cmake/cmake/-/issues/20997.
if(CMAKE_VERSION VERSION_LESS 3.19)
list(REMOVE_ITEM CMAKE_CXX17_STANDARD_COMPILE_OPTION -A)
endif()
endif()

# ~~~
Expand Down