Fix -DCMAKE_CXX_STANDARD ignored by CMakeLists#273
Conversation
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") |
There was a problem hiding this comment.
#270 (comment) suggests option. What's the difference between set(CACHE) and option / when would I want to use one or the other? @jievince
There was a problem hiding this comment.
Hi @jmr, I am unfamiliar with CMake, and I don't know the difference between them. I just tried option, and it works.
There was a problem hiding this comment.
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.
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