From 015896f4e4b6d205a40bdfa3385fdf3d48b09b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Reitb=C3=B6ck?= Date: Sun, 21 Sep 2025 16:54:06 +0200 Subject: [PATCH] MeshPart: 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/MeshPart/App/AppMeshPart.cpp | 1 - src/Mod/MeshPart/App/AppMeshPartPy.cpp | 4 +--- src/Mod/MeshPart/App/CMakeLists.txt | 7 +++--- src/Mod/MeshPart/App/CurveProjector.cpp | 6 ++--- src/Mod/MeshPart/App/MeshAlgos.cpp | 5 ++-- src/Mod/MeshPart/App/MeshFlattening.cpp | 3 --- .../MeshPart/App/MeshFlatteningLscmRelax.cpp | 4 +--- src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp | 4 +--- src/Mod/MeshPart/App/MeshFlatteningPy.cpp | 3 --- src/Mod/MeshPart/App/Mesher.cpp | 3 --- src/Mod/MeshPart/App/PreCompiled.cpp | 23 ------------------- src/Mod/MeshPart/App/PreCompiled.h | 3 --- src/Mod/MeshPart/Gui/AppMeshPartGui.cpp | 1 - src/Mod/MeshPart/Gui/CMakeLists.txt | 10 ++++---- src/Mod/MeshPart/Gui/Command.cpp | 4 +--- src/Mod/MeshPart/Gui/CrossSections.cpp | 3 --- src/Mod/MeshPart/Gui/CurveOnMesh.cpp | 3 --- src/Mod/MeshPart/Gui/PreCompiled.cpp | 23 ------------------- src/Mod/MeshPart/Gui/PreCompiled.h | 4 ---- src/Mod/MeshPart/Gui/TaskCurveOnMesh.cpp | 1 - src/Mod/MeshPart/Gui/Tessellation.cpp | 4 +--- src/Mod/MeshPart/Gui/Workbench.cpp | 4 +--- 22 files changed, 19 insertions(+), 104 deletions(-) delete mode 100644 src/Mod/MeshPart/App/PreCompiled.cpp delete mode 100644 src/Mod/MeshPart/Gui/PreCompiled.cpp diff --git a/src/Mod/MeshPart/App/AppMeshPart.cpp b/src/Mod/MeshPart/App/AppMeshPart.cpp index 147d7d6257..3eed116924 100644 --- a/src/Mod/MeshPart/App/AppMeshPart.cpp +++ b/src/Mod/MeshPart/App/AppMeshPart.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/MeshPart/App/AppMeshPartPy.cpp b/src/Mod/MeshPart/App/AppMeshPartPy.cpp index 56a0bf897d..718df0ba13 100644 --- a/src/Mod/MeshPart/App/AppMeshPartPy.cpp +++ b/src/Mod/MeshPart/App/AppMeshPartPy.cpp @@ -20,11 +20,9 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include -#endif + #include #include diff --git a/src/Mod/MeshPart/App/CMakeLists.txt b/src/Mod/MeshPart/App/CMakeLists.txt index 881c184f15..920424fc77 100644 --- a/src/Mod/MeshPart/App/CMakeLists.txt +++ b/src/Mod/MeshPart/App/CMakeLists.txt @@ -60,7 +60,6 @@ SET(MeshPart_SRCS MeshAlgos.h Mesher.cpp Mesher.h - PreCompiled.cpp PreCompiled.h ) @@ -69,9 +68,9 @@ set(MeshPart_Scripts ) if(FREECAD_USE_PCH) - add_definitions(-D_PreComp_) - GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${MeshPart_SRCS}) - ADD_MSVC_PRECOMPILED_HEADER(MeshPart PreCompiled.h PreCompiled.cpp PCH_SRCS) + target_precompile_headers(MeshPart PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) endif(FREECAD_USE_PCH) # Suppress -Wundefined-var-template diff --git a/src/Mod/MeshPart/App/CurveProjector.cpp b/src/Mod/MeshPart/App/CurveProjector.cpp index 62c6acae4c..4bb476690b 100644 --- a/src/Mod/MeshPart/App/CurveProjector.cpp +++ b/src/Mod/MeshPart/App/CurveProjector.cpp @@ -20,9 +20,10 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include + +#include + #ifdef FC_OS_LINUX #include #endif @@ -43,7 +44,6 @@ #include #include #include -#endif #include #include diff --git a/src/Mod/MeshPart/App/MeshAlgos.cpp b/src/Mod/MeshPart/App/MeshAlgos.cpp index 573402bfb1..bb52be4a88 100644 --- a/src/Mod/MeshPart/App/MeshAlgos.cpp +++ b/src/Mod/MeshPart/App/MeshAlgos.cpp @@ -20,12 +20,11 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ +#include + #ifdef FC_OS_LINUX #include #endif -#endif #include #include diff --git a/src/Mod/MeshPart/App/MeshFlattening.cpp b/src/Mod/MeshPart/App/MeshFlattening.cpp index 14f0888a01..d6d2bafe08 100644 --- a/src/Mod/MeshPart/App/MeshFlattening.cpp +++ b/src/Mod/MeshPart/App/MeshFlattening.cpp @@ -20,8 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -33,7 +31,6 @@ #include #include #include -#endif #include "MeshFlattening.h" #include "MeshFlatteningLscmRelax.h" diff --git a/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.cpp b/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.cpp index 4c73f3f651..5ed70956e4 100644 --- a/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.cpp +++ b/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.cpp @@ -20,8 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -29,7 +27,7 @@ #include #include #include -#endif + #include diff --git a/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp b/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp index da252cb943..588d9ebf9d 100644 --- a/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp +++ b/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp @@ -20,11 +20,9 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include -#endif + #include "MeshFlatteningNurbs.h" diff --git a/src/Mod/MeshPart/App/MeshFlatteningPy.cpp b/src/Mod/MeshPart/App/MeshFlatteningPy.cpp index 700aba7f23..37d38a7144 100644 --- a/src/Mod/MeshPart/App/MeshFlatteningPy.cpp +++ b/src/Mod/MeshPart/App/MeshFlatteningPy.cpp @@ -25,15 +25,12 @@ # define strdup _strdup #endif -#include "PreCompiled.h" -#ifndef _PreComp_ # include # include # include # include # include -#endif // necessary for the feature despite not all are necessary for compilation #include diff --git a/src/Mod/MeshPart/App/Mesher.cpp b/src/Mod/MeshPart/App/Mesher.cpp index eb1603a299..580d286257 100644 --- a/src/Mod/MeshPart/App/Mesher.cpp +++ b/src/Mod/MeshPart/App/Mesher.cpp @@ -20,15 +20,12 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include #include #include -#endif #include #include diff --git a/src/Mod/MeshPart/App/PreCompiled.cpp b/src/Mod/MeshPart/App/PreCompiled.cpp deleted file mode 100644 index cde4369c5b..0000000000 --- a/src/Mod/MeshPart/App/PreCompiled.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Jürgen Riegel * - * * - * 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/MeshPart/App/PreCompiled.h b/src/Mod/MeshPart/App/PreCompiled.h index 0905376a54..64dbeb96c4 100644 --- a/src/Mod/MeshPart/App/PreCompiled.h +++ b/src/Mod/MeshPart/App/PreCompiled.h @@ -25,8 +25,6 @@ #include -#ifdef _PreComp_ - // standard #include #include @@ -72,5 +70,4 @@ #include #include -#endif // _PreComp_ #endif diff --git a/src/Mod/MeshPart/Gui/AppMeshPartGui.cpp b/src/Mod/MeshPart/Gui/AppMeshPartGui.cpp index 6426a56e50..b7183ba179 100644 --- a/src/Mod/MeshPart/Gui/AppMeshPartGui.cpp +++ b/src/Mod/MeshPart/Gui/AppMeshPartGui.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/MeshPart/Gui/CMakeLists.txt b/src/Mod/MeshPart/Gui/CMakeLists.txt index f4032a1b5b..ae66abdb1a 100644 --- a/src/Mod/MeshPart/Gui/CMakeLists.txt +++ b/src/Mod/MeshPart/Gui/CMakeLists.txt @@ -39,7 +39,6 @@ SET(MeshPartGui_SRCS CurveOnMesh.cpp CurveOnMesh.h Resources/MeshPart.qrc - PreCompiled.cpp PreCompiled.h TaskCurveOnMesh.ui TaskCurveOnMesh.cpp @@ -59,13 +58,14 @@ set(FLATMESH_PY_SRCS MeshFlatteningCommand.py ) +add_library(MeshPartGui SHARED ${MeshPartGui_SRCS} ${MeshPartGui_Scripts} ${FLATMESH_PY_SRCS}) + if(FREECAD_USE_PCH) - add_definitions(-D_PreComp_) - GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${MeshPartGui_SRCS}) - ADD_MSVC_PRECOMPILED_HEADER(MeshPartGui PreCompiled.h PreCompiled.cpp PCH_SRCS) + target_precompile_headers(MeshPartGui PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) endif(FREECAD_USE_PCH) -add_library(MeshPartGui SHARED ${MeshPartGui_SRCS} ${MeshPartGui_Scripts} ${FLATMESH_PY_SRCS}) target_include_directories( MeshPartGui PRIVATE diff --git a/src/Mod/MeshPart/Gui/Command.cpp b/src/Mod/MeshPart/Gui/Command.cpp index d8e298ee0d..d65ff92330 100644 --- a/src/Mod/MeshPart/Gui/Command.cpp +++ b/src/Mod/MeshPart/Gui/Command.cpp @@ -20,12 +20,10 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include -#endif + #include #include diff --git a/src/Mod/MeshPart/Gui/CrossSections.cpp b/src/Mod/MeshPart/Gui/CrossSections.cpp index 00df2c45a1..e2643fd457 100644 --- a/src/Mod/MeshPart/Gui/CrossSections.cpp +++ b/src/Mod/MeshPart/Gui/CrossSections.cpp @@ -20,8 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include @@ -40,7 +38,6 @@ #include #include #include -#endif #include #include diff --git a/src/Mod/MeshPart/Gui/CurveOnMesh.cpp b/src/Mod/MeshPart/Gui/CurveOnMesh.cpp index 6e902d8fc5..c4f8a1a21d 100644 --- a/src/Mod/MeshPart/Gui/CurveOnMesh.cpp +++ b/src/Mod/MeshPart/Gui/CurveOnMesh.cpp @@ -20,9 +20,7 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -49,7 +47,6 @@ #include #include #include -#endif #include #include diff --git a/src/Mod/MeshPart/Gui/PreCompiled.cpp b/src/Mod/MeshPart/Gui/PreCompiled.cpp deleted file mode 100644 index cde4369c5b..0000000000 --- a/src/Mod/MeshPart/Gui/PreCompiled.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Jürgen Riegel * - * * - * 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/MeshPart/Gui/PreCompiled.h b/src/Mod/MeshPart/Gui/PreCompiled.h index 5a4b8be6cc..725de73281 100644 --- a/src/Mod/MeshPart/Gui/PreCompiled.h +++ b/src/Mod/MeshPart/Gui/PreCompiled.h @@ -25,8 +25,6 @@ #include -#ifdef _PreComp_ - // STL #include @@ -69,6 +67,4 @@ #include #include -#endif //_PreComp_ - #endif // __PRECOMPILED_GUI__ diff --git a/src/Mod/MeshPart/Gui/TaskCurveOnMesh.cpp b/src/Mod/MeshPart/Gui/TaskCurveOnMesh.cpp index 7f56c69428..f355d66aa0 100644 --- a/src/Mod/MeshPart/Gui/TaskCurveOnMesh.cpp +++ b/src/Mod/MeshPart/Gui/TaskCurveOnMesh.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include diff --git a/src/Mod/MeshPart/Gui/Tessellation.cpp b/src/Mod/MeshPart/Gui/Tessellation.cpp index 92b480351e..5e34210412 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.cpp +++ b/src/Mod/MeshPart/Gui/Tessellation.cpp @@ -20,10 +20,8 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include -#endif + #include #include diff --git a/src/Mod/MeshPart/Gui/Workbench.cpp b/src/Mod/MeshPart/Gui/Workbench.cpp index 837fe73416..0fbff9391a 100644 --- a/src/Mod/MeshPart/Gui/Workbench.cpp +++ b/src/Mod/MeshPart/Gui/Workbench.cpp @@ -20,10 +20,8 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include -#endif + #include