@@ -37,27 +37,14 @@ foreach(pold "") # Currently Empty
37
37
endif ()
38
38
endforeach ()
39
39
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
- # ====
58
-
59
- # Ensures that CMAKE_BUILD_TYPE has a default value
60
- if (NOT DEFINED CMAKE_BUILD_TYPE )
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 )
45
+
46
+ # Ensure that CMAKE_BUILD_TYPE has a value specified for single configuration generators.
47
+ if (NOT DEFINED CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES )
61
48
set (CMAKE_BUILD_TYPE Release CACHE STRING
62
49
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage." )
63
50
endif ()
@@ -95,16 +82,9 @@ option(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" ON)
95
82
option (JSONCPP_WITH_EXAMPLE "Compile JsonCpp example" OFF )
96
83
option (BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF )
97
84
98
- # Enable runtime search path support for dynamic libraries on OSX
99
- if (APPLE )
100
- set (CMAKE_MACOSX_RPATH 1)
101
- endif ()
102
-
103
85
# Adhere to GNU filesystem layout conventions
104
86
include (GNUInstallDirs)
105
87
106
- set (DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build" )
107
-
108
88
set (JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL" )
109
89
110
90
configure_file ("${PROJECT_SOURCE_DIR} /version.in"
@@ -115,23 +95,11 @@ macro(use_compilation_warning_as_error)
115
95
if (MSVC )
116
96
# Only enabled in debug because some old versions of VS STL generate
117
97
# warnings when compiled in release configuration.
118
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
119
- add_compile_options ($<$<CONFIG:Debug>:/WX>)
120
- else ()
121
- set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX " )
122
- endif ()
98
+ add_compile_options ($<$<CONFIG:Debug>:/WX>)
123
99
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
124
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
125
- add_compile_options (-Werror)
126
- else ()
127
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror" )
128
- endif ()
100
+ add_compile_options (-Werror)
129
101
if (JSONCPP_WITH_STRICT_ISO)
130
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
131
- add_compile_options (-pedantic-errors)
132
- else ()
133
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors" )
134
- endif ()
102
+ add_compile_options (-pedantic-errors)
135
103
endif ()
136
104
endif ()
137
105
endmacro ()
@@ -142,57 +110,29 @@ include_directories(${jsoncpp_SOURCE_DIR}/include)
142
110
if (MSVC )
143
111
# Only enabled in debug because some old versions of VS STL generate
144
112
# unreachable code warning when compiled in release configuration.
145
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
146
- add_compile_options ($<$<CONFIG:Debug>:/W4>)
147
- else ()
148
- set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 " )
149
- endif ()
113
+ add_compile_options ($<$<CONFIG:Debug>:/W4>)
150
114
endif ()
151
115
152
116
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
153
117
# using regular Clang or AppleClang
154
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
155
- add_compile_options (-Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare)
156
- else ()
157
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare" )
158
- endif ()
118
+ add_compile_options (-Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare)
159
119
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
160
120
# using GCC
161
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
162
- add_compile_options (-Wall -Wconversion -Wshadow -Wextra)
163
- else ()
164
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Wextra" )
165
- endif ()
121
+ add_compile_options (-Wall -Wconversion -Wshadow -Wextra)
166
122
# not yet ready for -Wsign-conversion
167
123
168
124
if (JSONCPP_WITH_STRICT_ISO)
169
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
170
- add_compile_options (-Wpedantic)
171
- else ()
172
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic" )
173
- endif ()
125
+ add_compile_options (-Wpedantic)
174
126
endif ()
175
127
if (JSONCPP_WITH_WARNING_AS_ERROR)
176
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
177
- add_compile_options (-Werror=conversion)
178
- else ()
179
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=conversion" )
180
- endif ()
128
+ add_compile_options (-Werror=conversion)
181
129
endif ()
182
130
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" )
183
131
# using Intel compiler
184
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
185
- add_compile_options (-Wall -Wconversion -Wshadow -Wextra -Werror=conversion)
186
- else ()
187
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Wextra -Werror=conversion" )
188
- endif ()
132
+ add_compile_options (-Wall -Wconversion -Wshadow -Wextra -Werror=conversion)
189
133
190
134
if (JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
191
- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
192
- add_compile_options (-Wpedantic)
193
- else ()
194
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic" )
195
- endif ()
135
+ add_compile_options (-Wpedantic)
196
136
endif ()
197
137
endif ()
198
138
0 commit comments