Skip to content

Commit 5fabc5e

Browse files
authored
conversion errors only if warnings as errors enabled (#1284)
1 parent ed1ab7a commit 5fabc5e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ endif()
134134

135135
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
136136
# using regular Clang or AppleClang
137-
add_compile_options(-Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare)
137+
add_compile_options(-Wall -Wconversion -Wshadow)
138+
139+
if(JSONCPP_WITH_WARNING_AS_ERROR)
140+
add_compile_options(-Werror=conversion -Werror=sign-compare)
141+
endif()
138142
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
139143
# using GCC
140144
add_compile_options(-Wall -Wconversion -Wshadow -Wextra)
@@ -148,9 +152,11 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
148152
endif()
149153
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
150154
# using Intel compiler
151-
add_compile_options(-Wall -Wconversion -Wshadow -Wextra -Werror=conversion)
155+
add_compile_options(-Wall -Wconversion -Wshadow -Wextra)
152156

153-
if(JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
157+
if(JSONCPP_WITH_WARNING_AS_ERROR)
158+
add_compile_options(-Werror=conversion)
159+
elseif(JSONCPP_WITH_STRICT_ISO)
154160
add_compile_options(-Wpedantic)
155161
endif()
156162
endif()

0 commit comments

Comments
 (0)