From e46020ada4713ec19cf2a5004acd49f54be2fdb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Reitb=C3=B6ck?= Date: Sun, 21 Sep 2025 15:59:38 +0200 Subject: [PATCH] Assembly: 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/Assembly/App/AppAssembly.cpp | 1 - src/Mod/Assembly/App/AppAssemblyPy.cpp | 1 - src/Mod/Assembly/App/AssemblyLink.cpp | 4 +-- src/Mod/Assembly/App/AssemblyLinkPyImp.cpp | 2 -- src/Mod/Assembly/App/AssemblyObject.cpp | 4 +-- src/Mod/Assembly/App/AssemblyObjectPyImp.cpp | 2 -- src/Mod/Assembly/App/AssemblyUtils.cpp | 4 +-- src/Mod/Assembly/App/BomGroup.cpp | 4 --- src/Mod/Assembly/App/BomGroupPyImp.cpp | 2 -- src/Mod/Assembly/App/BomObject.cpp | 4 +-- src/Mod/Assembly/App/BomObjectPyImp.cpp | 2 -- src/Mod/Assembly/App/CMakeLists.txt | 7 +++--- src/Mod/Assembly/App/JointGroup.cpp | 3 --- src/Mod/Assembly/App/JointGroupPyImp.cpp | 2 -- src/Mod/Assembly/App/PreCompiled.cpp | 25 ------------------- src/Mod/Assembly/App/PreCompiled.h | 3 --- src/Mod/Assembly/App/SimulationGroup.cpp | 3 --- src/Mod/Assembly/App/SimulationGroupPyImp.cpp | 2 -- src/Mod/Assembly/App/ViewGroup.cpp | 3 --- src/Mod/Assembly/App/ViewGroupPyImp.cpp | 2 -- src/Mod/Assembly/Gui/AppAssemblyGui.cpp | 1 - src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp | 1 - src/Mod/Assembly/Gui/CMakeLists.txt | 13 +++++----- src/Mod/Assembly/Gui/PreCompiled.cpp | 25 ------------------- src/Mod/Assembly/Gui/PreCompiled.h | 2 -- src/Mod/Assembly/Gui/TaskAssemblyMessages.cpp | 4 --- src/Mod/Assembly/Gui/ViewProviderAssembly.cpp | 4 +-- .../Assembly/Gui/ViewProviderAssemblyLink.cpp | 4 +-- .../Gui/ViewProviderAssemblyPyImp.cpp | 1 - src/Mod/Assembly/Gui/ViewProviderBom.cpp | 4 +-- src/Mod/Assembly/Gui/ViewProviderBomGroup.cpp | 5 ---- .../Assembly/Gui/ViewProviderJointGroup.cpp | 5 ---- .../Gui/ViewProviderSimulationGroup.cpp | 5 ---- .../Assembly/Gui/ViewProviderViewGroup.cpp | 5 ---- 34 files changed, 16 insertions(+), 143 deletions(-) delete mode 100644 src/Mod/Assembly/App/PreCompiled.cpp delete mode 100644 src/Mod/Assembly/Gui/PreCompiled.cpp diff --git a/src/Mod/Assembly/App/AppAssembly.cpp b/src/Mod/Assembly/App/AppAssembly.cpp index 562221a891..118e18f029 100644 --- a/src/Mod/Assembly/App/AppAssembly.cpp +++ b/src/Mod/Assembly/App/AppAssembly.cpp @@ -21,7 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Assembly/App/AppAssemblyPy.cpp b/src/Mod/Assembly/App/AppAssemblyPy.cpp index f62cf30c8f..49c9bab95d 100644 --- a/src/Mod/Assembly/App/AppAssemblyPy.cpp +++ b/src/Mod/Assembly/App/AppAssemblyPy.cpp @@ -21,7 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Assembly/App/AssemblyLink.cpp b/src/Mod/Assembly/App/AssemblyLink.cpp index f12169669c..4ab6771da8 100644 --- a/src/Mod/Assembly/App/AssemblyLink.cpp +++ b/src/Mod/Assembly/App/AssemblyLink.cpp @@ -21,11 +21,9 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include -#endif + #include #include diff --git a/src/Mod/Assembly/App/AssemblyLinkPyImp.cpp b/src/Mod/Assembly/App/AssemblyLinkPyImp.cpp index 5d9a9e78c7..7ca17b4e3b 100644 --- a/src/Mod/Assembly/App/AssemblyLinkPyImp.cpp +++ b/src/Mod/Assembly/App/AssemblyLinkPyImp.cpp @@ -22,8 +22,6 @@ ***************************************************************************/ -#include "PreCompiled.h" - // inclusion of the generated files (generated out of AssemblyLink.xml) #include "AssemblyLinkPy.h" #include "AssemblyLinkPy.cpp" diff --git a/src/Mod/Assembly/App/AssemblyObject.cpp b/src/Mod/Assembly/App/AssemblyObject.cpp index 3be6e90d9c..b9304f4e4e 100644 --- a/src/Mod/Assembly/App/AssemblyObject.cpp +++ b/src/Mod/Assembly/App/AssemblyObject.cpp @@ -21,13 +21,11 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include #include -#endif + #include #include diff --git a/src/Mod/Assembly/App/AssemblyObjectPyImp.cpp b/src/Mod/Assembly/App/AssemblyObjectPyImp.cpp index 74b6bc5f8f..4e44a9e8ea 100644 --- a/src/Mod/Assembly/App/AssemblyObjectPyImp.cpp +++ b/src/Mod/Assembly/App/AssemblyObjectPyImp.cpp @@ -22,8 +22,6 @@ ***************************************************************************/ -#include "PreCompiled.h" - // inclusion of the generated files (generated out of AssemblyObject.xml) #include "AssemblyObjectPy.h" #include "AssemblyObjectPy.cpp" diff --git a/src/Mod/Assembly/App/AssemblyUtils.cpp b/src/Mod/Assembly/App/AssemblyUtils.cpp index d55156c13e..86786484b3 100644 --- a/src/Mod/Assembly/App/AssemblyUtils.cpp +++ b/src/Mod/Assembly/App/AssemblyUtils.cpp @@ -21,8 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -30,7 +28,7 @@ #include #include #include -#endif + #include #include diff --git a/src/Mod/Assembly/App/BomGroup.cpp b/src/Mod/Assembly/App/BomGroup.cpp index 7754c39f6d..1ab091583a 100644 --- a/src/Mod/Assembly/App/BomGroup.cpp +++ b/src/Mod/Assembly/App/BomGroup.cpp @@ -21,10 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ -#endif - #include #include #include diff --git a/src/Mod/Assembly/App/BomGroupPyImp.cpp b/src/Mod/Assembly/App/BomGroupPyImp.cpp index a73a733cf7..4c22736390 100644 --- a/src/Mod/Assembly/App/BomGroupPyImp.cpp +++ b/src/Mod/Assembly/App/BomGroupPyImp.cpp @@ -21,8 +21,6 @@ ***************************************************************************/ -#include "PreCompiled.h" - // inclusion of the generated files (generated out of BomGroup.xml) #include "BomGroupPy.h" #include "BomGroupPy.cpp" diff --git a/src/Mod/Assembly/App/BomObject.cpp b/src/Mod/Assembly/App/BomObject.cpp index 3a63fd52e0..ca9b8c1679 100644 --- a/src/Mod/Assembly/App/BomObject.cpp +++ b/src/Mod/Assembly/App/BomObject.cpp @@ -21,11 +21,9 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include -#endif + #include #include diff --git a/src/Mod/Assembly/App/BomObjectPyImp.cpp b/src/Mod/Assembly/App/BomObjectPyImp.cpp index 3df251f35e..4066df238f 100644 --- a/src/Mod/Assembly/App/BomObjectPyImp.cpp +++ b/src/Mod/Assembly/App/BomObjectPyImp.cpp @@ -21,8 +21,6 @@ ***************************************************************************/ -#include "PreCompiled.h" - // inclusion of the generated files (generated out of BomObject.xml) #include "BomObjectPy.h" #include "BomObjectPy.cpp" diff --git a/src/Mod/Assembly/App/CMakeLists.txt b/src/Mod/Assembly/App/CMakeLists.txt index f6696ad805..70c8e0f9d3 100644 --- a/src/Mod/Assembly/App/CMakeLists.txt +++ b/src/Mod/Assembly/App/CMakeLists.txt @@ -37,7 +37,6 @@ SOURCE_GROUP("Python" FILES ${Python_SRCS}) SET(Module_SRCS AppAssembly.cpp AppAssemblyPy.cpp - PreCompiled.cpp PreCompiled.h ) SOURCE_GROUP("Module" FILES ${Module_SRCS}) @@ -78,9 +77,9 @@ if (FREECAD_WARN_ERROR) endif() if(FREECAD_USE_PCH) - add_definitions(-D_PreComp_) - GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Assembly_SRCS}) - ADD_MSVC_PRECOMPILED_HEADER(Assembly PreCompiled.h PreCompiled.cpp PCH_SRCS) + target_precompile_headers(Assembly PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) endif(FREECAD_USE_PCH) SET_BIN_DIR(Assembly AssemblyApp /Mod/Assembly) diff --git a/src/Mod/Assembly/App/JointGroup.cpp b/src/Mod/Assembly/App/JointGroup.cpp index c22bbbdd33..18e7c26679 100644 --- a/src/Mod/Assembly/App/JointGroup.cpp +++ b/src/Mod/Assembly/App/JointGroup.cpp @@ -21,9 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ -#endif #include #include diff --git a/src/Mod/Assembly/App/JointGroupPyImp.cpp b/src/Mod/Assembly/App/JointGroupPyImp.cpp index a403ca4d9a..2d23645b04 100644 --- a/src/Mod/Assembly/App/JointGroupPyImp.cpp +++ b/src/Mod/Assembly/App/JointGroupPyImp.cpp @@ -21,8 +21,6 @@ ***************************************************************************/ -#include "PreCompiled.h" - // inclusion of the generated files (generated out of JointGroup.xml) #include "JointGroupPy.h" #include "JointGroupPy.cpp" diff --git a/src/Mod/Assembly/App/PreCompiled.cpp b/src/Mod/Assembly/App/PreCompiled.cpp deleted file mode 100644 index ed7cfc6869..0000000000 --- a/src/Mod/Assembly/App/PreCompiled.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: LGPL-2.1-or-later -/**************************************************************************** - * * - * Copyright (c) 2023 Ondsel * - * * - * This file is part of FreeCAD. * - * * - * FreeCAD is free software: you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as * - * published by the Free Software Foundation, either version 2.1 of the * - * License, or (at your option) any later version. * - * * - * FreeCAD 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 * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with FreeCAD. If not, see * - * . * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" diff --git a/src/Mod/Assembly/App/PreCompiled.h b/src/Mod/Assembly/App/PreCompiled.h index 5027472fb0..7d20eaf595 100644 --- a/src/Mod/Assembly/App/PreCompiled.h +++ b/src/Mod/Assembly/App/PreCompiled.h @@ -26,8 +26,6 @@ #include -#ifdef _PreComp_ - // standard #include #include @@ -48,5 +46,4 @@ #include #include -#endif // _PreComp_ #endif // ASSEMBLY_PRECOMPILED_H diff --git a/src/Mod/Assembly/App/SimulationGroup.cpp b/src/Mod/Assembly/App/SimulationGroup.cpp index d80197a414..71f1c574b2 100644 --- a/src/Mod/Assembly/App/SimulationGroup.cpp +++ b/src/Mod/Assembly/App/SimulationGroup.cpp @@ -21,9 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ -#endif #include #include diff --git a/src/Mod/Assembly/App/SimulationGroupPyImp.cpp b/src/Mod/Assembly/App/SimulationGroupPyImp.cpp index 1d08082cb8..4ef1c6d111 100644 --- a/src/Mod/Assembly/App/SimulationGroupPyImp.cpp +++ b/src/Mod/Assembly/App/SimulationGroupPyImp.cpp @@ -22,8 +22,6 @@ ***************************************************************************/ -#include "PreCompiled.h" - // inclusion of the generated files (generated out of SimulationGroup.xml) #include "SimulationGroupPy.h" #include "SimulationGroupPy.cpp" diff --git a/src/Mod/Assembly/App/ViewGroup.cpp b/src/Mod/Assembly/App/ViewGroup.cpp index 864e692a62..536bce8604 100644 --- a/src/Mod/Assembly/App/ViewGroup.cpp +++ b/src/Mod/Assembly/App/ViewGroup.cpp @@ -21,9 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ -#endif #include #include diff --git a/src/Mod/Assembly/App/ViewGroupPyImp.cpp b/src/Mod/Assembly/App/ViewGroupPyImp.cpp index aa86e9d416..5fda15ecc4 100644 --- a/src/Mod/Assembly/App/ViewGroupPyImp.cpp +++ b/src/Mod/Assembly/App/ViewGroupPyImp.cpp @@ -21,8 +21,6 @@ ***************************************************************************/ -#include "PreCompiled.h" - // inclusion of the generated files (generated out of ViewGroup.xml) #include "ViewGroupPy.h" #include "ViewGroupPy.cpp" diff --git a/src/Mod/Assembly/Gui/AppAssemblyGui.cpp b/src/Mod/Assembly/Gui/AppAssemblyGui.cpp index eb0e09c932..4966c27bf6 100644 --- a/src/Mod/Assembly/Gui/AppAssemblyGui.cpp +++ b/src/Mod/Assembly/Gui/AppAssemblyGui.cpp @@ -21,7 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp b/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp index dd6f0fdf22..f82ca2409a 100644 --- a/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp +++ b/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp @@ -21,7 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include diff --git a/src/Mod/Assembly/Gui/CMakeLists.txt b/src/Mod/Assembly/Gui/CMakeLists.txt index bcb51c20c2..541a6959a9 100644 --- a/src/Mod/Assembly/Gui/CMakeLists.txt +++ b/src/Mod/Assembly/Gui/CMakeLists.txt @@ -38,7 +38,6 @@ SOURCE_GROUP("Python" FILES ${Python_SRCS}) SET(AssemblyGui_SRCS_Module AppAssemblyGui.cpp AppAssemblyGuiPy.cpp - PreCompiled.cpp PreCompiled.h TaskAssemblyMessages.cpp TaskAssemblyMessages.h @@ -69,18 +68,18 @@ SET(AssemblyGui_SRCS ${Python_SRCS} ) -if(FREECAD_USE_PCH) - add_definitions(-D_PreComp_) - GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${AssemblyGui_SRCS}) - ADD_MSVC_PRECOMPILED_HEADER(AssemblyGui PreCompiled.h PreCompiled.cpp PCH_SRCS) -endif(FREECAD_USE_PCH) - SET(AssemblyGuiIcon_SVG Resources/icons/AssemblyWorkbench.svg ) add_library(AssemblyGui SHARED ${AssemblyGui_SRCS} ${AssemblyGuiIcon_SVG}) +if(FREECAD_USE_PCH) + target_precompile_headers(AssemblyGui PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) +endif(FREECAD_USE_PCH) + target_include_directories( AssemblyGui PRIVATE diff --git a/src/Mod/Assembly/Gui/PreCompiled.cpp b/src/Mod/Assembly/Gui/PreCompiled.cpp deleted file mode 100644 index ed7cfc6869..0000000000 --- a/src/Mod/Assembly/Gui/PreCompiled.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: LGPL-2.1-or-later -/**************************************************************************** - * * - * Copyright (c) 2023 Ondsel * - * * - * This file is part of FreeCAD. * - * * - * FreeCAD is free software: you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as * - * published by the Free Software Foundation, either version 2.1 of the * - * License, or (at your option) any later version. * - * * - * FreeCAD 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 * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with FreeCAD. If not, see * - * . * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" diff --git a/src/Mod/Assembly/Gui/PreCompiled.h b/src/Mod/Assembly/Gui/PreCompiled.h index 59d045527d..90b02a0fdd 100644 --- a/src/Mod/Assembly/Gui/PreCompiled.h +++ b/src/Mod/Assembly/Gui/PreCompiled.h @@ -26,7 +26,6 @@ #include -#ifdef _PreComp_ // STL #include @@ -48,6 +47,5 @@ // all of Inventor #include -#endif //_PreComp_ #endif // ASSEMBLYGUI_PRECOMPILED_H diff --git a/src/Mod/Assembly/Gui/TaskAssemblyMessages.cpp b/src/Mod/Assembly/Gui/TaskAssemblyMessages.cpp index a85ed0e0e0..6d3da0ae38 100644 --- a/src/Mod/Assembly/Gui/TaskAssemblyMessages.cpp +++ b/src/Mod/Assembly/Gui/TaskAssemblyMessages.cpp @@ -21,10 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ -#endif - #include #include #include diff --git a/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp b/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp index 66b83809f7..3ef1cf7cb3 100644 --- a/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderAssembly.cpp @@ -21,9 +21,7 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include @@ -38,7 +36,7 @@ #include #include #include -#endif + #include diff --git a/src/Mod/Assembly/Gui/ViewProviderAssemblyLink.cpp b/src/Mod/Assembly/Gui/ViewProviderAssemblyLink.cpp index 04f8ff311a..becbf84f56 100644 --- a/src/Mod/Assembly/Gui/ViewProviderAssemblyLink.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderAssemblyLink.cpp @@ -21,15 +21,13 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include #include #include -#endif + #include #include diff --git a/src/Mod/Assembly/Gui/ViewProviderAssemblyPyImp.cpp b/src/Mod/Assembly/Gui/ViewProviderAssemblyPyImp.cpp index 463be2e9ea..0ebd0ff52c 100644 --- a/src/Mod/Assembly/Gui/ViewProviderAssemblyPyImp.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderAssemblyPyImp.cpp @@ -20,7 +20,6 @@ * * **************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Assembly/Gui/ViewProviderBom.cpp b/src/Mod/Assembly/Gui/ViewProviderBom.cpp index ee2146ad8f..f0e47f13e2 100644 --- a/src/Mod/Assembly/Gui/ViewProviderBom.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderBom.cpp @@ -21,11 +21,9 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include -#endif + #include #include diff --git a/src/Mod/Assembly/Gui/ViewProviderBomGroup.cpp b/src/Mod/Assembly/Gui/ViewProviderBomGroup.cpp index 980426cc11..1949fcd8a3 100644 --- a/src/Mod/Assembly/Gui/ViewProviderBomGroup.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderBomGroup.cpp @@ -21,11 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" - -#ifndef _PreComp_ -#endif - #include #include #include diff --git a/src/Mod/Assembly/Gui/ViewProviderJointGroup.cpp b/src/Mod/Assembly/Gui/ViewProviderJointGroup.cpp index f56dbde95e..d1151761b1 100644 --- a/src/Mod/Assembly/Gui/ViewProviderJointGroup.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderJointGroup.cpp @@ -21,11 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" - -#ifndef _PreComp_ -#endif - #include #include #include diff --git a/src/Mod/Assembly/Gui/ViewProviderSimulationGroup.cpp b/src/Mod/Assembly/Gui/ViewProviderSimulationGroup.cpp index ccfac42aec..d155d05b49 100644 --- a/src/Mod/Assembly/Gui/ViewProviderSimulationGroup.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderSimulationGroup.cpp @@ -21,11 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" - -#ifndef _PreComp_ -#endif - #include #include #include diff --git a/src/Mod/Assembly/Gui/ViewProviderViewGroup.cpp b/src/Mod/Assembly/Gui/ViewProviderViewGroup.cpp index bd32b579f3..496de73b48 100644 --- a/src/Mod/Assembly/Gui/ViewProviderViewGroup.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderViewGroup.cpp @@ -21,11 +21,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" - -#ifndef _PreComp_ -#endif - #include #include #include