From c06ab39887816123d32670c64de5e18a5a894bbd Mon Sep 17 00:00:00 2001 From: VeithMetro Date: Tue, 22 Aug 2023 10:32:37 +0200 Subject: [PATCH] Fixing warnings and adding warnings to the local build --- CMakeLists.txt | 22 ++++++++++++++++++++++ definitions/Definitions.cpp | 2 +- definitions/definitions.h | 12 ++++++------ interfaces/json/ExternalMetadata.h | 2 +- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a90bed3..4b916a28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,5 +26,27 @@ if (BUILD_REFERENCE) add_definitions (-DBUILD_REFERENCE=${BUILD_REFERENCE}) endif() +option(ENABLE_STRICT_COMPILER_SETTINGS + "Enable compiler flags to get the warnings/errors due to improper condition in the code" ON) + +if(ENABLE_STRICT_COMPILER_SETTINGS) + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + message(FATAL_ERROR "Compiling with Clang") + set(CMAKE_STRICT_COMPILER_SETTINGS "-Weverything -Wextra -Wpedantic -Werror") + set(CMAKE_STRICT_CXX_COMPILER_SETTINGS "${CMAKE_STRICT_COMPILER_SETTINGS} -Wnon-virtual-dtor") + elseif(${CMAKE_COMPILER_IS_GNUCXX}) + message(STATUS "Compiling with GCC") + set(CMAKE_STRICT_COMPILER_SETTINGS "-Wall -Wextra -Wpedantic -Werror") + set(CMAKE_STRICT_CXX_COMPILER_SETTINGS "${CMAKE_STRICT_COMPILER_SETTINGS} -Wnon-virtual-dtor") + elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + message(STATUS "Compiling with MS Visual Studio") + set(CMAKE_STRICT_COMPILER_SETTINGS "/W4") + else() + message(STATUS "Compiler ${CMAKE_CXX_COMPILER_ID}") + endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_STRICT_CXX_COMPILER_SETTINGS}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_STRICT_COMPILER_SETTINGS}") +endif() + add_subdirectory(interfaces) add_subdirectory(definitions) diff --git a/definitions/Definitions.cpp b/definitions/Definitions.cpp index 01d17bc7..62e60bea 100644 --- a/definitions/Definitions.cpp +++ b/definitions/Definitions.cpp @@ -83,7 +83,7 @@ #include "ValuePoint.h" #endif -MODULE_NAME_DECLARATION(BUILD_REFERENCE); +MODULE_NAME_DECLARATION(BUILD_REFERENCE) namespace WPEFramework { diff --git a/definitions/definitions.h b/definitions/definitions.h index df62a06f..1a868a86 100644 --- a/definitions/definitions.h +++ b/definitions/definitions.h @@ -47,10 +47,10 @@ namespace WPEFramework { - ENUM_CONVERSION_HANDLER(Exchange::IComposition::ScreenResolution); - ENUM_CONVERSION_HANDLER(Exchange::IStream::streamtype); - ENUM_CONVERSION_HANDLER(Exchange::IStream::state); - ENUM_CONVERSION_HANDLER(Exchange::IValuePoint::basic); - ENUM_CONVERSION_HANDLER(Exchange::IValuePoint::specific); - ENUM_CONVERSION_HANDLER(Exchange::IValuePoint::dimension); + ENUM_CONVERSION_HANDLER(Exchange::IComposition::ScreenResolution) + ENUM_CONVERSION_HANDLER(Exchange::IStream::streamtype) + ENUM_CONVERSION_HANDLER(Exchange::IStream::state) + ENUM_CONVERSION_HANDLER(Exchange::IValuePoint::basic) + ENUM_CONVERSION_HANDLER(Exchange::IValuePoint::specific) + ENUM_CONVERSION_HANDLER(Exchange::IValuePoint::dimension) } diff --git a/interfaces/json/ExternalMetadata.h b/interfaces/json/ExternalMetadata.h index 942eac90..0f00a6d3 100644 --- a/interfaces/json/ExternalMetadata.h +++ b/interfaces/json/ExternalMetadata.h @@ -57,5 +57,5 @@ namespace WPEFramework { } } - ENUM_CONVERSION_HANDLER(Exchange::External::Metadata::protocol); + ENUM_CONVERSION_HANDLER(Exchange::External::Metadata::protocol) }