CAM: 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 23:36:45 +02:00
parent 63a8d31bb6
commit 6bd5c9737d
54 changed files with 32 additions and 226 deletions

View File

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

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <gp_Circ.hxx>
@@ -31,7 +29,7 @@
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp_Explorer.hxx>
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -20,12 +20,10 @@
* *
****************************************************************************/
#include "PreCompiled.h"
// From Boost 1.75 on the geometry component requires C++14
#define BOOST_GEOMETRY_DISABLE_DEPRECATED_03_WARNING
#ifndef _PreComp_
#include <limits>
#include <boost/geometry.hpp>
@@ -67,7 +65,6 @@
#include <TopExp_Explorer.hxx>
#include <TopoDS_Compound.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

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

View File

@@ -42,7 +42,6 @@ SET(Python_SRCS
SET(Mod_SRCS
AppPath.cpp
AppPathPy.cpp
PreCompiled.cpp
PreCompiled.h
)
@@ -128,9 +127,9 @@ endif()
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" Path_CPP_SRCS ${Path_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(Path PreCompiled.h PreCompiled.cpp Path_CPP_SRCS)
target_precompile_headers(Path PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
SET_BIN_DIR(Path PathApp /Mod/CAM)

View File

@@ -20,12 +20,10 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cinttypes>
#include <iomanip>
#include <boost/algorithm/string.hpp>
#endif
#include <Base/Exception.h>
#include <Base/Reader.h>

View File

@@ -20,10 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <boost/algorithm/string.hpp>
#endif
#include <Base/Exception.h>
#include <Base/PlacementPy.h>

View File

@@ -20,12 +20,10 @@
* *
****************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <BRep_Builder.hxx>
#include <Precision.hxx>
#include <TopoDS_Compound.hxx>
#endif
#include <Base/Console.h> // for FC_LOG_LEVEL_INIT
#include <Base/Placement.h>

View File

@@ -20,7 +20,6 @@
* *
****************************************************************************/
#include "PreCompiled.h"
#include <Base/PyWrapParseTupleAndKeywords.h>
#include <Mod/Part/App/TopoShapePy.h>

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <App/DocumentObjectPy.h>

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "FeaturePathCompound.h"
#include "Command.h"

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
// inclusion of the generated files (generated out of FeaturePathCompoundPy.xml)
#include "FeaturePathCompoundPy.h"

View File

@@ -21,11 +21,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <Standard_Version.hxx>
#include <TopoDS_Shape.hxx>
#endif
#include "FeaturePathShape.h"

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <App/Application.h>
#include <Base/Console.h>

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Base/GeometryPyCXX.h"

View File

@@ -19,7 +19,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <vector>

View File

@@ -1,24 +0,0 @@
/***************************************************************************
* Copyright (c) 2014 Yorik van Havre <yorik@uncreated.net> *
* *
* 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"

View File

@@ -25,19 +25,6 @@
#include <FCConfig.h>
// Exporting of App classes
#ifdef FC_OS_WIN32
#define PathExport __declspec(dllexport)
// # define RobotExport __declspec(dllexport) uncomment this to use KDL
#define PartExport __declspec(dllimport)
#else // for Linux
#define PathExport
// # define RobotExport uncomment this to use KDL
#define PartExport
#endif
#ifdef _PreComp_
// standard
#include <cinttypes>
#include <iomanip>
@@ -97,5 +84,4 @@
#include <TopExp_Explorer.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#endif // _PreComp_
#endif

View File

@@ -20,10 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <sstream>
#endif
#include <App/DocumentObject.h>
#include <App/PropertyContainer.h>

View File

@@ -20,10 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Base/Vector3D.h>
#include <Base/Tools.h>

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "VoronoiCell.h"

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Base/Vector3D.h"
#include "Base/VectorPy.h"

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "VoronoiEdge.h"

View File

@@ -20,12 +20,11 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <Geom_Parabola.hxx>
#endif
#include "Mod/Part/App/Geometry.h"
#include "Mod/Part/App/TopoShapeEdgePy.h"

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Base/GeometryPyCXX.h"
#include "Base/Vector3D.h"

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "VoronoiVertex.h"

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Base/Vector3D.h"
#include "Base/VectorPy.h"

View File

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

View File

@@ -20,11 +20,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QDir>
#include <QFileInfo>
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -24,7 +24,6 @@ SET(PathGui_SRCS_Module
AppPathGui.cpp
AppPathGuiPy.cpp
Resources/Path.qrc
PreCompiled.cpp
PreCompiled.h
DlgSettingsPathColor.ui
DlgSettingsPathColor.cpp
@@ -59,17 +58,18 @@ SET(PathGui_SRCS
${PathGui_SRCS_ViewProvider}
)
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${PathGui_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(PathGui PreCompiled.h PreCompiled.cpp PCH_SRCS)
endif(FREECAD_USE_PCH)
SET(PathGuiIcon_SVG
Resources/icons/CAMWorkbench.svg
)
add_library(PathGui SHARED ${PathGui_SRCS} ${PathGuiIcon_SVG})
if(FREECAD_USE_PCH)
target_precompile_headers(PathGui PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
target_include_directories(
PathGui
PRIVATE

View File

@@ -20,10 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <TopExp_Explorer.hxx>
#endif
#include <Base/Console.h>
#include <Gui/Application.h>

View File

@@ -20,10 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QDialog>
#endif
#include <Gui/MainWindow.h>

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "DlgSettingsPathColor.h"
#include "ui_DlgSettingsPathColor.h"

View File

@@ -1,23 +0,0 @@
/***************************************************************************
* Copyright (c) 2014 Yorik van Havre <yorik@uncreated.net> *
* *
* 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"

View File

@@ -25,21 +25,6 @@
#include <FCConfig.h>
// Importing of App classes
#ifdef FC_OS_WIN32
#define PartExport __declspec(dllimport)
#define PathExport __declspec(dllimport)
#define PartGuiExport __declspec(dllexport)
#define PathGuiExport __declspec(dllexport)
#else // for Linux
#define PartExport
#define PathExport
#define PartGuiExport
#define PathGuiExport
#endif
#ifdef _PreComp_
// boost
#include <boost/algorithm/string/replace.hpp>
@@ -65,6 +50,4 @@
#include <Inventor/nodes/SoSwitch.h>
#include <Inventor/nodes/SoTransform.h>
#endif //_PreComp_
#endif // PATHGUI_PRECOMPILED_H

View File

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

View File

@@ -20,7 +20,6 @@
* *
****************************************************************************/
#include "PreCompiled.h"
#include <Gui/Application.h>
#include <Mod/CAM/App/FeatureArea.h>

View File

@@ -20,9 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#include <boost/algorithm/string/replace.hpp>
@@ -37,7 +34,6 @@
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoSwitch.h>
#include <Inventor/nodes/SoTransform.h>
#endif
#include <App/Application.h>
#include <App/DocumentObject.h>

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <Gui/BitmapFactory.h>
#include <Gui/Control.h>

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>

View File

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

View File

@@ -18,7 +18,6 @@ SET(PathSimulator_SRCS
PathSim.h
VolSim.cpp
VolSim.h
PreCompiled.cpp
PreCompiled.h
${Python_SRCS}
)

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "PathSim.h"

View File

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

View File

@@ -1,23 +0,0 @@
/***************************************************************************
* Copyright (c) 2017 Shai Seger <shaise at gmail> *
* *
* 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"

View File

@@ -25,7 +25,6 @@
#include <FCConfig.h>
#ifdef _PreComp_
// standard
#include <cstdio>
@@ -50,6 +49,4 @@
// Xerces
#include <xercesc/util/XercesDefs.hpp>
#endif //_PreComp_
#endif

View File

@@ -20,10 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <algorithm>
#endif
#include <BRepBndLib.hxx>
#include <BRepCheck_Analyzer.hxx>

View File

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

View File

@@ -20,11 +20,9 @@
* *
***************************************************************************/
#include "PreCompiled.h" // NOLINT
#ifndef _PreComp_
#include <string>
#include <vector>
#endif
#include "CAMSim.h"
#include "DlgCAMSimulator.h"

View File

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

View File

@@ -22,7 +22,6 @@ SET(CAMSimulator_SRCS_Module
CAMSimPyImp.cpp
DlgCAMSimulator.cpp
DlgCAMSimulator.h
PreCompiled.cpp
PreCompiled.h
)
@@ -76,12 +75,6 @@ SET(CAMSimulator_SRCS
${CAMSimulator_SRCS_Core}
)
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${CAMSimulator_SRCS_precomp})
ADD_MSVC_PRECOMPILED_HEADER(CAMSimulator PreCompiled.h PreCompiled.cpp PCH_SRCS)
endif(FREECAD_USE_PCH)
add_library(CAMSimulator SHARED ${CAMSimulator_SRCS})
target_include_directories(
CAMSimulator
@@ -92,6 +85,14 @@ target_include_directories(
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(CAMSimulator ${CAMSimulator_LIBS})
if(FREECAD_USE_PCH)
target_precompile_headers(CAMSimulator PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
set_source_files_properties(${CAMSimulator_SRCS_Core} PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE)
endif(FREECAD_USE_PCH)
if (FREECAD_WARN_ERROR)
target_compile_warn_error(CAMSimulator)
endif()

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "DlgCAMSimulator.h"
#include "MillSimulation.h"

View File

@@ -1,23 +0,0 @@
/***************************************************************************
* Copyright (c) 2017 Shai Seger <shaise at gmail> *
* *
* 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"

View File

@@ -25,8 +25,6 @@
#include <FCConfig.h>
#ifdef _PreComp_
// standard
#include <cstdio>
#include <cassert>
@@ -50,6 +48,4 @@
// Xerces
#include <xercesc/util/XercesDefs.hpp>
#endif //_PreComp_
#endif