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

Do not override CMAKE_CXX_STANDARD #977

Merged
merged 3 commits into from
Sep 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,25 @@ else()
)
endif()

if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()

option(WITH_STL "Whether to use Standard Library for C++latest features" OFF)

option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF)

if(NOT DEFINED CMAKE_CXX_STANDARD)
if(WITH_STL)
# Require at least C++17. C++20 is needed to avoid gsl::span
if(CMAKE_VERSION VERSION_GREATER 3.11.999)
# Ask for 20, may get anything below
set(CMAKE_CXX_STANDARD 20)
else()
# Ask for 17, may get anything below
set(CMAKE_CXX_STANDARD 17)
endif()
else()
set(CMAKE_CXX_STANDARD 11)
endif()
endif()

if(WITH_ABSEIL)
find_package(absl CONFIG REQUIRED)

Expand All @@ -112,14 +123,6 @@ if(WITH_STL)
# the global project build definitions.
add_definitions(-DHAVE_CPP_STDLIB)
add_definitions(-DHAVE_GSL)
# Require at least C++17. C++20 is needed to avoid gsl::span
if(CMAKE_VERSION VERSION_GREATER 3.11.999)
# Ask for 20, may get anything below
set(CMAKE_CXX_STANDARD 20)
else()
# Ask for 17, may get anything below
set(CMAKE_CXX_STANDARD 17)
endif()

# Guidelines Support Library path. Used if we are not on not get C++20.
#
Expand Down