Skip to content

Fixes 50 Compiler Warnings: Add SYSTEM toCMakeLists.txt#10653

Merged
SoftFever merged 5 commits intoOrcaSlicer:mainfrom
rubienr:add-SYSTEM-to-target_include_directories
Sep 19, 2025
Merged

Fixes 50 Compiler Warnings: Add SYSTEM toCMakeLists.txt#10653
SoftFever merged 5 commits intoOrcaSlicer:mainfrom
rubienr:add-SYSTEM-to-target_include_directories

Conversation

@rubienr
Copy link
Copy Markdown
Contributor

@rubienr rubienr commented Sep 7, 2025

Description

This PR:

  • fixes Reduce Compiler Warnings #10652
  • adds SYSTEM to target_include_directories() in cmake files to reduce compiler warnings of 3rd party source that we cannot influence
  • suppresses 49 3rd party compiler warnings
  • fixes 1 compiler warning

Example:

target_include_directories(libslic3r
    PUBLIC
        ${OpenCASCADE_INCLUDE_DIR}
)

vs.

target_include_directories(libslic3r SYSTEM
    PUBLIC
        ${OpenCASCADE_INCLUDE_DIR}
)

Screenshots/Recordings/Graphs

Warnings as of main vs. PR: 172:122

git co main
./build_linux.sh -spcC | tee warnings-main.txt
grep "\[\-W"  warnings-main.txt | wc -l
172
git co add-SYSTEM-to-target_include_directories
./build_linux.sh -spcC | tee warnings-with-system.txt
grep "\[\-W"  warnings-with-system.txt | wc -l
122

Warning distribution of main vs. PR

grep -E "\[\-W.*\]"  warnings-main.txt -o | sort | uniq -c    
      1 [-Waddress]
      7 [-Warray-bounds=]
      2 [-Wcatch-value=]
      5 [-Wclass-memaccess]
      9 [-Wcomment]
      1 [-Wconversion-null]
      7 [-Wdangling-pointer=]
      2 [-Wdangling-reference]
     63 [-Wdeprecated-declarations]
      1 [-Wendif-labels]
      2 [-Wformat-overflow=]
      1 [-Winit-self]
     45 [-Wmaybe-uninitialized]
      2 [-Wodr]
      3 [-Woverloaded-virtual=]
      2 [-Wparentheses]
      1 [-Wpessimizing-move]
      1 [-Wself-move]
      2 [-Wsequence-point]
      5 [-Wstringop-overflow=]
      1 [-Wstringop-truncation]
      5 [-Wuninitialized]
      3 [-Wuse-after-free]
      1 [-Wvarargs]

vs.

grep -E "\[\-W.*\]"  warnings-with-system.txt -o | sort | uniq -c
      1 [-Waddress]
      7 [-Warray-bounds=]
      2 [-Wcatch-value=]
      4 [-Wclass-memaccess]           <--- -1
      9 [-Wcomment]
      1 [-Wconversion-null]
      7 [-Wdangling-pointer=]
      2 [-Wdangling-reference]
     14 [-Wdeprecated-declarations]   <--- -49
      1 [-Wendif-labels]
      2 [-Wformat-overflow=]
      1 [-Winit-self]
     45 [-Wmaybe-uninitialized]
      2 [-Wodr]
      3 [-Woverloaded-virtual=]
      2 [-Wparentheses]
      1 [-Wpessimizing-move]
      1 [-Wself-move]
      2 [-Wsequence-point]
      5 [-Wstringop-overflow=]
      1 [-Wstringop-truncation]
      5 [-Wuninitialized]
      3 [-Wuse-after-free]
      1 [-Wvarargs]

Manually Tested

  1. compiled from scratch
  2. started OrcaSlicer
  3. imported a simple .3mf file
  4. sliced
  5. did not crash :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ugly diff is a result of tr + sort + uniq of the lisbslic3r_sources listing. i.e. echo "..." | tr -d '[:blank:]' | sort | uniq

Comment thread src/slic3r/CMakeLists.txt
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ugly diff is a result of tr + sort + uniq of the SLIC3R_GUI_SOURCES listing. i.e. echo "..." | tr -d '[:blank:]' | sort | uniq

