From cfe0d9ffacf9f0551bf5594e4e105cef00bb2a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Reitb=C3=B6ck?= Date: Sun, 21 Sep 2025 16:39:50 +0200 Subject: [PATCH] Surface: 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/Surface/App/AppSurface.cpp | 1 - src/Mod/Surface/App/Blending/BlendCurve.cpp | 4 +--- .../Surface/App/Blending/BlendCurvePyImp.cpp | 1 - src/Mod/Surface/App/Blending/BlendPoint.cpp | 4 +--- .../Surface/App/Blending/BlendPointPyImp.cpp | 4 +--- .../App/Blending/FeatureBlendCurve.cpp | 4 +--- src/Mod/Surface/App/CMakeLists.txt | 10 ++++---- src/Mod/Surface/App/FeatureCut.cpp | 4 +--- src/Mod/Surface/App/FeatureExtend.cpp | 6 ++--- src/Mod/Surface/App/FeatureFilling.cpp | 3 --- .../Surface/App/FeatureGeomFillSurface.cpp | 4 +--- src/Mod/Surface/App/FeatureSections.cpp | 4 +--- src/Mod/Surface/App/FeatureSewing.cpp | 4 +--- src/Mod/Surface/App/PreCompiled.cpp | 23 ------------------- src/Mod/Surface/App/PreCompiled.h | 4 ---- src/Mod/Surface/Gui/AppSurfaceGui.cpp | 1 - .../Surface/Gui/Blending/TaskBlendCurve.cpp | 3 --- .../Gui/Blending/ViewProviderBlendCurve.cpp | 3 --- src/Mod/Surface/Gui/CMakeLists.txt | 13 +++++------ src/Mod/Surface/Gui/Command.cpp | 3 --- src/Mod/Surface/Gui/PreCompiled.cpp | 23 ------------------- src/Mod/Surface/Gui/PreCompiled.h | 4 ---- src/Mod/Surface/Gui/TaskFilling.cpp | 3 --- src/Mod/Surface/Gui/TaskFillingEdge.cpp | 3 --- src/Mod/Surface/Gui/TaskFillingVertex.cpp | 4 +--- src/Mod/Surface/Gui/TaskGeomFillSurface.cpp | 4 +--- src/Mod/Surface/Gui/TaskSections.cpp | 3 --- src/Mod/Surface/Gui/ViewProviderExtend.cpp | 1 - src/Mod/Surface/Gui/Workbench.cpp | 1 - 29 files changed, 23 insertions(+), 126 deletions(-) delete mode 100644 src/Mod/Surface/App/PreCompiled.cpp delete mode 100644 src/Mod/Surface/Gui/PreCompiled.cpp diff --git a/src/Mod/Surface/App/AppSurface.cpp b/src/Mod/Surface/App/AppSurface.cpp index 171aff3791..8a6ebe824b 100644 --- a/src/Mod/Surface/App/AppSurface.cpp +++ b/src/Mod/Surface/App/AppSurface.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Surface/App/Blending/BlendCurve.cpp b/src/Mod/Surface/App/Blending/BlendCurve.cpp index fb32c88652..47c6adc04a 100644 --- a/src/Mod/Surface/App/Blending/BlendCurve.cpp +++ b/src/Mod/Surface/App/Blending/BlendCurve.cpp @@ -21,8 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -31,7 +29,7 @@ #include #include #include -#endif + #include "Blending/BlendCurve.h" #include "Blending/BlendCurvePy.h" #include diff --git a/src/Mod/Surface/App/Blending/BlendCurvePyImp.cpp b/src/Mod/Surface/App/Blending/BlendCurvePyImp.cpp index a5dfb9eeeb..43b83684e6 100644 --- a/src/Mod/Surface/App/Blending/BlendCurvePyImp.cpp +++ b/src/Mod/Surface/App/Blending/BlendCurvePyImp.cpp @@ -20,7 +20,6 @@ // * * // ***************************************************************************/ -#include "PreCompiled.h" // clang-format off #include "Blending/BlendCurvePy.h" diff --git a/src/Mod/Surface/App/Blending/BlendPoint.cpp b/src/Mod/Surface/App/Blending/BlendPoint.cpp index 8e6f24d99f..4be72afc77 100644 --- a/src/Mod/Surface/App/Blending/BlendPoint.cpp +++ b/src/Mod/Surface/App/Blending/BlendPoint.cpp @@ -21,11 +21,9 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include -#endif + #include "Blending/BlendPoint.h" #include "Blending/BlendPointPy.h" diff --git a/src/Mod/Surface/App/Blending/BlendPointPyImp.cpp b/src/Mod/Surface/App/Blending/BlendPointPyImp.cpp index 6ffc238a9b..d1709ad90c 100644 --- a/src/Mod/Surface/App/Blending/BlendPointPyImp.cpp +++ b/src/Mod/Surface/App/Blending/BlendPointPyImp.cpp @@ -20,11 +20,9 @@ // * * // ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include -#endif + // clang-format off #include "Blending/BlendPoint.h" diff --git a/src/Mod/Surface/App/Blending/FeatureBlendCurve.cpp b/src/Mod/Surface/App/Blending/FeatureBlendCurve.cpp index b7542c037b..7f9596be57 100644 --- a/src/Mod/Surface/App/Blending/FeatureBlendCurve.cpp +++ b/src/Mod/Surface/App/Blending/FeatureBlendCurve.cpp @@ -21,14 +21,12 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include #include #include -#endif + #include "Mod/Surface/App/Blending/BlendCurve.h" #include "Mod/Surface/App/Blending/BlendPoint.h" diff --git a/src/Mod/Surface/App/CMakeLists.txt b/src/Mod/Surface/App/CMakeLists.txt index 32c0926d65..cb2ed678a4 100644 --- a/src/Mod/Surface/App/CMakeLists.txt +++ b/src/Mod/Surface/App/CMakeLists.txt @@ -30,7 +30,6 @@ SET(Surface_SRCS ${Blending_SRCS} ${BlendingPy_SRCS} AppSurface.cpp - PreCompiled.cpp PreCompiled.h FeatureExtend.cpp FeatureExtend.h @@ -46,13 +45,14 @@ SET(Surface_SRCS FeatureCut.h ) +add_library(Surface SHARED ${Surface_SRCS}) + if(FREECAD_USE_PCH) - add_definitions(-D_PreComp_) - GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Surface_SRCS}) - ADD_MSVC_PRECOMPILED_HEADER(Surface PreCompiled.h PreCompiled.cpp PCH_SRCS) + target_precompile_headers(Surface PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) endif(FREECAD_USE_PCH) -add_library(Surface SHARED ${Surface_SRCS}) target_include_directories( Surface PRIVATE diff --git a/src/Mod/Surface/App/FeatureCut.cpp b/src/Mod/Surface/App/FeatureCut.cpp index e39a0cadce..fb1c79e9d7 100644 --- a/src/Mod/Surface/App/FeatureCut.cpp +++ b/src/Mod/Surface/App/FeatureCut.cpp @@ -20,10 +20,8 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include -#endif + #include "FeatureCut.h" diff --git a/src/Mod/Surface/App/FeatureExtend.cpp b/src/Mod/Surface/App/FeatureExtend.cpp index 24c83fcc34..4fcac1f881 100644 --- a/src/Mod/Surface/App/FeatureExtend.cpp +++ b/src/Mod/Surface/App/FeatureExtend.cpp @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ +#include + #include #include #include @@ -33,8 +33,6 @@ #include #include #include -#include -#endif #include diff --git a/src/Mod/Surface/App/FeatureFilling.cpp b/src/Mod/Surface/App/FeatureFilling.cpp index 0462603745..ce9ffa920e 100644 --- a/src/Mod/Surface/App/FeatureFilling.cpp +++ b/src/Mod/Surface/App/FeatureFilling.cpp @@ -20,8 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include @@ -30,7 +28,6 @@ #include #include #include -#endif #include "FeatureFilling.h" diff --git a/src/Mod/Surface/App/FeatureGeomFillSurface.cpp b/src/Mod/Surface/App/FeatureGeomFillSurface.cpp index 8eec4968d0..1f2a907442 100644 --- a/src/Mod/Surface/App/FeatureGeomFillSurface.cpp +++ b/src/Mod/Surface/App/FeatureGeomFillSurface.cpp @@ -21,9 +21,7 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -47,7 +45,7 @@ #include #include #include -#endif + #include "FeatureGeomFillSurface.h" diff --git a/src/Mod/Surface/App/FeatureSections.cpp b/src/Mod/Surface/App/FeatureSections.cpp index cd18b80eb8..36a5b652fa 100644 --- a/src/Mod/Surface/App/FeatureSections.cpp +++ b/src/Mod/Surface/App/FeatureSections.cpp @@ -20,8 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -31,7 +29,7 @@ #include #include #include -#endif + #include "FeatureSections.h" diff --git a/src/Mod/Surface/App/FeatureSewing.cpp b/src/Mod/Surface/App/FeatureSewing.cpp index 2c821b9fb3..061d942995 100644 --- a/src/Mod/Surface/App/FeatureSewing.cpp +++ b/src/Mod/Surface/App/FeatureSewing.cpp @@ -20,12 +20,10 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include -#endif + #include "FeatureSewing.h" diff --git a/src/Mod/Surface/App/PreCompiled.cpp b/src/Mod/Surface/App/PreCompiled.cpp deleted file mode 100644 index a6ded796a3..0000000000 --- a/src/Mod/Surface/App/PreCompiled.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2014 Nathan Miller * - * * - * 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/Surface/App/PreCompiled.h b/src/Mod/Surface/App/PreCompiled.h index 0d80e1fe47..24224bf263 100644 --- a/src/Mod/Surface/App/PreCompiled.h +++ b/src/Mod/Surface/App/PreCompiled.h @@ -25,14 +25,10 @@ #include -#ifdef _PreComp_ - // STL #include // opencascade #include -#endif //_PreComp_ - #endif diff --git a/src/Mod/Surface/Gui/AppSurfaceGui.cpp b/src/Mod/Surface/Gui/AppSurfaceGui.cpp index 71f5155740..4a83802a1a 100644 --- a/src/Mod/Surface/Gui/AppSurfaceGui.cpp +++ b/src/Mod/Surface/Gui/AppSurfaceGui.cpp @@ -21,7 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Surface/Gui/Blending/TaskBlendCurve.cpp b/src/Mod/Surface/Gui/Blending/TaskBlendCurve.cpp index 474802b3ce..d89787e9e3 100644 --- a/src/Mod/Surface/Gui/Blending/TaskBlendCurve.cpp +++ b/src/Mod/Surface/Gui/Blending/TaskBlendCurve.cpp @@ -19,13 +19,10 @@ * * **************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include #include -#endif #include #include diff --git a/src/Mod/Surface/Gui/Blending/ViewProviderBlendCurve.cpp b/src/Mod/Surface/Gui/Blending/ViewProviderBlendCurve.cpp index 51bf3c159d..6f9c66bcd1 100644 --- a/src/Mod/Surface/Gui/Blending/ViewProviderBlendCurve.cpp +++ b/src/Mod/Surface/Gui/Blending/ViewProviderBlendCurve.cpp @@ -20,10 +20,7 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include -#endif #include "ViewProviderBlendCurve.h" #include "TaskBlendCurve.h" diff --git a/src/Mod/Surface/Gui/CMakeLists.txt b/src/Mod/Surface/Gui/CMakeLists.txt index c2263358fc..515a304575 100644 --- a/src/Mod/Surface/Gui/CMakeLists.txt +++ b/src/Mod/Surface/Gui/CMakeLists.txt @@ -38,7 +38,6 @@ SET(SurfaceGui_SRCS TaskSections.h AppSurfaceGui.cpp Command.cpp - PreCompiled.cpp PreCompiled.h ViewProviderExtend.cpp ViewProviderExtend.h @@ -52,17 +51,17 @@ SET(SurfaceGuiIcon_SVG Resources/icons/Surface_Workbench.svg ) -if(FREECAD_USE_PCH) - add_definitions(-D_PreComp_) - GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${SurfaceGui_SRCS}) - ADD_MSVC_PRECOMPILED_HEADER(SurfaceGui PreCompiled.h PreCompiled.cpp PCH_SRCS) -endif(FREECAD_USE_PCH) - add_library(SurfaceGui SHARED ${SurfaceGui_SRCS} ${SurfaceGuiIcon_SVG} ) +if(FREECAD_USE_PCH) + target_precompile_headers(SurfaceGui PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) +endif(FREECAD_USE_PCH) + target_include_directories( SurfaceGui PRIVATE diff --git a/src/Mod/Surface/Gui/Command.cpp b/src/Mod/Surface/Gui/Command.cpp index 8c9422155e..3ff5139e74 100644 --- a/src/Mod/Surface/Gui/Command.cpp +++ b/src/Mod/Surface/Gui/Command.cpp @@ -21,8 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -31,7 +29,6 @@ #include #include #include -#endif #include "Mod/Part/App/PartFeature.h" #include diff --git a/src/Mod/Surface/Gui/PreCompiled.cpp b/src/Mod/Surface/Gui/PreCompiled.cpp deleted file mode 100644 index a6ded796a3..0000000000 --- a/src/Mod/Surface/Gui/PreCompiled.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2014 Nathan Miller * - * * - * 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/Surface/Gui/PreCompiled.h b/src/Mod/Surface/Gui/PreCompiled.h index e29d145fdc..f0b43e2bec 100644 --- a/src/Mod/Surface/Gui/PreCompiled.h +++ b/src/Mod/Surface/Gui/PreCompiled.h @@ -25,8 +25,6 @@ #include -#ifdef _PreComp_ - // STL #include @@ -48,6 +46,4 @@ #include #include -#endif //_PreComp_ - #endif // GUI_PRECOMPILED_H diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index 56dd99970b..94aa2437d6 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -20,8 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -32,7 +30,6 @@ #include #include #include -#endif #include #include diff --git a/src/Mod/Surface/Gui/TaskFillingEdge.cpp b/src/Mod/Surface/Gui/TaskFillingEdge.cpp index 6030eaca47..06232670e4 100644 --- a/src/Mod/Surface/Gui/TaskFillingEdge.cpp +++ b/src/Mod/Surface/Gui/TaskFillingEdge.cpp @@ -21,8 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -32,7 +30,6 @@ #include #include #include -#endif #include #include diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.cpp b/src/Mod/Surface/Gui/TaskFillingVertex.cpp index c684cc7dd4..c7fe86a465 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.cpp +++ b/src/Mod/Surface/Gui/TaskFillingVertex.cpp @@ -20,11 +20,9 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include -#endif + #include #include diff --git a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp index 8a204a05ef..ccbb74a30d 100644 --- a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp +++ b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp @@ -21,15 +21,13 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include #include #include #include -#endif + #include #include diff --git a/src/Mod/Surface/Gui/TaskSections.cpp b/src/Mod/Surface/Gui/TaskSections.cpp index 7cbee3c0a8..3ef26c3af5 100644 --- a/src/Mod/Surface/Gui/TaskSections.cpp +++ b/src/Mod/Surface/Gui/TaskSections.cpp @@ -20,8 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -29,7 +27,6 @@ #include #include -#endif #include #include diff --git a/src/Mod/Surface/Gui/ViewProviderExtend.cpp b/src/Mod/Surface/Gui/ViewProviderExtend.cpp index 6a5ef3b175..1449d2f60c 100644 --- a/src/Mod/Surface/Gui/ViewProviderExtend.cpp +++ b/src/Mod/Surface/Gui/ViewProviderExtend.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include diff --git a/src/Mod/Surface/Gui/Workbench.cpp b/src/Mod/Surface/Gui/Workbench.cpp index 946efddce1..02e32248c3 100644 --- a/src/Mod/Surface/Gui/Workbench.cpp +++ b/src/Mod/Surface/Gui/Workbench.cpp @@ -21,7 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include