Set C++ standard only if it is not set at parent scope #3541
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change allows cleaner inclusion of p4c into projects that set
CMAKE_CXX_STANDARD
to value greater then 11, it does not change anything if p4c is built standalone.Essentially, in Intel we have top-level target that includes p4c and p4c then includes our extensions. We build our extensions with C++17, but we would like to build p4c with C++17 too to avoid having some code compiled with older standard. In particular, problem can be in the code that is built as part of
p4c
, but is coming from extensions (such as additional IR defs). With this change, we would be able to use C++17 cleanly.Of course, anyone setting
CMAKE_CXX_STANDARD
> 11 takes the risk it will break something in p4c. This risk is very small for C++17 (bigger for C++20 if anyone would be brave enough to try it).