Skip to content

Commit 12ceb01

Browse files
committed
Always use consistent CXX_STANDARD
Since CMake has subdirectory variable scope, unilaterally set the CMAKE_CXX_STANDARD variable to use C++11. This covers cases with the library being included externally, both in cases of only C++98 being specified, as well as later versions being specified (since the CXX_STANDARD itself isn't a library dependency, only the PUBLIC target_compile_features on jsoncpp_lib). The previous direct check for C++98 is handled by requiring C++11 on this library; should the compiler being used not support C++11 then CMake will issue an error.
1 parent edc6239 commit 12ceb01

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

CMakeLists.txt

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,11 @@ foreach(pold "") # Currently Empty
3737
endif()
3838
endforeach()
3939

40-
# ==== Define language standard configurations requiring at least c++11 standard
41-
if(CMAKE_CXX_STANDARD EQUAL "98")
42-
message(FATAL_ERROR "CMAKE_CXX_STANDARD:STRING=98 is not supported.")
43-
endif()
44-
45-
#####
46-
## Set the default target properties
47-
if(NOT CMAKE_CXX_STANDARD)
48-
set(CMAKE_CXX_STANDARD 11) # Supported values are ``11``, ``14``, and ``17``.
49-
endif()
50-
if(NOT CMAKE_CXX_STANDARD_REQUIRED)
51-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
52-
endif()
53-
if(NOT CMAKE_CXX_EXTENSIONS)
54-
set(CMAKE_CXX_EXTENSIONS OFF)
55-
endif()
56-
57-
# ====
40+
# Build the library with C++11 standard support, independent from other including
41+
# software which may use a different CXX_STANDARD or CMAKE_CXX_STANDARD.
42+
set(CMAKE_CXX_STANDARD 11)
43+
set(CMAKE_CXX_EXTENSIONS OFF)
44+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5845

5946
# Ensure that CMAKE_BUILD_TYPE has a value specified for single configuration generators.
6047
if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)

0 commit comments

Comments
 (0)