Skip to content

Commit 7cdf9f9

Browse files
authored
cleaned up build flags for GUI (danmar#7367)
1 parent 75ec331 commit 7cdf9f9

File tree

12 files changed

+65
-38
lines changed

12 files changed

+65
-38
lines changed

gui/CMakeLists.txt

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ CheckOptions:
99
- { key: HeaderFileExtensions, value: 'x' }
1010
")
1111

12-
# TODO: limit to target
13-
add_compile_definitions($<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
14-
add_compile_definitions($<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG_OUTPUT>)
15-
add_compile_definitions($<$<NOT:$<CONFIG:Debug>>:QT_NO_WARNING_OUTPUT>)
16-
add_compile_definitions($<$<CONFIG:Debug>:QT_DEBUG>)
17-
1812
file(GLOB hdrs "*.h")
1913
file(GLOB srcs "*.cpp")
2014
file(GLOB uis "*.ui")
@@ -73,12 +67,25 @@ CheckOptions:
7367
endif()
7468
endif()
7569
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
76-
# Q_UNUSED() in generated code
77-
target_compile_options_safe(cppcheck-gui -Wno-extra-semi-stmt)
78-
# caused by Qt generated moc code
79-
target_compile_options_safe(cppcheck-gui -Wno-redundant-parens)
70+
if(QT_VERSION VERSION_LESS "6.0.0")
71+
# Q_UNUSED() in generated code - see https://bugreports.qt.io/browse/QTBUG-82978
72+
target_compile_options_safe(cppcheck-gui -Wno-extra-semi-stmt)
73+
endif()
74+
if(QT_VERSION VERSION_LESS "6.4.0")
75+
# caused by Qt generated moc code - see https://bugreports.qt.io/browse/QTBUG-100915
76+
target_compile_options_safe(cppcheck-gui -Wno-redundant-parens)
77+
endif()
8078
endif()
81-
#target_compile_definitions(cppcheck-gui PRIVATE -DQT_NO_QPAIR) # TODO: cannot be completely disabled because QBrush uses QPair
79+
if(QT_VERSION VERSION_GREATER_EQUAL "6.9.0")
80+
# QBrush fails to compile before 6.9.0 - see https://bugreports.qt.io/browse/QTBUG-134038
81+
target_compile_definitions(cppcheck-gui PRIVATE -DQT_NO_QPAIR)
82+
endif()
83+
target_compile_definitions(cppcheck-gui PRIVATE -DQT_NO_FOREACH)
84+
85+
target_compile_definitions(cppcheck-gui PRIVATE $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
86+
target_compile_definitions(cppcheck-gui PRIVATE $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG_OUTPUT>)
87+
target_compile_definitions(cppcheck-gui PRIVATE $<$<NOT:$<CONFIG:Debug>>:QT_NO_WARNING_OUTPUT>)
88+
target_compile_definitions(cppcheck-gui PRIVATE $<$<CONFIG:Debug>:QT_DEBUG>)
8289

8390
if (QHELPGENERATOR)
8491
# TODO: generate in CMAKE_BINARY_DIR folder

gui/compliancereportdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void ComplianceReportDialog::buttonClicked(QAbstractButton* button)
122122
break;
123123
default:
124124
break;
125-
};
125+
}
126126
}
127127

128128
void ComplianceReportDialog::save()

gui/mainwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ bool MainWindow::getCppcheckSettings(Settings& settings, Suppressions& supprs)
11451145
case ProjectFile::CheckLevel::exhaustive:
11461146
settings.setCheckLevel(Settings::CheckLevel::exhaustive);
11471147
break;
1148-
};
1148+
}
11491149
settings.checkHeaders = mProjectFile->getCheckHeaders();
11501150
settings.checkUnusedTemplates = mProjectFile->getCheckUnusedTemplates();
11511151
settings.safeChecks.classes = mProjectFile->safeChecks.classes;

gui/projectfile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ bool ProjectFile::write(const QString &filename)
10251025
xmlWriter.writeStartElement(CppcheckXml::CheckLevelExhaustiveElementName);
10261026
xmlWriter.writeEndElement();
10271027
break;
1028-
};
1028+
}
10291029

