Spreadsheet: 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-15 20:31:46 +02:00
parent f323323e8b
commit 62b915ee7b
39 changed files with 39 additions and 124 deletions

View File

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

View File

@@ -10,7 +10,6 @@ set(Spreadsheet_SRCS
Cell.cpp
Cell.h
DisplayUnit.h
PreCompiled.cpp
PreCompiled.h
PropertySheet.cpp
PropertySheet.h
@@ -40,14 +39,14 @@ generate_from_py(PropertySheet)
generate_from_py(PropertyColumnWidths)
generate_from_py(PropertyRowHeights)
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Spreadsheet_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(Spreadsheet PreCompiled.h PreCompiled.cpp PCH_SRCS)
endif(FREECAD_USE_PCH)
add_library(Spreadsheet SHARED ${Spreadsheet_SRCS})
if(FREECAD_USE_PCH)
target_precompile_headers(Spreadsheet PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
target_include_directories(
Spreadsheet
PRIVATE

View File

@@ -20,15 +20,13 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QLocale>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/tokenizer.hpp>
#include <iomanip>
#include <sstream>
#endif
#include <App/ExpressionParser.h>
#include <Base/Console.h>

View File

@@ -29,6 +29,8 @@
#include <App/Expression.h>
#include <App/Material.h>
#include <Mod/Spreadsheet/SpreadsheetGlobal.h>
#include "DisplayUnit.h"
#include "Utils.h"

View File

@@ -1,24 +0,0 @@
/***************************************************************************
* Copyright (c) 2002 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

@@ -26,8 +26,6 @@
#include <FCConfig.h>
#ifdef _PreComp_
// STL
#include <algorithm>
#include <deque>
@@ -48,6 +46,4 @@
// Qt
#include <QLocale>
#endif //_PreComp_
#endif // SPREADSHEET_PRECOMPILED_H

View File

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

View File

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

View File

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

View File

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

View File

@@ -20,14 +20,11 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <algorithm>
#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm/copy.hpp>
#include <boost/regex.hpp>
#endif
#include <App/Document.h>
#include <App/DocumentObject.h>

View File

@@ -23,11 +23,19 @@
#ifndef PROPERTYSHEET_H
#define PROPERTYSHEET_H
#ifdef _MSC_VER
#ifdef PropertySheet
#undef PropertySheet // Microsoft's #define conflicts with the use below
#endif
#endif
#include <map>
#include <App/DocumentObject.h>
#include <App/PropertyLinks.h>
#include <Mod/Spreadsheet/SpreadsheetGlobal.h>
#include "Cell.h"

View File

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

View File

@@ -20,9 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <boost/tokenizer.hpp>
#include <boost/regex.hpp>
#include <deque>
@@ -34,7 +31,6 @@
#include <string>
#include <set>
#include <vector>
#endif
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -41,6 +41,8 @@
#include <App/Range.h>
#include <Base/Unit.h>
#include <Mod/Spreadsheet/SpreadsheetGlobal.h>
#include "PropertyColumnWidths.h"
#include "PropertyRowHeights.h"
#include "PropertySheet.h"

View File

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

View File

@@ -21,7 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <boost/tokenizer.hpp>

View File

@@ -20,11 +20,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <sstream>
#endif
#include "Sheet.h"
#include "Utils.h"

View File

@@ -21,7 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <App/Application.h>
#include <App/Document.h>

View File

@@ -64,7 +64,6 @@ SET(SpreadsheetGui_SRCS
SheetTableViewAccessibleInterface.cpp
SheetModel.h
SheetModel.cpp
PreCompiled.cpp
PreCompiled.h
Workbench.cpp
Workbench.h
@@ -105,6 +104,12 @@ add_library(SpreadsheetGui SHARED
${SpreadsheetGuiIcon_SVG}
)
if(FREECAD_USE_PCH)
target_precompile_headers(SpreadsheetGui PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
target_include_directories(
SpreadsheetGui
PRIVATE

View File

@@ -19,11 +19,10 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <sstream>
#endif
#include <FCConfig.h>
#if defined(FC_OS_WIN32)
#include <sys/timeb.h>

View File

@@ -20,7 +20,6 @@
* *
****************************************************************************/
#include "PreCompiled.h"
#include <QMessageBox>
#include <boost/algorithm/string.hpp>

View File

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

View File

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

View File

@@ -20,14 +20,11 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QApplication>
#include <QEvent>
#include <QKeyEvent>
#include <QGraphicsProxyWidget>
#endif
#include "LineEdit.h"
#include <Gui/MainWindow.h>

View File

@@ -1,24 +0,0 @@
/***************************************************************************
* Copyright (c) 2002 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

@@ -26,8 +26,6 @@
#include <FCConfig.h>
#ifdef _PreComp_
// standard
#include <cmath>
@@ -42,6 +40,4 @@
// Qt Toolkit
#include <Gui/QtAll.h>
#endif //_PreComp_
#endif // SPREADSHEET_PRECOMPILED_H

View File

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

View File

@@ -20,12 +20,10 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QFont>
#include <QLocale>
#endif
#include <App/Document.h>
#include <Base/Interpreter.h>

View File

@@ -20,9 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#include <QAction>
#include <QApplication>
@@ -31,7 +28,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QMimeData>
#endif
#include <QTextTableCell>
#include <App/Application.h>

View File

@@ -21,9 +21,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QAction>
#include <QApplication>
#include <QClipboard>
@@ -31,7 +29,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QMimeData>
#endif
#include "SheetTableViewAccessibleInterface.h"

View File

@@ -22,12 +22,10 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QLineEdit>
#include <QPainter>
#endif
#include <App/DocumentObject.h>
#include <Base/Console.h>

View File

@@ -20,15 +20,13 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QPalette>
#include <QPrintDialog>
#include <QPrintPreviewDialog>
#include <QPrinter>
#include <QTextDocument>
#endif
#include <App/Application.h>
#include <App/DocumentObject.h>

View File

@@ -29,6 +29,8 @@
#include <Gui/MDIViewPy.h>
#include <Mod/Spreadsheet/App/Sheet.h>
#include <Mod/Spreadsheet/SpreadsheetGlobal.h>
#include "SheetModel.h"

View File

@@ -21,13 +21,11 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QMenu>
#include <QString>
#include <sstream>
#endif
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
// clang-format off
#include "ViewProviderSpreadsheetPy.h"

View File

@@ -21,12 +21,10 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QToolBar>
#include <qobject.h>
#endif
#include "Mod/Spreadsheet/App/Sheet.h"
#include "Mod/Spreadsheet/Gui/SpreadsheetView.h"

View File

@@ -45,8 +45,6 @@
**
****************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cmath>
#include <QApplication>
@@ -64,7 +62,6 @@
#include <QtGui/QPaintEvent>
#include <QtGui/QPixmap>
#include <QtGui/QShowEvent>
#endif
#include <Gui/FileDialog.h>

View File

@@ -20,11 +20,11 @@
* *
***************************************************************************/
#include <FCGlobal.h>
#ifndef SPREADSHEET_GLOBAL_H
#define SPREADSHEET_GLOBAL_H
#include <FCGlobal.h>
// Spreadsheet
#ifndef SpreadsheetExport