From 4bc92384b7bbe28141b588cb79631f990685ad65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Reitb=C3=B6ck?= Date: Sun, 21 Sep 2025 16:10:44 +0200 Subject: [PATCH] Inspection: use CMake to generate precompiled headers on all platforms "Professional CMake" book suggest the following: "Targets should build successfully with or without compiler support for precompiled headers. It should be considered an optimization, not a requirement. In particular, do not explicitly include a precompile header (e.g. stdafx.h) in the source code, let CMake force-include an automatically generated precompile header on the compiler command line instead. This is more portable across the major compilers and is likely to be easier to maintain. It will also avoid warnings being generated from certain code checking tools like iwyu (include what you use)." Therefore, removed the "#include " from sources, also there is no need for the "#ifdef _PreComp_" anymore --- src/Mod/Inspection/App/AppInspection.cpp | 1 - src/Mod/Inspection/App/CMakeLists.txt | 10 ++++---- src/Mod/Inspection/App/InspectionFeature.cpp | 4 ---- src/Mod/Inspection/App/PreCompiled.cpp | 23 ------------------- src/Mod/Inspection/App/PreCompiled.h | 4 ---- src/Mod/Inspection/Gui/AppInspectionGui.cpp | 1 - src/Mod/Inspection/Gui/CMakeLists.txt | 13 +++++------ src/Mod/Inspection/Gui/Command.cpp | 4 +--- src/Mod/Inspection/Gui/PreCompiled.cpp | 23 ------------------- src/Mod/Inspection/Gui/PreCompiled.h | 4 ---- .../Inspection/Gui/ViewProviderInspection.cpp | 3 --- src/Mod/Inspection/Gui/VisualInspection.cpp | 3 --- src/Mod/Inspection/Gui/Workbench.cpp | 1 - 13 files changed, 12 insertions(+), 82 deletions(-) delete mode 100644 src/Mod/Inspection/App/PreCompiled.cpp delete mode 100644 src/Mod/Inspection/Gui/PreCompiled.cpp diff --git a/src/Mod/Inspection/App/AppInspection.cpp b/src/Mod/Inspection/App/AppInspection.cpp index 13ed115ee6..1e0eb5e04b 100644 --- a/src/Mod/Inspection/App/AppInspection.cpp +++ b/src/Mod/Inspection/App/AppInspection.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Inspection/App/CMakeLists.txt b/src/Mod/Inspection/App/CMakeLists.txt index 5712ccf32f..c4992428b0 100644 --- a/src/Mod/Inspection/App/CMakeLists.txt +++ b/src/Mod/Inspection/App/CMakeLists.txt @@ -9,7 +9,6 @@ SET(Inspection_SRCS AppInspection.cpp InspectionFeature.cpp InspectionFeature.h - PreCompiled.cpp PreCompiled.h ) @@ -17,13 +16,14 @@ set(Inspection_Scripts ../Init.py ) +add_library(Inspection SHARED ${Inspection_SRCS} ${Inspection_Scripts}) + if(FREECAD_USE_PCH) - add_definitions(-D_PreComp_) - GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Inspection_SRCS}) - ADD_MSVC_PRECOMPILED_HEADER(Inspection PreCompiled.h PreCompiled.cpp PCH_SRCS) + target_precompile_headers(Inspection PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) endif(FREECAD_USE_PCH) -add_library(Inspection SHARED ${Inspection_SRCS} ${Inspection_Scripts}) target_include_directories( Inspection PRIVATE diff --git a/src/Mod/Inspection/App/InspectionFeature.cpp b/src/Mod/Inspection/App/InspectionFeature.cpp index c6b5594eb8..688cdce1a5 100644 --- a/src/Mod/Inspection/App/InspectionFeature.cpp +++ b/src/Mod/Inspection/App/InspectionFeature.cpp @@ -20,9 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" - -#ifndef _PreComp_ #include #include #include @@ -39,7 +36,6 @@ #include #include #include -#endif #include #include diff --git a/src/Mod/Inspection/App/PreCompiled.cpp b/src/Mod/Inspection/App/PreCompiled.cpp deleted file mode 100644 index 2ac4ea20cd..0000000000 --- a/src/Mod/Inspection/App/PreCompiled.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2011 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" diff --git a/src/Mod/Inspection/App/PreCompiled.h b/src/Mod/Inspection/App/PreCompiled.h index 447cd24797..329650e51c 100644 --- a/src/Mod/Inspection/App/PreCompiled.h +++ b/src/Mod/Inspection/App/PreCompiled.h @@ -25,8 +25,6 @@ #include -#ifdef _PreComp_ - // STL #include @@ -48,6 +46,4 @@ #include #include -#endif //_PreComp_ - #endif diff --git a/src/Mod/Inspection/Gui/AppInspectionGui.cpp b/src/Mod/Inspection/Gui/AppInspectionGui.cpp index a1bda821b0..714bb336d2 100644 --- a/src/Mod/Inspection/Gui/AppInspectionGui.cpp +++ b/src/Mod/Inspection/Gui/AppInspectionGui.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Inspection/Gui/CMakeLists.txt b/src/Mod/Inspection/Gui/CMakeLists.txt index d0adb9a68c..f8a1eeb420 100644 --- a/src/Mod/Inspection/Gui/CMakeLists.txt +++ b/src/Mod/Inspection/Gui/CMakeLists.txt @@ -21,7 +21,6 @@ SET(InspectionGui_SRCS ${Dialogs_SRCS} AppInspectionGui.cpp Command.cpp - PreCompiled.cpp PreCompiled.h ViewProviderInspection.cpp ViewProviderInspection.h @@ -33,12 +32,6 @@ set(InspectionGui_Scripts ../InitGui.py ) -if(FREECAD_USE_PCH) - add_definitions(-D_PreComp_) - GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${InspectionGui_SRCS}) - ADD_MSVC_PRECOMPILED_HEADER(InspectionGui PreCompiled.h PreCompiled.cpp PCH_SRCS) -endif(FREECAD_USE_PCH) - SET(InspectionGuiIcon_SVG Resources/icons/InspectionWorkbench.svg ) @@ -49,6 +42,12 @@ add_library(InspectionGui SHARED ${InspectionGuiIcon_SVG} ) +if(FREECAD_USE_PCH) + target_precompile_headers(InspectionGui PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) +endif(FREECAD_USE_PCH) + target_include_directories( InspectionGui PRIVATE diff --git a/src/Mod/Inspection/Gui/Command.cpp b/src/Mod/Inspection/Gui/Command.cpp index 29ab5bec00..14f7c7fd53 100644 --- a/src/Mod/Inspection/Gui/Command.cpp +++ b/src/Mod/Inspection/Gui/Command.cpp @@ -20,10 +20,8 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include -#endif + #include #include diff --git a/src/Mod/Inspection/Gui/PreCompiled.cpp b/src/Mod/Inspection/Gui/PreCompiled.cpp deleted file mode 100644 index 2ac4ea20cd..0000000000 --- a/src/Mod/Inspection/Gui/PreCompiled.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2011 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" diff --git a/src/Mod/Inspection/Gui/PreCompiled.h b/src/Mod/Inspection/Gui/PreCompiled.h index 74816df791..fda61dfe10 100644 --- a/src/Mod/Inspection/Gui/PreCompiled.h +++ b/src/Mod/Inspection/Gui/PreCompiled.h @@ -26,8 +26,6 @@ #include -#ifdef _PreComp_ - // STL // Inventor @@ -54,6 +52,4 @@ #include #include -#endif //_PreComp_ - #endif // GUI_PRECOMPILED_H diff --git a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp index cd0728be80..d720bff784 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp @@ -20,9 +20,7 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -44,7 +42,6 @@ #include #include #include -#endif #include #include diff --git a/src/Mod/Inspection/Gui/VisualInspection.cpp b/src/Mod/Inspection/Gui/VisualInspection.cpp index 5be5012921..8d55cdc6ca 100644 --- a/src/Mod/Inspection/Gui/VisualInspection.cpp +++ b/src/Mod/Inspection/Gui/VisualInspection.cpp @@ -20,10 +20,7 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include -#endif #include #include diff --git a/src/Mod/Inspection/Gui/Workbench.cpp b/src/Mod/Inspection/Gui/Workbench.cpp index c2a02150d0..001438333d 100644 --- a/src/Mod/Inspection/Gui/Workbench.cpp +++ b/src/Mod/Inspection/Gui/Workbench.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include "Workbench.h"