12
12
# CMake versions greater than the JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION policies will
13
13
# continue to generate policy warnings "CMake Warning (dev)...Policy CMP0XXX is not set:"
14
14
#
15
- set (JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION "3.8.0 " )
16
- set (JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION "3.13.2 " )
15
+ set (JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION "3.21.. " )
16
+ set (JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION "3.29 " )
17
17
cmake_minimum_required (VERSION ${JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION} )
18
18
if ("${CMAKE_VERSION} " VERSION_LESS "${JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION} " )
19
19
#Set and use the newest available cmake policies that are validated to work
@@ -40,12 +40,6 @@ foreach(pold "") # Currently Empty
40
40
endif ()
41
41
endforeach ()
42
42
43
- # Build the library with C++11 standard support, independent from other including
44
- # software which may use a different CXX_STANDARD or CMAKE_CXX_STANDARD.
45
- set (CMAKE_CXX_STANDARD 11 )
46
- set (CMAKE_CXX_EXTENSIONS OFF )
47
- set (CMAKE_CXX_STANDARD_REQUIRED ON )
48
-
49
43
# Ensure that CMAKE_BUILD_TYPE has a value specified for single configuration generators.
50
44
if (NOT DEFINED CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES )
51
45
set (CMAKE_BUILD_TYPE Release CACHE STRING
@@ -75,6 +69,15 @@ project(jsoncpp
75
69
VERSION 1.9.5 # <major>[.<minor>[.<patch>[.<tweak>]]]
76
70
LANGUAGES CXX )
77
71
72
+
73
+ if (PROJECT_IS_TOP_LEVEL )
74
+ # Build the library with C++11 standard support, independent from other including
75
+ # software which may use a different CXX_STANDARD or CMAKE_CXX_STANDARD.
76
+ set (CMAKE_CXX_STANDARD 11 )
77
+ set (CMAKE_CXX_EXTENSIONS OFF )
78
+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
79
+ endif ()
80
+
78
81
message (STATUS "JsonCpp Version: ${PROJECT_VERSION_MAJOR} .${PROJECT_VERSION_MINOR} .${PROJECT_VERSION_PATCH} " )
79
82
set (PROJECT_SOVERSION 25 )
80
83
@@ -105,6 +108,8 @@ endif()
105
108
106
109
set (JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL" )
107
110
111
+ add_library (project_options INTERFACE )
112
+
108
113
configure_file ("${PROJECT_SOURCE_DIR} /version.in"
109
114
"${PROJECT_BINARY_DIR} /version"
110
115
NEWLINE_STYLE UNIX )
@@ -113,53 +118,53 @@ macro(use_compilation_warning_as_error)
113
118
if (MSVC )
114
119
# Only enabled in debug because some old versions of VS STL generate
115
120
# warnings when compiled in release configuration.
116
- add_compile_options ( $< $< CONFIG:Debug> :/WX> )
121
+ target_compile_options ( project_options INTERFACE $< $< CONFIG:Debug> :/WX> )
117
122
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
118
- add_compile_options ( -Werror )
123
+ target_compile_options ( project_options INTERFACE -Werror )
119
124
if (JSONCPP_WITH_STRICT_ISO )
120
- add_compile_options ( -pedantic-errors )
125
+ target_compile_options ( project_options INTETFACE -pedantic-errors )
121
126
endif ()
122
127
endif ()
123
128
endmacro ()
124
129
125
130
# Include our configuration header
126
- include_directories ( ${jsoncpp_SOURCE_DIR} /include )
131
+ target_include_directories ( project_options INTERFACE ${jsoncpp_SOURCE_DIR} /include )
127
132
128
133
if (MSVC )
129
134
# Only enabled in debug because some old versions of VS STL generate
130
135
# unreachable code warning when compiled in release configuration.
131
- add_compile_options ( $< $< CONFIG:Debug> :/W4> )
136
+ target_compile_options ( project_options INTERFACE $< $< CONFIG:Debug> :/W4> )
132
137
if (JSONCPP_STATIC_WINDOWS_RUNTIME )
133
138
set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
134
139
endif ()
135
140
endif ()
136
141
137
142
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
138
143
# using regular Clang or AppleClang
139
- add_compile_options ( -Wall -Wconversion -Wshadow )
144
+ target_compile_options ( project_options INTERFACE -Wall -Wconversion -Wshadow )
140
145
141
146
if (JSONCPP_WITH_WARNING_AS_ERROR )
142
- add_compile_options ( -Werror=conversion -Werror=sign-compare )
147
+ target_compile_options ( project_options INTERFACE -Werror=conversion -Werror=sign-compare )
143
148
endif ()
144
149
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
145
150
# using GCC
146
- add_compile_options ( -Wall -Wconversion -Wshadow -Wextra )
151
+ target_compile_options ( project_options INTERFACE -Wall -Wconversion -Wshadow -Wextra )
147
152
# not yet ready for -Wsign-conversion
148
153
149
154
if (JSONCPP_WITH_STRICT_ISO )
150
- add_compile_options ( -Wpedantic )
155
+ target_compile_options ( project_options INTERFACE -Wpedantic )
151
156
endif ()
152
157
if (JSONCPP_WITH_WARNING_AS_ERROR )
153
- add_compile_options ( -Werror=conversion )
158
+ target_compile_options ( project_options INTERFACE -Werror=conversion )
154
159
endif ()
155
160
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" )
156
161
# using Intel compiler
157
- add_compile_options ( -Wall -Wconversion -Wshadow -Wextra )
162
+ target_compile_options ( project_options INTERFACE -Wall -Wconversion -Wshadow -Wextra )
158
163
159
164
if (JSONCPP_WITH_WARNING_AS_ERROR )
160
- add_compile_options ( -Werror=conversion )
165
+ target_compile_options ( project_options INTERFACE -Werror=conversion )
161
166
elseif (JSONCPP_WITH_STRICT_ISO )
162
- add_compile_options ( -Wpedantic )
167
+ target_compile_options ( project_options INTERFACE -Wpedantic )
163
168
endif ()
164
169
endif ()
165
170
0 commit comments