enh(ci): Add ENABLE_COMPILER_WARNINGS to cmake to enable additional compiler warnings

This commit is contained in:
Matej Kenda 2023-11-30 12:50:39 +01:00
parent 1e4c08b4eb
commit 381467d8f5
2 changed files with 17 additions and 1 deletions

View File

@ -206,6 +206,9 @@ endif()
option(ENABLE_TESTS
"Set to OFF|ON (default is OFF) to control build of POCO tests" OFF)
option(ENABLE_COMPILER_WARNINGS
"Set to OFF|ON (default is OFF) to enable additional compiler warnings. Intended primarily for maintainers." OFF)
option(ENABLE_SAMPLES
"Set to OFF|ON (default is OFF) to control build of POCO samples" OFF)

View File

@ -49,7 +49,20 @@ else(MSVC)
set(STATIC_POSTFIX "" CACHE STRING "Set static library postfix" FORCE)
endif(MSVC)
if (ENABLE_COMPILER_WARNINGS)
message(STATUS "Enabling additional compiler warning flags.")
# Additional compiler-specific warning flags
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# using clang
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
add_compile_options(/W4)
endif()
endif()
# Add a d postfix to the debug libraries
if(BUILD_SHARED_LIBS)