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 <PreCompiled.h>" from sources, also
there is no need for the "#ifdef _PreComp_" anymore
This commit is contained in:
Markus Reitböck
2025-09-21 15:59:38 +02:00
parent cf1b7821ee
commit e46020ada4
34 changed files with 16 additions and 143 deletions

View File

@@ -21,7 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <Base/Console.h>
#include <Base/Interpreter.h>

View File

@@ -21,7 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <Base/Interpreter.h>
#include <Base/Tools.h>

View File

@@ -21,11 +21,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cmath>
#include <vector>
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -22,8 +22,6 @@
***************************************************************************/
#include "PreCompiled.h"
// inclusion of the generated files (generated out of AssemblyLink.xml)
#include "AssemblyLinkPy.h"
#include "AssemblyLinkPy.cpp"

View File

@@ -21,13 +21,11 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <boost/core/ignore_unused.hpp>
#include <cmath>
#include <vector>
#include <unordered_map>
#endif
#include <App/Application.h>
#include <App/Datums.h>

View File

@@ -22,8 +22,6 @@
***************************************************************************/
#include "PreCompiled.h"
// inclusion of the generated files (generated out of AssemblyObject.xml)
#include "AssemblyObjectPy.h"
#include "AssemblyObjectPy.cpp"

View File

@@ -21,8 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <TopoDS.hxx>
@@ -30,7 +28,7 @@
#include <gp_Circ.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Sphere.hxx>
#endif
#include <App/Application.h>
#include <App/Datums.h>

View File

@@ -21,10 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Application.h>
#include <App/Document.h>
#include <App/FeaturePythonPyImp.h>

View File

@@ -21,8 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
// inclusion of the generated files (generated out of BomGroup.xml)
#include "BomGroupPy.h"
#include "BomGroupPy.cpp"

View File

@@ -21,11 +21,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cmath>
#include <vector>
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -21,8 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
// inclusion of the generated files (generated out of BomObject.xml)
#include "BomObjectPy.h"
#include "BomObjectPy.cpp"

View File

@@ -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
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
SET_BIN_DIR(Assembly AssemblyApp /Mod/Assembly)

View File

@@ -21,9 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -21,8 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
// inclusion of the generated files (generated out of JointGroup.xml)
#include "JointGroupPy.h"
#include "JointGroupPy.cpp"

View File

@@ -1,25 +0,0 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2023 Ondsel <development@ondsel.com> *
* *
* 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 *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
#include "PreCompiled.h"

View File

@@ -26,8 +26,6 @@
#include <FCConfig.h>
#ifdef _PreComp_
// standard
#include <cinttypes>
#include <cmath>
@@ -48,5 +46,4 @@
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#endif // _PreComp_
#endif // ASSEMBLY_PRECOMPILED_H

View File

@@ -21,9 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -22,8 +22,6 @@
***************************************************************************/
#include "PreCompiled.h"
// inclusion of the generated files (generated out of SimulationGroup.xml)
#include "SimulationGroupPy.h"
#include "SimulationGroupPy.cpp"

View File

@@ -21,9 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -21,8 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
// inclusion of the generated files (generated out of ViewGroup.xml)
#include "ViewGroupPy.h"
#include "ViewGroupPy.cpp"

View File

@@ -21,7 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <Base/Console.h>
#include <Base/Interpreter.h>

View File

@@ -21,7 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <Base/Interpreter.h>

View File

@@ -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
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
target_include_directories(
AssemblyGui
PRIVATE

View File

@@ -1,25 +0,0 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2023 Ondsel <development@ondsel.com> *
* *
* 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 *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
#include "PreCompiled.h"

View File

@@ -26,7 +26,6 @@
#include <FCConfig.h>
#ifdef _PreComp_
// STL
#include <algorithm>
@@ -48,6 +47,5 @@
// all of Inventor
#include <Gui/InventorAll.h>
#endif //_PreComp_
#endif // ASSEMBLYGUI_PRECOMPILED_H

View File

@@ -21,10 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>

View File

@@ -21,9 +21,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <boost/core/ignore_unused.hpp>
#include <QMessageBox>
#include <QTimer>
@@ -38,7 +36,7 @@
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/sensors/SoFieldSensor.h>
#include <Inventor/sensors/SoSensor.h>
#endif
#include <chrono>

View File

@@ -21,15 +21,13 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QAction>
#include <QMenu>
#include <vector>
#include <sstream>
#include <iostream>
#endif
#include <App/Link.h>
#include <App/Document.h>

View File

@@ -20,7 +20,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include <Base/Interpreter.h>
#include <Base/PlacementPy.h>

View File

@@ -21,11 +21,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <vector>
#endif
#include <App/Document.h>
#include <App/DocumentObject.h>

View File

@@ -21,11 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/Application.h>

View File

@@ -21,11 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/Application.h>

View File

@@ -21,11 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/Application.h>

View File

@@ -21,11 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/Application.h>