Skip to content

Commit

Permalink
Do not override CMAKE_CXX_STANDARD (#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
srgbtl authored Sep 13, 2021
1 parent 320c593 commit 0da25b3
Showing 1 changed file with 15 additions and 12 deletions.
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

0 comments on commit 0da25b3

Please sign in to comment.