Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CMAKE_CXX_STANDARD to set C++14 standard #448

Open
cwsmith opened this issue Aug 21, 2024 · 6 comments
Open

Use CMAKE_CXX_STANDARD to set C++14 standard #448

cwsmith opened this issue Aug 21, 2024 · 6 comments

Comments

@cwsmith
Copy link
Contributor

cwsmith commented Aug 21, 2024

Replace the -std=c++14 here

set(FLAGS "${FLAGS} --std=c++14 -Wall -Wextra -Wpedantic -Werror -Wno-extra-semi -Werror=unused-parameter -Wno-error=deprecated-declarations")

with set(CMAKE_CXX_STANDARD 14).

Tagging with CGNS as that code requires C++14:

core/CMakeLists.txt

Lines 40 to 42 in 8959c59

if(ENABLE_CGNS) #takes precedence over SCOREC_ENABLE_CXX11
message(STATUS "enabling cxx14")
bob_cxx14_flags()

@jacobmerson
Copy link
Contributor

Here is some suggested code from Professional CMake:

# Require C++20, but let a parent project ask for something higher
if(DEFINED CMAKE_CXX_STANDARD)
  if(CMAKE_CXX_STANDARD EQUAL 98 OR CMAKE_CXX_STANDARD LESS 20)
    message(FATAL_ERROR "This project requires at least C++20")
  endif()
else()
  set(CMAKE_CXX_STANDARD 20)
endif()
# Always enforce the language constraint
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# We don't need compiler extensions, but let a parent ask for them
if(NOT DEFINED CMAKE_CXX_EXTENSIONS)
  set(CMAKE_CXX_EXTENSIONS OFF)
endif()

If we are making a major version bump for the PCU changes, can we consider jumping to c++17? I saw somewhere, but can't track it down at the moment that Kokkos is going to c++20 within the next 6 months.

@cwsmith
Copy link
Contributor Author

cwsmith commented Aug 21, 2024

Thank you.

I'm not sure we have a strong reason to increase the standard beyond 14 (pending the discussion here #447).

@jacobmerson
Copy link
Contributor

It would be nice to push the language standard as much forward as we can on a major version release. C++17 has some performance guarantees related to NRVO/ copy elision. And many usability improvements over 14. But, I can understand the argument for not breaking customers code.

Is there a way for us to find out if any of our users are stuck on 14 and cannot move to 17?

@cwsmith
Copy link
Contributor Author

cwsmith commented Aug 22, 2024

I agree, there are nice benefits of the newer standards.

To find out if we will break anyone, we'd have to survey the pumi users (which we have not done before). A couple ideas:

  • put a poll for which C++ standards are being used on the github front page, or make a simple github.io page
  • dig though issues to find contact info and email directly

@jacobmerson
Copy link
Contributor

Do we want to wait for the decision on 17 or start a new issue for 17 and make progress on the CMAKE_CXX_STANDARD stuff

@cwsmith
Copy link
Contributor Author

cwsmith commented Aug 23, 2024

Let's get this fixed and wait on the use of 17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants