Measure: 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:20:36 +02:00
parent 4bc92384b7
commit 93830929ae
30 changed files with 22 additions and 130 deletions

View File

@@ -20,7 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <Mod/Measure/MeasureGlobal.h>
#include <App/MeasureManager.h>
#include <Base/Console.h>

View File

@@ -21,11 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Mod/Measure/MeasureGlobal.h>
#include <algorithm> // clears "include what you use" lint message, but creates "included header not used"

View File

@@ -15,7 +15,6 @@ SET(Python_SRCS
SOURCE_GROUP("Python" FILES ${Python_SRCS})
SET(MeasureModule_SRCS
PreCompiled.cpp
PreCompiled.h
AppMeasure.cpp
AppMeasurePy.cpp
@@ -56,14 +55,14 @@ SET(Measure_SRCS
${Python_SRCS}
)
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" Measure_CPP_SRCS ${Measure_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(Measure PreCompiled.h PreCompiled.cpp Measure_CPP_SRCS)
endif(FREECAD_USE_PCH)
add_library(Measure SHARED ${Measure_SRCS})
if(FREECAD_USE_PCH)
target_precompile_headers(Measure PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
target_include_directories(
Measure
PRIVATE

View File

@@ -20,8 +20,6 @@
**************************************************************************/
#include "PreCompiled.h"
#include <App/PropertyContainer.h>
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -20,8 +20,6 @@
**************************************************************************/
#include "PreCompiled.h"
#include <App/Application.h>
#include <App/MeasureManager.h>
#include <App/Document.h>

View File

@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include <Mod/Measure/MeasureGlobal.h>
#include <App/PropertyGeo.h>
#include <Base/PlacementPy.h>

View File

@@ -1,4 +1,3 @@
#include "PreCompiled.h"
#include "MeasureBase.h"

View File

@@ -20,8 +20,6 @@
**************************************************************************/
#include "PreCompiled.h"
#include <App/PropertyContainer.h>
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -20,8 +20,6 @@
**************************************************************************/
#include "PreCompiled.h"
#include <App/Application.h>
#include <App/Document.h>
#include <App/MeasureManager.h>

View File

@@ -20,8 +20,6 @@
**************************************************************************/
#include "PreCompiled.h"
#include <App/PropertyContainer.h>
#include <App/Application.h>
#include <App/MeasureManager.h>

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
@@ -38,7 +36,6 @@
#include <GProp_GProps.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#endif
#include <Base/Console.h>

View File

@@ -20,10 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <sstream>
#endif
#include <App/Application.h>
#include <App/Document.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

@@ -27,7 +27,6 @@
#include <Mod/Measure/MeasureGlobal.h>
#ifdef _PreComp_
// standard
#include <cmath>
@@ -43,6 +42,4 @@
#include <Mod/Part/App/OpenCascadeAll.h>
#endif //_PreComp_
#endif // MEASUREGUI_PRECOMPILED_H

View File

@@ -19,10 +19,8 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <string>
#endif
#include <App/Application.h>
#include <App/Material.h>

View File

@@ -26,10 +26,6 @@
//! and its placement.
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <boost_regex.hpp>
#include <BRep_Builder.hxx>

View File

@@ -24,10 +24,6 @@
//! a class to perform common operations on subelement names.
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <boost_regex.hpp>
#include <Base/Tools.h>

View File

@@ -19,10 +19,8 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QApplication>
#endif
#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <Base/PyObjectBase.h>

View File

@@ -29,7 +29,6 @@ SET(MeasureGui_SRCS
AppMeasureGui.cpp
Command.cpp
Resources/Measure.qrc
PreCompiled.cpp
PreCompiled.h
QuickMeasure.pyi
QuickMeasurePyImp.cpp
@@ -58,17 +57,18 @@ SET(MeasureGuiTaskDlgs_SRCS
# ../InitGui.py
#)
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${MeasureGui_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(MeasureGui PreCompiled.h PreCompiled.cpp PCH_SRCS)
endif(FREECAD_USE_PCH)
SET(MeasureGuiIcon_SVG
Resources/icons/preferences-measure.svg
)
add_library(MeasureGui SHARED ${MeasureGui_SRCS} ${MeasureGuiIcon_SVG})
if(FREECAD_USE_PCH)
target_precompile_headers(MeasureGui PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
target_include_directories(
MeasureGui
PRIVATE

View File

@@ -19,10 +19,7 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QApplication>
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -19,7 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include "DlgPrefsMeasureAppearanceImp.h"
#include "ui_DlgPrefsMeasureAppearanceImp.h"

View File

@@ -1,22 +0,0 @@
/***************************************************************************
* Copyright (c) 2023 David Friedli <david[at]friedli-be.ch> *
* *
* 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

@@ -30,8 +30,6 @@
#include <windows.h>
#endif
#ifdef _PreComp_
// standard
#include <cmath>
@@ -75,6 +73,4 @@
// Inventor includes OpenGL
#include <Gui/InventorAll.h>
#endif //_PreComp_
#endif

View File

@@ -20,13 +20,11 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cmath>
#include <vector>
#include <QTimer>
#endif
#include <App/Document.h>
#include <App/DocumentObject.h>

View File

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

View File

@@ -20,12 +20,8 @@
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QApplication>
#include <QKeyEvent>
#endif
#include "TaskMeasure.h"

View File

@@ -20,9 +20,7 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <sstream>
#include <QApplication>
#include <Inventor/draggers/SoTranslate2Dragger.h>
@@ -51,7 +49,7 @@
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/nodes/SoVertexProperty.h>
#include <Inventor/nodekits/SoBaseKit.h>
#endif
#include <Precision.hxx>
#include <Geom_Curve.hxx>

View File

@@ -21,9 +21,7 @@
#include "Gui/Application.h"
#include "Gui/MDIView.h"
#include "PreCompiled.h"
#ifndef _PreComp_
#include <Inventor/actions/SoGetMatrixAction.h>
#include <Inventor/nodes/SoAnnotation.h>
#include <Inventor/nodes/SoBaseColor.h>
@@ -38,7 +36,7 @@
#include <Inventor/engines/SoTransformVec3f.h>
#include <Inventor/engines/SoConcatenate.h>
#include <Inventor/SbViewportRegion.h>
#endif
#include <App/DocumentObject.h>
#include <Base/Console.h>

View File

@@ -21,9 +21,7 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <sstream>
#include <QApplication>
#include <Inventor/engines/SoCalculator.h>
@@ -47,7 +45,7 @@
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoResetTransform.h>
#include <Inventor/nodes/SoNodes.h>
#endif
#include <Gui/Inventor/MarkerBitmaps.h>