Sandbox: 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-23 19:29:13 +02:00
parent b864ccda60
commit 2150afc470
16 changed files with 22 additions and 113 deletions

View File

@@ -21,10 +21,8 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Python.h>
#endif
#include <Base/Console.h>
#include <App/DocumentPy.h>

View File

@@ -32,7 +32,6 @@ SET(Sandbox_SRCS
DocumentProtectorPy.h
DocumentThread.cpp
DocumentThread.h
PreCompiled.cpp
PreCompiled.h
)
@@ -45,6 +44,12 @@ add_library(Sandbox SHARED ${Sandbox_SRCS} ${Sandbox_Scripts})
target_link_libraries(Sandbox ${Sandbox_LIBS})
if(FREECAD_USE_PCH)
target_precompile_headers(Sandbox PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
fc_target_copy_resource_flat(Sandbox
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/Mod/Sandbox

View File

@@ -21,8 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QCoreApplication>
# include <QObject>
# include <QEvent>
@@ -31,7 +29,7 @@
# include <QSemaphore>
# include <QThread>
# include <QWaitCondition>
#endif
#include "DocumentProtector.h"

View File

@@ -21,10 +21,8 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <memory>
#endif
#include "DocumentProtectorPy.h"
#include "DocumentProtector.h"

View File

@@ -21,10 +21,8 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QMutexLocker>
#endif
#include "DocumentThread.h"
#include "DocumentProtector.h"

View File

@@ -1,24 +0,0 @@
/***************************************************************************
* Copyright (c) 2009 Werner Mayer <wmayer@users.sourceforge.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

@@ -26,17 +26,6 @@
#include <FCConfig.h>
// Exporting of App classes
#ifdef FC_OS_WIN32
# define SandboxAppExport __declspec(dllexport)
# define MeshExport __declspec(dllimport)
#else // for Linux
# define SandboxAppExport
# define MeshExport
#endif
#ifdef _PreComp_
// standard
#include <cstdio>
#include <cassert>
@@ -67,7 +56,5 @@
#include <QSemaphore>
#include <QThread>
#endif //_PreComp_
#endif

View File

@@ -21,14 +21,12 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Python.h>
# include <Inventor/nodes/SoLineSet.h>
# include <Inventor/nodes/SoBaseColor.h>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/nodes/SoCoordinate3.h>
#endif
#include <Base/Console.h>
#include <Base/Interpreter.h>

View File

@@ -1,5 +1,6 @@
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/Gui
)
@@ -42,7 +43,6 @@ SET(SandboxGui_SRCS
GLGraphicsView.h
Overlay.cpp
Overlay.h
PreCompiled.cpp
PreCompiled.h
TaskPanelView.cpp
TaskPanelView.h
@@ -62,6 +62,12 @@ if (MSVC)
endif()
if(FREECAD_USE_PCH)
target_precompile_headers(SandboxGui PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
fc_target_copy_resource_flat(SandboxGui
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/Mod/Sandbox

View File

@@ -20,9 +20,8 @@
* *
***************************************************************************/
#include <FCConfig.h>
#include "PreCompiled.h"
#ifndef _PreComp_
# ifdef FC_OS_WIN32
# include <windows.h>
# endif
@@ -55,7 +54,6 @@
# include <boost/thread/future.hpp>
# include <boost/bind/bind.hpp>
# include <memory>
#endif
#include <Base/Console.h>
#include <Base/Sequencer.h>

View File

@@ -21,11 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Inventor/SoEventManager.h>
#include <Inventor/SoRenderManager.h>
#include <Inventor/SbViewportRegion.h>

View File

@@ -21,14 +21,12 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QImage>
# include <QMouseEvent>
# include <QPainter>
# include <Inventor/nodes/SoOrthographicCamera.h>
# include <Inventor/nodes/SoImage.h>
#endif
#include <Gui/Application.h>
#include <Gui/Document.h>

View File

@@ -1,24 +0,0 @@
/***************************************************************************
* Copyright (c) 2009 Werner Mayer <wmayer[at]users.sourceforge.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

@@ -26,23 +26,6 @@
#include <FCConfig.h>
// Importing of App classes
#ifdef FC_OS_WIN32
# define SandboxAppExport __declspec(dllimport)
# define SandboxGuiExport __declspec(dllexport)
# define MeshExport __declspec(dllimport)
# define PartExport __declspec(dllimport)
# define AppPartExport __declspec(dllimport)
#else // for Linux
# define SandboxAppExport
# define SandboxGuiExport
# define MeshExport
# define PartExport
# define AppPartExport
#endif
#ifdef _PreComp_
// standard
#include <cstdio>
#include <cassert>
@@ -72,6 +55,4 @@
#include <qmainwindow.h>
#include <qworkspace.h>
#endif //_PreComp_
#endif // GUI_PRECOMPILED_H
#endif // GUI_PRECOMPILED_H

View File

@@ -21,7 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
/// Here the FreeCAD includes sorted by Base,App,Gui......

View File

@@ -21,9 +21,7 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QGridLayout>
# include <QPainter>
# include <Inventor/actions/SoAction.h>
@@ -32,7 +30,7 @@
# include <Inventor/elements/SoViewportRegionElement.h>
# include <Inventor/SoPrimitiveVertex.h>
# include <Inventor/SbLinear.h>
#endif
#include "Workbench.h"
#include <App/Application.h>