@rubienr rubienr force-pushed the add-SYSTEM-to-target_include_directories branch 2 times, most recently from ccd97eb to 4a497f2 Compare September 9, 2025 18:30
@rubienr rubienr changed the title Add SYSTEM to target_include_directories() im CMakeLists.txt Fixes 50 Compiler Warnings: Add SYSTEM toCMakeLists.txt Sep 9, 2025
@rubienr rubienr force-pushed the add-SYSTEM-to-target_include_directories branch 2 times, most recently from 08496d2 to 2ce9022 Compare September 12, 2025 18:54
@rubienr rubienr mentioned this pull request Sep 13, 2025
1 task
@rubienr rubienr force-pushed the add-SYSTEM-to-target_include_directories branch from 2ce9022 to ced49dc Compare September 14, 2025 17:17
@SoftFever SoftFever requested a review from Copilot September 16, 2025 14:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR suppresses 49 third-party compiler warnings by adding the SYSTEM keyword to target_include_directories() calls in CMake files. It also fixes 1 actual compiler warning by removing an incorrect #pragma once directive from a .cpp file.

  • Adds SYSTEM keyword to numerous CMake files to treat third-party headers as system headers
  • Removes #pragma once from a source file where it doesn't belong
  • Reorganizes source file listings in CMakeLists.txt files alphabetically

Reviewed Changes

Copilot reviewed 26 out of 28 changed files in this pull request and generated no comments.

File Description
src/slic3r/GUI/Widgets/ScrolledWindow.cpp Removes incorrect #pragma once from source file
src/slic3r/CMakeLists.txt Adds SYSTEM to third-party includes and reorganizes source list
src/libslic3r/CMakeLists.txt Adds SYSTEM to OpenCASCADE includes and reorganizes source list
deps_src/*/CMakeLists.txt Adds SYSTEM keyword to all third-party dependency include directories
Comments suppressed due to low confidence (1)

src/slic3r/GUI/Widgets/ScrolledWindow.cpp:1

  • The #pragma once directive should not be used in source files (.cpp). It is only appropriate for header files (.hpp/.h) to prevent multiple inclusions during compilation.
// for scroll

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@rubienr rubienr force-pushed the add-SYSTEM-to-target_include_directories branch from ced49dc to 1d62bd6 Compare September 16, 2025 20:31
Copy link
Copy Markdown
Collaborator

@SoftFever SoftFever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
Very nice fixes 👍

@SoftFever SoftFever merged commit 75ed995 into OrcaSlicer:main Sep 19, 2025
12 checks passed
@rubienr
Copy link
Copy Markdown
Contributor Author

rubienr commented Sep 19, 2025

Thank you @SoftFever 😀
I suspect that a few libs in deps_src/ don't require SYSTEM. I have that on the radar screen and will approach that once i have no more progress in fixing warnings in src/.

@rubienr rubienr deleted the add-SYSTEM-to-target_include_directories branch September 19, 2025 17:19
dbaarda pushed a commit to dbaarda/OrcaSlicer that referenced this pull request Sep 21, 2025
* main:
  Shellcheck everything (OrcaSlicer#10730)
  Update Anycubic Kobra 2 Neo machine profile fine tune end gcode (OrcaSlicer#10742)
  Update TURKISH translations (V2.3.1-beta) (OrcaSlicer#10726)
  Fixes 999 CMake Warnings (OrcaSlicer#10729)
  Fixes 50 Compiler Warnings: Add SYSTEM toCMakeLists.txt (OrcaSlicer#10653)
  Fix variable name comment and message (OrcaSlicer#10302)
  Reflect swapped mouse buttons in Help → Keyboard Shortcuts (OrcaSlicer#10647)
  [Profile]parameters modified in printer file (OrcaSlicer#10394)
dbaarda pushed a commit to dbaarda/OrcaSlicer that referenced this pull request Sep 21, 2025
* opt-marchsq:
  Shellcheck everything (OrcaSlicer#10730)
  Update Anycubic Kobra 2 Neo machine profile fine tune end gcode (OrcaSlicer#10742)
  Update TURKISH translations (V2.3.1-beta) (OrcaSlicer#10726)
  Fixes 999 CMake Warnings (OrcaSlicer#10729)
  Fixes 50 Compiler Warnings: Add SYSTEM toCMakeLists.txt (OrcaSlicer#10653)
  Fix variable name comment and message (OrcaSlicer#10302)
  Reflect swapped mouse buttons in Help → Keyboard Shortcuts (OrcaSlicer#10647)
  [Profile]parameters modified in printer file (OrcaSlicer#10394)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce Compiler Warnings

3 participants