Inspection: 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:10:44 +02:00
parent 7051848d10
commit 4bc92384b7
13 changed files with 12 additions and 82 deletions

View File

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

View File

@@ -9,7 +9,6 @@ SET(Inspection_SRCS
AppInspection.cpp
InspectionFeature.cpp
InspectionFeature.h
PreCompiled.cpp
PreCompiled.h
)
@@ -17,13 +16,14 @@ set(Inspection_Scripts
../Init.py
)
add_library(Inspection SHARED ${Inspection_SRCS} ${Inspection_Scripts})
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Inspection_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(Inspection PreCompiled.h PreCompiled.cpp PCH_SRCS)
target_precompile_headers(Inspection PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
add_library(Inspection SHARED ${Inspection_SRCS} ${Inspection_Scripts})
target_include_directories(
Inspection
PRIVATE

View File

@@ -20,9 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <boost/core/ignore_unused.hpp>
#include <numeric>
#include <limits>
@@ -39,7 +36,6 @@
#include <QFuture>
#include <QFutureWatcher>
#include <QtConcurrentMap>
#endif
#include <Base/Console.h>
#include <Base/FutureWatcherProgress.h>

View File

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

@@ -25,8 +25,6 @@
#include <FCConfig.h>
#ifdef _PreComp_
// STL
#include <numeric>
@@ -48,6 +46,4 @@
#include <QFutureWatcher>
#include <QtConcurrentMap>
#endif //_PreComp_
#endif

View File

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

View File

@@ -21,7 +21,6 @@ SET(InspectionGui_SRCS
${Dialogs_SRCS}
AppInspectionGui.cpp
Command.cpp
PreCompiled.cpp
PreCompiled.h
ViewProviderInspection.cpp
ViewProviderInspection.h
@@ -33,12 +32,6 @@ set(InspectionGui_Scripts
../InitGui.py
)
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${InspectionGui_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(InspectionGui PreCompiled.h PreCompiled.cpp PCH_SRCS)
endif(FREECAD_USE_PCH)
SET(InspectionGuiIcon_SVG
Resources/icons/InspectionWorkbench.svg
)
@@ -49,6 +42,12 @@ add_library(InspectionGui SHARED
${InspectionGuiIcon_SVG}
)
if(FREECAD_USE_PCH)
target_precompile_headers(InspectionGui PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
target_include_directories(
InspectionGui
PRIVATE

View File

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

View File

@@ -1,23 +0,0 @@
/***************************************************************************
* Copyright (c) 2011 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,8 +26,6 @@
#include <FCConfig.h>
#ifdef _PreComp_
// STL
// Inventor
@@ -54,6 +52,4 @@
#include <QMenu>
#include <QMessageBox>
#endif //_PreComp_
#endif // GUI_PRECOMPILED_H

View File

@@ -20,9 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QApplication>
#include <QMenu>
#include <QMessageBox>
@@ -44,7 +42,6 @@
#include <Inventor/nodes/SoNormal.h>
#include <Inventor/nodes/SoPointSet.h>
#include <Inventor/nodes/SoShapeHints.h>
#endif
#include <App/GeoFeature.h>
#include <Gui/Application.h>

View File

@@ -20,10 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#endif
#include <App/Document.h>
#include <App/DocumentObject.h>

View File

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