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

Diff for: gui/CMakeLists.txt

+18-11
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

Diff for: gui/compliancereportdialog.cpp

+1-1
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()

Diff for: gui/mainwindow.cpp

+1-1
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;

Diff for: gui/projectfile.cpp

+1-1
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) {

Diff for: gui/projectfiledialog.cpp

+1-1
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());

Diff for: gui/test/cppchecklibrarydata/CMakeLists.txt

+4-2
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)

Diff for: gui/test/filelist/CMakeLists.txt

+4-2
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)

Diff for: gui/test/projectfile/CMakeLists.txt

+4-2
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)

Diff for: gui/test/resultstree/CMakeLists.txt

+4-2
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()

Diff for: gui/test/translationhandler/CMakeLists.txt

+4-2
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)

Diff for: gui/test/xmlreportv2/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ if (BUILD_CORE_DLL)
2929
target_link_libraries(test-xmlreportv2 cppcheck-core)
3030
endif()
3131
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
32-
target_compile_options_safe(test-xmlreportv2 -Wno-extra-semi-stmt)
32+
if(QT_VERSION VERSION_LESS "6.0.0")
33+
# Q_UNUSED() in generated code - see https://bugreports.qt.io/browse/QTBUG-82978
34+
target_compile_options_safe(test-xmlreportv2 -Wno-extra-semi-stmt)
35+
endif()
3336
endif()
3437

3538
if (REGISTER_GUI_TESTS)

Diff for: tools/triage/CMakeLists.txt

+19-12
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ CheckOptions:
88
- { key: HeaderFileExtensions, value: 'x' }
99
")
1010

11-
# TODO: limit to target
12-
add_compile_definitions($<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
13-
add_compile_definitions($<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG_OUTPUT>)
14-
add_compile_definitions($<$<NOT:$<CONFIG:Debug>>:QT_NO_WARNING_OUTPUT>)
15-
add_compile_definitions($<$<CONFIG:Debug>:QT_DEBUG>)
16-
1711
file(GLOB hdrs "*.h")
1812
file(GLOB srcs "*.cpp")
1913
file(GLOB uis "*.ui")
@@ -28,14 +22,27 @@ CheckOptions:
2822
${PROJECT_SOURCE_DIR}/gui/codeeditorstyle.cpp
2923
${PROJECT_SOURCE_DIR}/gui/codeeditor.cpp)
3024
set_target_properties(triage PROPERTIES AUTOMOC ON)
31-
set_target_properties(cppcheck-gui PROPERTIES WIN32_EXECUTABLE ON)
25+
set_target_properties(triage PROPERTIES WIN32_EXECUTABLE ON)
3226
target_include_directories(triage PRIVATE ${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/gui/)
3327
target_link_libraries(triage ${QT_CORE_LIB} ${QT_GUI_LIB} ${QT_WIDGETS_LIB})
3428
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
35-
# Q_UNUSED() in generated code
36-
target_compile_options_safe(triage -Wno-extra-semi-stmt)
37-
# caused by Qt generated moc code
38-
target_compile_options_safe(triage -Wno-redundant-parens)
29+
if(QT_VERSION VERSION_LESS "6.0.0")
30+
# Q_UNUSED() in generated code - see https://bugreports.qt.io/browse/QTBUG-82978
31+
target_compile_options_safe(triage -Wno-extra-semi-stmt)
32+
endif()
33+
if(QT_VERSION VERSION_LESS "6.4.0")
34+
# caused by Qt generated moc code - see https://bugreports.qt.io/browse/QTBUG-100915
35+
target_compile_options_safe(triage -Wno-redundant-parens)
36+
endif()
37+
endif()
38+
if(QT_VERSION VERSION_GREATER_EQUAL "6.9.0")
39+
# QBrush fails to compile before 6.9.0 - see https://bugreports.qt.io/browse/QTBUG-134038
40+
target_compile_definitions(triage PRIVATE -DQT_NO_QPAIR)
3941
endif()
40-
#target_compile_definitions(triage PRIVATE -DQT_NO_QPAIR) # TODO: cannot be completely disabled because QBrush uses QPair
42+
target_compile_definitions(triage PRIVATE -DQT_NO_FOREACH)
43+
44+
target_compile_definitions(triage PRIVATE $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
45+
target_compile_definitions(triage PRIVATE $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG_OUTPUT>)
46+
target_compile_definitions(triage PRIVATE $<$<NOT:$<CONFIG:Debug>>:QT_NO_WARNING_OUTPUT>)
47+
target_compile_definitions(triage PRIVATE $<$<CONFIG:Debug>:QT_DEBUG>)
4148
endif()

0 commit comments

Comments
 (0)