Skip to content

Commit 14400be

Browse files
authored
refs #12021 - CI-windows.yml: fail build on compiler warnings / some cleanups (#6982)
1 parent 8765840 commit 14400be

13 files changed

+371
-149
lines changed

.github/workflows/CI-windows.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ jobs:
5252
run: |
5353
; TODO: enable rules?
5454
; specify Release build so matchcompiler is used
55-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_ONLINE_HELP=On || exit /b !errorlevel!
55+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_ONLINE_HELP=On || exit /b !errorlevel!
5656
cmake --build build --target cppcheck-gui --config Release || exit /b !errorlevel!
5757
5858
- name: Build GUI release (Qt 6)
5959
if: startsWith(matrix.qt_ver, '6')
6060
run: |
6161
; TODO: enable rules?
6262
; specify Release build so matchcompiler is used
63-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_ONLINE_HELP=On || exit /b !errorlevel!
63+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_ONLINE_HELP=On || exit /b !errorlevel!
6464
cmake --build build --target cppcheck-gui --config Release || exit /b !errorlevel!
6565
6666
- name: Deploy GUI
@@ -135,16 +135,15 @@ jobs:
135135
python -m pip install pytest-timeout || exit /b !errorlevel!
136136
python -m pip install psutil || exit /b !errorlevel!
137137
138-
- name: Run CMake
139-
if: false # TODO: enable
140-
run: |
141-
cmake -S . -B build -DBUILD_TESTS=On || exit /b !errorlevel!
138+
# TODO: build with CMake
142139

143140
- name: Build CLI debug configuration using MSBuild
144141
if: matrix.config == 'debug'
145142
run: |
146143
:: cmake --build build --target check --config Debug || exit /b !errorlevel!
147144
msbuild -m cppcheck.sln /p:Configuration=Debug-PCRE;Platform=x64 -maxcpucount || exit /b !errorlevel!
145+
env:
146+
_CL_: /WX
148147

149148
- name: Run Debug test
150149
if: matrix.config == 'debug'
@@ -155,6 +154,8 @@ jobs:
155154
run: |
156155
:: cmake --build build --target check --config Release || exit /b !errorlevel!
157156
msbuild -m cppcheck.sln /p:Configuration=Release-PCRE;Platform=x64 -maxcpucount || exit /b !errorlevel!
157+
env:
158+
_CL_: /WX
158159

159160
- name: Run Release test
160161
if: matrix.config == 'release'

cli/cli.vcxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9393
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
9494
<WarningLevel>Level4</WarningLevel>
95-
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4482;4512;4701;4706;4800;4805</DisableSpecificWarnings>
95+
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4701;4706;4800;4805</DisableSpecificWarnings>
9696
<MultiProcessorCompilation>true</MultiProcessorCompilation>
9797
<PrecompiledHeader>Use</PrecompiledHeader>
9898
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
@@ -121,7 +121,7 @@
121121
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
122122
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
123123
<WarningLevel>Level4</WarningLevel>
124-
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4482;4512;4701;4706;4800;4805</DisableSpecificWarnings>
124+
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4701;4706;4800;4805</DisableSpecificWarnings>
125125
<MultiProcessorCompilation>true</MultiProcessorCompilation>
126126
<PrecompiledHeader>Use</PrecompiledHeader>
127127
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
@@ -155,7 +155,7 @@
155155
<OmitFramePointers>true</OmitFramePointers>
156156
<FunctionLevelLinking>true</FunctionLevelLinking>
157157
<StringPooling>true</StringPooling>
158-
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4482;4512;4701;4706;4800;4805</DisableSpecificWarnings>
158+
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4701;4706;4800;4805</DisableSpecificWarnings>
159159
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
160160
<MultiProcessorCompilation>true</MultiProcessorCompilation>
161161
<PrecompiledHeader>Use</PrecompiledHeader>
@@ -193,7 +193,7 @@
193193
<OmitFramePointers>true</OmitFramePointers>
194194
<FunctionLevelLinking>true</FunctionLevelLinking>
195195
<StringPooling>true</StringPooling>
196-
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4482;4512;4701;4706;4800;4805</DisableSpecificWarnings>
196+
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4701;4706;4800;4805</DisableSpecificWarnings>
197197
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
198198
<MultiProcessorCompilation>true</MultiProcessorCompilation>
199199
<PrecompiledHeader>Use</PrecompiledHeader>

cmake/compileroptions.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,10 @@ if(MSVC)
176176
add_compile_options(/wd4127) # warning C4127: conditional expression is constant
177177
add_compile_options(/wd4146) # warning C4146: unary minus operator applied to unsigned type, result still unsigned
178178
add_compile_options(/wd4244) # warning C4244: 'initializing': conversion from 'int' to 'char', possible loss of data
179-
add_compile_options(/wd4251)
179+
add_compile_options(/wd4251) # warning C4251: 'x': class 'y' needs to have dll-interface to be used by clients of struct 'u'
180180
# Clang: -Wshorten-64-to-32 -Wimplicit-int-conversion
181181
add_compile_options(/wd4267) # warning C4267: 'return': conversion from 'size_t' to 'int', possible loss of data
182182
add_compile_options(/wd4389) # warning C4389: '==': signed/unsigned mismatch
183-
add_compile_options(/wd4482)
184-
add_compile_options(/wd4512)
185183
add_compile_options(/wd4701) # warning C4701: potentially uninitialized local variable 'err' used
186184
add_compile_options(/wd4706) # warning C4706: assignment within conditional expression
187185
add_compile_options(/wd4800) # warning C4800: 'const SymbolDatabase *' : forcing value to bool 'true' or 'false' (performance warning)

gui/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ CheckOptions:
6363
if(MSVC)
6464
# compilation will fail as e.g. QList::realloc would be replaced by MSVC's macro definition
6565
target_compile_definitions(cppcheck-gui PRIVATE $<$<CONFIG:Debug>:DISABLE_CRTDBG_MAP_ALLOC>)
66+
if(NOT USE_QT6)
67+
target_compile_options(cppcheck-gui PRIVATE /wd4996) # warning C4996: 'QProcess::startDetached': Use QProcess::startDetached(const QString &program, const QStringList &arguments) instead
68+
target_compile_options(cppcheck-gui PRIVATE /wd4505) # warning C4505: 'x': unreferenced function with internal linkage has been removed
69+
endif()
6670
endif()
6771
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
6872
# Q_UNUSED() in generated code

0 commit comments

Comments
 (0)