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 <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 16:54:06 +02:00
parent 5b6a0b1852
commit 015896f4e4
22 changed files with 19 additions and 104 deletions

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 <BRepBuilderAPI_MakePolygon.hxx>
#include <TopoDS.hxx>
#endif
#include <Base/Console.h>
#include <Base/Converter.h>

View File

@@ -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
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
# Suppress -Wundefined-var-template

View File

@@ -20,9 +20,10 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#include <FCConfig.h>
#ifdef FC_OS_LINUX
#include <unistd.h>
#endif
@@ -43,7 +44,6 @@
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <gp_Pln.hxx>
#endif
#include <Base/Console.h>
#include <Base/FileInfo.h>

View File

@@ -20,12 +20,11 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <FCConfig.h>
#ifdef FC_OS_LINUX
#include <unistd.h>
#endif
#endif
#include <Base/Builder3D.h>
#include <Base/Console.h>

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <map>
#include <set>
#include <vector>
@@ -33,7 +31,6 @@
#include <Standard_Version.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TopLoc_Location.hxx>
#endif
#include "MeshFlattening.h"
#include "MeshFlatteningLscmRelax.h"

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <array>
#include <cmath>
#include <iostream>
@@ -29,7 +27,7 @@
#include <numbers>
#include <set>
#include <vector>
#endif
#include <Eigen/SparseCholesky>

View File

@@ -20,11 +20,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cmath>
#include <iostream>
#endif
#include "MeshFlatteningNurbs.h"

View File

@@ -25,15 +25,12 @@
# define strdup _strdup
#endif
#include "PreCompiled.h"
#ifndef _PreComp_
# include <stdexcept>
# include <vector>
# include <TopoDS.hxx>
# include <TopoDS_Edge.hxx>
# include <TopoDS_Face.hxx>
#endif
// necessary for the feature despite not all are necessary for compilation
#include <pybind11/eigen.h>

View File

@@ -20,15 +20,12 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <algorithm>
#include <BRepMesh_IncrementalMesh.hxx>
#include <BRepTools.hxx>
#include <Standard_Version.hxx>
#include <TopoDS_Shape.hxx>
#endif
#include <Base/Console.h>
#include <Base/Tools.h>

View File

@@ -1,23 +0,0 @@
/***************************************************************************
* Copyright (c) 2008 Jürgen Riegel <juergen.riegel@web.de> *
* *
* 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 <cmath>
#include <iostream>
@@ -72,5 +70,4 @@
#include <TopoDS_Shape.hxx>
#include <gp_Pln.hxx>
#endif // _PreComp_
#endif

View File

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

View File

@@ -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
$<$<COMPILE_LANGUAGE:CXX>:"${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

View File

@@ -20,12 +20,10 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QApplication>
#include <QMessageBox>
#include <QPushButton>
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#include <sstream>
@@ -40,7 +38,6 @@
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoLineSet.h>
#include <Inventor/nodes/SoSeparator.h>
#endif
#include <App/Document.h>
#include <Gui/Application.h>

View File

@@ -20,9 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMenu>
#include <QPointer>
#include <QStatusBar>
@@ -49,7 +47,6 @@
#include <Inventor/nodes/SoLineSet.h>
#include <Inventor/nodes/SoPointSet.h>
#include <Inventor/nodes/SoSeparator.h>
#endif
#include <App/Document.h>
#include <Base/Converter.h>

View File

@@ -1,23 +0,0 @@
/***************************************************************************
* Copyright (c) 2008 Jürgen Riegel <juergen.riegel@web.de> *
* *
* 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_
// STL
#include <sstream>
@@ -69,6 +67,4 @@
#include <Inventor/nodes/SoPointSet.h>
#include <Inventor/nodes/SoSeparator.h>
#endif //_PreComp_
#endif // __PRECOMPILED_GUI__

View File

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

View File

@@ -20,10 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMessageBox>
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

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