Skip to content

Commit

Permalink
Enable Werror on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Waqar144 committed Apr 5, 2024
1 parent 08ad63c commit 172e4c5
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 9 deletions.
2 changes: 2 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ if(GAMMARAY_WITH_KDSME)
)

gammaray_ensure_submodule_exists(KDStateMachineEditor)
# remove this as it clashes with Gammaray's DQT_DISABLE_DEPRECATED_BEFORE
remove_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050500)
add_subdirectory(KDStateMachineEditor)
endfunction()
add_ksme_subdirectory()
Expand Down
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
# Use GNU gold linker
# Default=false
#
# -DWARNINGS_ARE_ERRORS=[true|false]
# Enables -Werror
# Default = false
#

cmake_minimum_required(VERSION 3.16.0)

Expand Down Expand Up @@ -269,6 +273,8 @@ gammaray_option(GAMMARAY_ENFORCE_QT_ASSERTS "Force QT_ASSERT in all builds." OFF

gammaray_option(GAMMARAY_DISABLE_FEEDBACK "Disable user feedback support." ${GAMMARAY_DISABLE_FEEDBACK_DEFAULT})

gammaray_option(WARNINGS_ARE_ERRORS "Enables -Werror" OFF)

#
# Static probe setup
#
Expand Down Expand Up @@ -555,6 +561,23 @@ endif()
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050500)
#add_definitions(-DQT_DEPRECATED_WARNINGS)

if (WARNINGS_ARE_ERRORS)
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-error=deprecated-declarations")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND QT_VERSION_MAJOR EQUAL 5)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=suggest-override") # Q_OBJECT expansion warnings
endif()

if (CMAKE_COMPILER_IS_GNUCXX)
# each compiler has its own opinion on when to apply [noreturn]
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=suggest-attribute=noreturn")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
add_definitions(-D_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING)
endif()
endif()

if(NOT DEFINED QT_LIBINFIX)
set(QT_LIBINFIX "")
endif()
Expand Down
12 changes: 8 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@
"cacheVariables": {
"GAMMARAY_CLIENT_ONLY_BUILD": "ON",
"GAMMARAY_INSTALL_QT_LAYOUT": "ON",
"GAMMARAY_MULTI_BUILD": "OFF"
"GAMMARAY_MULTI_BUILD": "OFF",
"WARNINGS_ARE_ERRORS": "ON"
},
"inherits": [
"dev"
Expand All @@ -165,7 +166,8 @@
"cacheVariables": {
"GAMMARAY_CLIENT_ONLY_BUILD": "ON",
"GAMMARAY_INSTALL_QT_LAYOUT": "ON",
"GAMMARAY_MULTI_BUILD": "OFF"
"GAMMARAY_MULTI_BUILD": "OFF",
"WARNINGS_ARE_ERRORS": "ON"
},
"inherits": [
"dev6"
Expand All @@ -180,7 +182,8 @@
"cacheVariables": {
"GAMMARAY_CLIENT_ONLY_BUILD": "OFF",
"GAMMARAY_INSTALL_QT_LAYOUT": "ON",
"GAMMARAY_MULTI_BUILD": "OFF"
"GAMMARAY_MULTI_BUILD": "OFF",
"WARNINGS_ARE_ERRORS": "ON"
},
"inherits": [
"dev"
Expand All @@ -195,7 +198,8 @@
"cacheVariables": {
"GAMMARAY_CLIENT_ONLY_BUILD": "OFF",
"GAMMARAY_INSTALL_QT_LAYOUT": "ON",
"GAMMARAY_MULTI_BUILD": "OFF"
"GAMMARAY_MULTI_BUILD": "OFF",
"WARNINGS_ARE_ERRORS": "ON"
},
"inherits": [
"dev6"
Expand Down
2 changes: 1 addition & 1 deletion client/processtracker_macos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void ProcessTrackerBackendMacOS::checkProcess(qint64 pid)

// Call sysctl.
size = sizeof(info);
status = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); // krazy:exclude=null
status = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0);

if (status == 0) {
// We're being debugged if the P_TRACED flag is set.
Expand Down
2 changes: 1 addition & 1 deletion common/enumdefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void EnumDefinition::setIsFlag(bool isFlag)
m_isFlag = isFlag;
}

QVector<EnumDefinitionElement> EnumDefinition::elements() const
const QVector<EnumDefinitionElement> &EnumDefinition::elements() const
{
return m_elements;
}
Expand Down
2 changes: 1 addition & 1 deletion common/enumdefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class GAMMARAY_COMMON_EXPORT EnumDefinition
/*! Returns the individual elements of this enum.
* That is, the key/value pairs of its definition.
*/
QVector<EnumDefinitionElement> elements() const;
const QVector<EnumDefinitionElement> &elements() const;

//! @cond internal
void setElements(const QVector<EnumDefinitionElement> &elements);
Expand Down
2 changes: 1 addition & 1 deletion core/metaobjectregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void MetaObjectRegistry::objectAdded(QObject *obj)

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
// Lifted from Qt
struct MetaTypeCoreHelper : public QMetaTypeModuleHelper
struct MetaTypeCoreHelper final : public QMetaTypeModuleHelper
{
template<typename T, typename LiteralWrapper = std::conditional_t<std::is_same_v<T, QString>, QLatin1String, const char *>>
static inline bool convertToBool(const T &source)
Expand Down
2 changes: 1 addition & 1 deletion core/tools/objectinspector/bindingmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ QVariant BindingModel::data(const QModelIndex &index, int role) const
return binding->sourceLocation().displayString();
case DepthColumn: {
uint depth = binding->depth();
return depth == std::numeric_limits<uint>::max() ? QStringLiteral("\u221E") : QString::number(depth); // Unicode infinity sign
return depth == std::numeric_limits<uint>::max() ? QString(QChar(0x221E)) : QString::number(depth); // Unicode infinity sign
}
}
} else if (role == ObjectModel::DeclarationLocationRole) {
Expand Down

0 comments on commit 172e4c5

Please sign in to comment.