Material: 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-13 17:18:54 +02:00
parent 4179075b72
commit 79708fb4f6
75 changed files with 37 additions and 253 deletions

View File

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

View File

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

View File

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

View File

@@ -114,7 +114,6 @@ SET(Materials_SRCS
ModelManagerLocal.h
ModelUuids.cpp
ModelUuids.h
PreCompiled.cpp
PreCompiled.h
PropertyMaterial.cpp
PropertyMaterial.h
@@ -134,13 +133,14 @@ if(BUILD_MATERIAL_EXTERNAL)
)
endif(BUILD_MATERIAL_EXTERNAL)
add_library(Materials SHARED ${Materials_SRCS})
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Materials_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(Materials PreCompiled.h PreCompiled.cpp PCH_SRCS)
target_precompile_headers(Materials PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
add_library(Materials SHARED ${Materials_SRCS})
target_include_directories(
Materials
PRIVATE

View File

@@ -19,10 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Python.h>
#include <QMutex>
#include <QMutexLocker>

View File

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

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QDirIterator>
#include <QFileInfo>
#include <QString>
@@ -30,7 +28,7 @@
#include <QUuid>
#include <memory>
#include <fstream>
#endif
#include <App/Application.h>

View File

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

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include <QMetaType>
#include <Base/Quantity.h>

View File

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

View File

@@ -19,12 +19,10 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QDirIterator>
#include <QFileInfo>
#include <QVector>
#endif
#include <App/Application.h>

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include <QMetaType>
#include <Base/Quantity.h>

View File

@@ -19,15 +19,13 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QDirIterator>
#include <QFileInfo>
#include <QList>
#include <QMetaType>
#include <QRegularExpression>
#include <QString>
#endif
#include <App/Application.h>
#include <Base/Interpreter.h>

View File

@@ -19,10 +19,8 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <random>
#endif
#include <QDirIterator>
#include <QMutex>

View File

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

View File

@@ -19,10 +19,7 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <random>
#endif
#include <QDirIterator>
#include <QMutex>

View File

@@ -19,7 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include "Exceptions.h"
#include "MaterialFilter.h"

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include "Model.h"
#include "PyVariants.h"
#include "ModelPropertyPy.h"

View File

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

View File

@@ -19,11 +19,9 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMetaType>
#include <QRegularExpression>
#endif
#include <App/Application.h>
#include <Base/Quantity.h>

View File

@@ -19,11 +19,9 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMetaType>
#include <QUuid>
#endif
#include <App/Application.h>

View File

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

View File

@@ -19,11 +19,8 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <string>
#include <QLatin1Char>
#endif
#include <QFileInfo>

View File

@@ -19,12 +19,9 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QDirIterator>
#include <QFileInfo>
#include <QString>
#endif
#include <App/Application.h>
#include <Base/FileInfo.h>

View File

@@ -19,10 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <QDirIterator>
#include <QMutexLocker>

View File

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

View File

@@ -19,10 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <QDirIterator>
#include <QMutexLocker>

View File

@@ -19,7 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include "Model.h"
#include "ModelLibrary.h"

View File

@@ -19,7 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include "Model.h"
#include "ModelPropertyPy.h"

View File

@@ -19,7 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include "Model.h"
#include "ModelLibrary.h"

View File

@@ -19,10 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include "ModelUuids.h"
using namespace Materials;

View File

@@ -1,22 +0,0 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* 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

@@ -28,7 +28,6 @@
#include <windows.h>
#endif
#ifdef _PreComp_
// standard
#include <cmath>
@@ -57,6 +56,5 @@
#include <QUuid>
#include <QVector>
#endif //_PreComp_
#endif // MATERIAL_PRECOMPILED_H

View File

@@ -19,11 +19,9 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMetaType>
#include <QUuid>
#endif
#include <App/Application.h>

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include <QVariant>
#include "PyVariants.h"

View File

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

View File

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

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QImage>
#include <QImageReader>
@@ -31,7 +29,6 @@
#include <Inventor/nodes/SoSphere.h>
#include <Inventor/nodes/SoSwitch.h>
#include <Inventor/nodes/SoTexture2.h>
#endif
#include <Inventor/nodes/SoTextureCoordinateEnvironment.h>

View File

@@ -19,11 +19,9 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMenu>
#include <QMessageBox>
#endif
#include <Gui/Application.h>
#include <Gui/Command.h>

View File

@@ -19,12 +19,10 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMenu>
#include <QMessageBox>
#include <QPushButton>
#endif
#include <Gui/MainWindow.h>

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QColorDialog>
#include <QDesktopServices>
#include <QIODevice>
@@ -31,7 +29,7 @@
#include <QTextStream>
#include <QVariant>
#include <limits>
#endif
#include <App/Application.h>
#include <Base/Interpreter.h>

View File

@@ -19,11 +19,9 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QList>
#include <QMetaType>
#endif
#include <Base/Console.h>
#include <Gui/MainWindow.h>

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QColorDialog>
#include <QDesktopServices>
#include <QIODevice>
@@ -32,7 +30,7 @@
#include <QTextStream>
#include <QVariant>
#include <limits>
#endif
#include <App/Application.h>
#include <Base/Interpreter.h>

View File

@@ -115,7 +115,6 @@ SET(MatGui_SRCS
ModelSelect.cpp
ModelSelect.h
ModelSelect.ui
PreCompiled.cpp
PreCompiled.h
TextEdit.cpp
TextEdit.h
@@ -136,12 +135,6 @@ if(BUILD_MATERIAL_EXTERNAL)
)
endif(BUILD_MATERIAL_EXTERNAL)
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${MatGui_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(MatGui PreCompiled.h PreCompiled.cpp PCH_SRCS)
endif(FREECAD_USE_PCH)
SET(MatGuiIcon_SVG
Resources/icons/list.svg
Resources/icons/Material_Edit.svg
@@ -168,6 +161,12 @@ add_library(MatGui SHARED
${Material_Ui_Files}
)
if(FREECAD_USE_PCH)
target_precompile_headers(MatGui PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
target_include_directories(
MatGui
PRIVATE

View File

@@ -19,10 +19,8 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QPointer>
#endif
#include <Gui/Command.h>
#include <Gui/Control.h>

View File

@@ -20,12 +20,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QSignalBlocker>
#include <algorithm>
#include <boost/signals2.hpp>
#endif
#include <Base/Console.h>
#include <Gui/Application.h>

View File

@@ -19,11 +19,9 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QPainter>
#include <QPaintEvent>
#endif
#include <App/Document.h>
#include <Gui/Application.h>

View File

@@ -19,13 +19,11 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QClipboard>
#include <QStandardItem>
#include <QStandardItemModel>
#include <QTreeView>
#endif
#include <App/Document.h>
#include <Gui/Application.h>

View File

@@ -20,14 +20,11 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QDockWidget>
#include <QSignalBlocker>
#include <QString>
#include <algorithm>
#include <boost/signals2.hpp>
#endif
#include <Base/Console.h>
#include <Gui/Application.h>

View File

@@ -19,7 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include <Mod/Material/App/ModelUuids.h>

View File

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

View File

@@ -19,7 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include "DlgSettingsMaterial.h"
#include "ui_DlgSettingsMaterial.h"

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QBuffer>
#include <QFile>
#include <QMenu>
@@ -30,7 +28,7 @@
#include <QString>
#include <QSvgRenderer>
#include <QTextStream>
#endif
#include <Gui/FileDialog.h>
#include <Gui/MainWindow.h>

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QColorDialog>
#include <QDesktopServices>
#include <QIODevice>
@@ -31,7 +29,7 @@
#include <QTextStream>
#include <QVariant>
#include <limits>
#endif
#include <App/Application.h>
#include <Base/Interpreter.h>

View File

@@ -19,11 +19,9 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMenu>
#include <QMessageBox>
#endif
#include <Gui/MainWindow.h>

View File

@@ -19,10 +19,8 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMetaType>
#endif
#include <Base/Console.h>
#include <Gui/MainWindow.h>

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QColorDialog>
#include <QDesktopServices>
#include <QIODevice>
@@ -33,7 +31,7 @@
#include <QTextStream>
#include <QVariant>
#include <limits>
#endif
#include <App/Application.h>
#include <Base/Interpreter.h>

View File

@@ -19,12 +19,10 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMenu>
#include <QMessageBox>
#include <QTreeView>
#endif
#include <Gui/Application.h>
#include <Gui/Command.h>

View File

@@ -19,11 +19,9 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QContextMenuEvent>
#include <QMenu>
#endif
#include <cstring>

View File

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

View File

@@ -19,8 +19,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QColorDialog>
#include <QDesktopServices>
#include <QIODevice>
@@ -32,7 +30,7 @@
#include <QTextStream>
#include <QVariant>
#include <limits>
#endif
#include <App/Application.h>
#include <App/License.h>

View File

@@ -19,13 +19,11 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QDesktopServices>
#include <QItemSelectionModel>
#include <QPushButton>
#include <QString>
#endif
#include <App/Application.h>
#include <Base/Interpreter.h>

View File

@@ -1,22 +0,0 @@
/***************************************************************************
* Copyright (c) 2023 David Carter <dcarter@david.carter.ca> *
* *
* 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

@@ -28,7 +28,6 @@
#include <windows.h>
#endif
#ifdef _PreComp_
// standard
#include <cmath>
@@ -49,6 +48,5 @@
# include <Gui/InventorAll.h>
#endif //_PreComp_
#endif // MATGUI_PRECOMPILED_H

View File

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

View File

@@ -19,11 +19,9 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMenu>
#include <QMessageBox>
#endif
#include <Gui/MainWindow.h>

View File

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

View File

@@ -22,7 +22,6 @@
**************************************************************************/
#include "PreCompiled.h"
#include "WorkbenchManipulator.h"
#include <Gui/MenuManager.h>
#include <Gui/ToolBarManager.h>

View File

@@ -22,10 +22,6 @@
#include <gtest/gtest.h>
#include <Mod/Material/App/PreCompiled.h>
#ifndef _PreComp_
#endif
#include <QMetaType>
#include <QString>

View File

@@ -22,10 +22,6 @@
#include "gtest/gtest.h"
#include <Mod/Material/App/PreCompiled.h>
#ifndef _PreComp_
#endif
#include <QMetaType>
#include <QString>

View File

@@ -22,10 +22,6 @@
#include <gtest/gtest.h>
#include <Mod/Material/App/PreCompiled.h>
#ifndef _PreComp_
#endif
#include <memory>
#include <QMetaType>

View File

@@ -22,10 +22,6 @@
#include <gtest/gtest.h>
#include <Mod/Material/App/PreCompiled.h>
#ifndef _PreComp_
#endif
#include <QMetaType>
#include <QString>

View File

@@ -22,10 +22,6 @@
#include <gtest/gtest.h>
#include <Mod/Material/App/PreCompiled.h>
#ifndef _PreComp_
#endif
#include <QLocale>
#include <QMetaType>
#include <QString>

View File

@@ -22,10 +22,6 @@
#include <gtest/gtest.h>
#include <Mod/Material/App/PreCompiled.h>
#ifndef _PreComp_
#endif
#include <QString>
#include <App/Application.h>

View File

@@ -22,10 +22,6 @@
#include <gtest/gtest.h>
#include <Mod/Material/App/PreCompiled.h>
#ifndef _PreComp_
#endif
#include <QMetaType>
#include <QString>