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

Fix -DCMAKE_CXX_STANDARD ignored by CMakeLists #273

Merged
merged 3 commits into from
Sep 15, 2022
Merged

Conversation

LafeWessel
Copy link
Contributor

The command line argument for setting the C++ standard to use is ignored. This change allows the default to remain 11 but allow for the user to override it.

Resolve #270

Add CACHE to setting CMAKE_CXX_STANDARD to allow for the user to override the default value.
…eLists

Fix set not having proper arguments
set(CMAKE_CXX_STANDARD 11)
# this than assuming what absl used.
# Using CACHE allows the user to override the default.
set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ standard to build with")
Copy link
Member

Choose a reason for hiding this comment

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

#270 (comment) suggests option. What's the difference between set(CACHE) and option / when would I want to use one or the other? @jievince

Choose a reason for hiding this comment

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

Hi @jmr, I am unfamiliar with CMake, and I don't know the difference between them. I just tried option, and it works.

Choose a reason for hiding this comment

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

Hi @LafeWessel, can you explain it?

Copy link
Contributor Author

@LafeWessel LafeWessel Sep 14, 2022

Choose a reason for hiding this comment

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

Based on the documentation, both option and set(CACHE) seem to do about the same thing.

https://cmake.org/cmake/help/latest/command/set.html#set-cache-entry

https://cmake.org/cmake/help/latest/command/option.html

However, based on the description of set(CACHE), it seems proper to use it instead of option in this use case. From the docs:

Sets the given cache (cache entry). Since cache entries are meant to provide user-settable values this does not overwrite existing cache entries by default. Use the FORCE option to overwrite existing entries.

Copy link

@jievince jievince left a comment

Choose a reason for hiding this comment

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

LGTM

@jmr jmr merged commit 01d6a50 into google:master Sep 15, 2022
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.

-DCMAKE_CXX_STANDARD=17 doesn't work
3 participants