Skip to content

cmake: Move minimum C++ standard to 20#1957

Open
johnbowen42 wants to merge 10 commits intodevelopfrom
feature/bowen/cpp20
Open

cmake: Move minimum C++ standard to 20#1957
johnbowen42 wants to merge 10 commits intodevelopfrom
feature/bowen/cpp20

Conversation

@johnbowen42
Copy link
Copy Markdown
Contributor

This pull request changes the minimum C++ version in CMake and build scripts to C++20. We probably want to hold off on merging this change until after the upcoming release is cut.

@johnbowen42 johnbowen42 requested review from a team and tomstitt December 12, 2025 17:57
Copy link
Copy Markdown
Member

@rhornung67 rhornung67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnbowen42 we cannot force C++20 yet since it that would break some of our WSC user codes.

Copy link
Copy Markdown
Member

@rhornung67 rhornung67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's hold off on merging this and reassess after the release.

Copy link
Copy Markdown
Member

@rhornung67 rhornung67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to dismiss approval

@kab163
Copy link
Copy Markdown
Contributor

kab163 commented Dec 19, 2025

Umpire has a similar PR - we can reassess after the holidays on when we want to start enforcing c++20 minimum requirement

@johnbowen42 johnbowen42 requested review from a team and rhornung67 February 20, 2026 00:02
@johnbowen42
Copy link
Copy Markdown
Contributor Author

@llnl/raja-core can I get a review on this PR now that we are ready to move forward with C++ 20?

Copy link
Copy Markdown
Member

@artv3 artv3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready!

("${BLT_CXX_STD}" STREQUAL "c++11") OR
("${BLT_CXX_STD}" STREQUAL "c++14"))
message(FATAL_ERROR "RAJA requires minimum C++ standard of c++17")
("${BLT_CXX_STD}" STREQUAL "c++14") OR
Copy link
Copy Markdown
Member

@rhornung67 rhornung67 Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to do this in CMake with a '<=' type syntax? Meaning a single statement that says the equivalent of std <= 20.

Or, should we move to something like this?
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON)

That probably conflicts with what BLT does or may introduce an ordering dependency based on where the standard is set?!?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the CMake way of specifying the minimum standard is the following (this was suggested in the CMake class offered to LLNL last year):

target_compile_features(RAJA PUBLIC cxx_std_20)

The PUBLIC means that downstream targets that include RAJA also need to have a minimum c++ standard of c++20.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could require a bit of cleverness. 98 (1998) will mess up simple extract year and LESS_EQUAL compare.

This would be a bit shorter than the OR sequence.

set(invalid_standards c++98 c++11 c++14 C++17)
if(BLT_CXX_STD IN_LIST invalid_standards)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @adayton1 I did not know that was the cmake idiomatic way.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, we originally had it written using the compile features check, but I ended up adding the extra logic because we regularly had issues with cmake claiming a given compiler didn't support a version when we knew it did. If that problem has gone away, then we should go back to doing it the idiomatic way.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer it to fail if the version is too low.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing to be aware is that if we use cxx_std_20 as a PUBLIC target feature, downstream libraries will also be affected - meaning if they set the standard too low on their project, that will also be ignored and silently updated to c++20. So now that we've talked this through, I think it cxx_std_20 should either not be used or set to PRIVATE so that it only affects RAJA and not downstream projects.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another vote for failing on version too low. Silent magic is bad.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto for me -- fail when unsupported version is specified.

Copy link
Copy Markdown
Member

@adrienbernede adrienbernede Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, fail when unsupported version is specified, ability to specify via BLT_CXX_STD.
Also, there have been efforts from folks like Daniel Taller to be able to enforce cxx standard via Spack. If the cxx standard specified as a variant in a spack spec actually resulted in another standard being use, that would be calling for troubles.

Copy link
Copy Markdown
Member

@rhornung67 rhornung67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the c++ std from corona sycl host-config

Copy link
Copy Markdown
Member

@smithsg84 smithsg84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me.

@johnbowen42 johnbowen42 force-pushed the feature/bowen/cpp20 branch from c9b305b to 6c54ad7 Compare April 3, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants