Skip to content

Commit 811f589

Browse files
committed
Merge tag 'wl16601-werror' into trunk
2 parents 046ba79 + 9eee702 commit 811f589

File tree

6 files changed

+58
-3
lines changed

6 files changed

+58
-3
lines changed

CMakeLists.txt

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,31 +271,70 @@ endif()
271271
# TODO: Fix these warnings.
272272
#
273273

274+
# TODO: Also cover linker warnings
275+
276+
add_config_option(WERROR BOOL ADVANCED DEFAULT OFF
277+
"Turn compile warnings into errors"
278+
)
279+
280+
#
281+
# Note: If WERROR is enabled we change its value to be the actual compiler
282+
# option to be used on the current platform. That is used for easier
283+
# propagation to external builds.
284+
#
285+
# Note: In more recent cmake there is CMAKE_COMPILE_WARNING_AS_ERROR variable
286+
# but at the moment we can't ensure using that recent cmake.
287+
#
288+
289+
if(WERROR)
290+
set(WERROR -Werror)
291+
endif()
292+
274293
if(MSVC)
275294

276295
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
277296

278297
if(CXX_FRONTEND_MSVC)
298+
299+
if(WERROR)
300+
set(WERROR /WX) # MSVC equivalent of -Werror
301+
endif()
302+
279303
# Disable MSVC unreachable code warnings unless requested.
280304
add_compile_options(/wd4702)
281305

282306
# Disable MSVC warning C4297 as it seems to be buggy.
283307
# Seehttps://connect.microsoft.com/VisualStudio/feedback/details/897611/incorrect-warning-of-c4297-for-destructor-with-try-catch-statement
284308

285309
add_compile_options(/wd4297)
310+
286311
endif()
287312

288-
endif()
313+
elseif(SUNPRO)
289314

315+
# Note: For simplicity we do not handle WERROR on SunOS
290316

291-
if(SUNPRO)
317+
set(WERROR)
292318

293319
add_compile_options(
294320
-errtags=yes -erroff=hidevf,wvarhidemem
295321
)
296322

297323
endif()
298324

325+
if(NOT WERROR)
326+
# clear if WERROR was set to something like OFF or FALSE
327+
# message(STATUS "WERROR: cleared")
328+
unset(WERROR CACHE)
329+
else()
330+
# overwrite cache entry with changed value
331+
set(WERROR "${WERROR}" CACHE INTERNAL "WERROR flags" FORCE)
332+
endif()
333+
334+
# message(STATUS "WERROR: ${WERROR}")
335+
add_compile_options(${WERROR})
336+
337+
299338
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 12.0)
300339
# Silence a warning produced by a regression in GCC 12.0 and newer
301340
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106199

cdk/cmake/dependency.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ set(EXT_FWD
6060
CMAKE_SYSTEM_PROCESSOR
6161
CMAKE_C_COMPILER CMAKE_CXX_COMPILER
6262
MSVC
63+
WERROR
6364
)
6465

6566
set(EXT_DIR ${CMAKE_CURRENT_LIST_DIR}/ext CACHE INTERNAL "external project utils location")
@@ -129,7 +130,7 @@ function(add_ext NAME HEADER)
129130
"${EXT_LIB} library name"
130131
)
131132

132-
133+
133134
#show_config_options()
134135

135136
# Handle non-path value of WITH_X option

cdk/extra/lz4/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ include(platform)
3434

3535
enable_pic()
3636

37+
if(WERROR)
38+
add_compile_options(${WERROR})
39+
endif()
40+
3741
add_library(lz4 STATIC
3842
lib/lz4.c
3943
lib/lz4frame.c

cdk/extra/protobuf/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ SET(PROTO_SRC_DIR "${PROJECT_SOURCE_DIR}/protobuf-3.19.6")
7373
enable_pic()
7474
enable_cxx17()
7575

76+
if(WERROR)
77+
add_compile_options(${WERROR})
78+
endif()
79+
7680
# -O3 using GCC on SPARC leds to segfault on protoc
7781
if(SPARC AND GCC)
7882
foreach(LANG C CXX)

cdk/extra/zlib/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ set(VERSION "1.3.1")
99
project(zlib VERSION ${VERSION} LANGUAGES C)
1010

1111
option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
12+
if(WERROR)
13+
add_compile_options(${WERROR})
14+
endif()
1215

1316
IF(DISABLE_THESE_LINES)
1417
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")

cdk/extra/zstd/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ include(platform)
1515

1616
enable_pic()
1717

18+
if(WERROR)
19+
add_compile_options(${WERROR})
20+
endif()
21+
1822

1923
SET(ZSTD_LIB_DIR
2024
"${PROJECT_SOURCE_DIR}/lib")

0 commit comments

Comments
 (0)