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

Require C++11 *or later* #5020

Merged
merged 1 commit into from
Dec 16, 2022
Merged

Require C++11 *or later* #5020

merged 1 commit into from
Dec 16, 2022

Conversation

dneto0
Copy link
Collaborator

@dneto0 dneto0 commented Dec 15, 2022

Allow externally setting CMAKE_CXX_STANDARD to 14, for example, which is needed to build protobufs

Allow externally setting CMAKE_CXX_STANDARD to 14, for example,
which is needed to build protobufs
@dneto0 dneto0 requested a review from alan-baker December 15, 2022 18:22
@dneto0 dneto0 merged commit 5d6adbd into KhronosGroup:master Dec 16, 2022
Comment on lines +36 to +41
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
if(${CMAKE_CXX_STANDARD} LESS 11)
message(FATAL_ERROR "SPIRV-Tools requires C++11 or later, but is configured for C++${CMAKE_CXX_STANDARD})")
endif()
Copy link
Contributor

Choose a reason for hiding this comment

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

All targets should just have target_compile_features(<target> PUBLIC cxx_std_11), CMakeLists of libraries should never set CMAKE_CXX_STANDARD.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Question: Should CMAKE_CXX_STANDARD be set when building executables?
E.g. the command line tools are built via https://github.com/KhronosGroup/SPIRV-Tools/blob/main/tools/CMakeLists.txt

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm confused. Why does CMAKE_CXX_STANDARD exist, then? Or is it legacy?

Ah, target_compile_features is new in CMake 3.8.
https://cmake.org/cmake/help/latest/release/3.8.html?highlight=cxx_std_11#c-c

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.

3 participants