10301030
// Cppcheck Premium
10311031
if (mBughunting) {

gui/projectfiledialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
319319
case ProjectFile::CheckLevel::exhaustive:
320320
mUI->mCheckLevelExhaustive->setChecked(true);
321321
break;
322-
};
322+
}
323323
mUI->mCheckHeaders->setChecked(projectFile->getCheckHeaders());
324324
mUI->mCheckUnusedTemplates->setChecked(projectFile->getCheckUnusedTemplates());
325325
mUI->mInlineSuppressions->setChecked(projectFile->getInlineSuppression());

gui/test/cppchecklibrarydata/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ target_compile_definitions(test-cppchecklibrarydata PRIVATE SRCDIR="${CMAKE_CURR
1313
target_link_libraries(test-cppchecklibrarydata ${QT_CORE_LIB} ${QT_TEST_LIB})
1414

1515
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
16-
# Q_UNUSED() in generated code
17-
target_compile_options_safe(test-cppchecklibrarydata -Wno-extra-semi-stmt)
16+
if(QT_VERSION VERSION_LESS "6.0.0")
17+
# Q_UNUSED() in generated code - see https://bugreports.qt.io/browse/QTBUG-82978
18+
target_compile_options_safe(test-cppchecklibrarydata -Wno-extra-semi-stmt)
19+
endif()
1820
endif()
1921

2022
if (REGISTER_GUI_TESTS)

gui/test/filelist/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ target_compile_definitions(test-filelist PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_
1616
target_link_libraries(test-filelist ${QT_CORE_LIB} ${QT_TEST_LIB})
1717

1818
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
19-
# Q_UNUSED() in generated code
20-
target_compile_options_safe(test-filelist -Wno-extra-semi-stmt)
19+
if(QT_VERSION VERSION_LESS "6.0.0")
20+
# Q_UNUSED() in generated code - see https://bugreports.qt.io/browse/QTBUG-82978
21+
target_compile_options_safe(test-filelist -Wno-extra-semi-stmt)
22+
endif()
2123
endif()
2224

2325
if (REGISTER_GUI_TESTS)

gui/test/projectfile/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ target_compile_definitions(test-projectfile PRIVATE SRCDIR="${CMAKE_CURRENT_SOUR
1111
target_link_libraries(test-projectfile ${QT_CORE_LIB} ${QT_TEST_LIB})
1212

1313
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
14-
# Q_UNUSED() in generated code
15-
target_compile_options_safe(test-projectfile -Wno-extra-semi-stmt)
14+
if(QT_VERSION VERSION_LESS "6.0.0")
15+
# Q_UNUSED() in generated code - see https://bugreports.qt.io/browse/QTBUG-82978
16+
target_compile_options_safe(test-projectfile -Wno-extra-semi-stmt)
17+
endif()
1618
endif()
1719

1820
if (REGISTER_GUI_TESTS)

gui/test/resultstree/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ if(tinyxml2_FOUND AND NOT USE_BUNDLED_TINYXML2)
3939
endif()
4040

4141
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
42-
# Q_UNUSED() in generated code
43-
target_compile_options_safe(test-resultstree -Wno-extra-semi-stmt)
42+
if(QT_VERSION VERSION_LESS "6.0.0")
43+
# Q_UNUSED() in generated code - see https://bugreports.qt.io/browse/QTBUG-82978
44+
target_compile_options_safe(test-resultstree -Wno-extra-semi-stmt)
45+
endif()
4446
# caused by mocks
4547
target_compile_options_safe(test-resultstree -Wno-missing-noreturn)
4648
endif()

gui/test/translationhandler/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ target_include_directories(test-translationhandler PRIVATE ${CMAKE_SOURCE_DIR}/g
1111
target_link_libraries(test-translationhandler ${QT_CORE_LIB} ${QT_WIDGETS_LIB} ${QT_TEST_LIB})
1212

1313
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
14-
# Q_UNUSED() in generated code
15-
target_compile_options_safe(test-translationhandler -Wno-extra-semi-stmt)
14+
if(QT_VERSION VERSION_LESS "6.0.0")
15+
# Q_UNUSED() in generated code - see https://bugreports.qt.io/browse/QTBUG-82978
16+
target_compile_options_safe(test-translationhandler -Wno-extra-semi-stmt)
17+
endif()
1618
endif()
1719

1820
if (REGISTER_GUI_TESTS)

0 commit comments

Comments
 (0)