Base: 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 11:26:01 +02:00
parent ab68e62ec9
commit 5a423dab39
78 changed files with 27 additions and 248 deletions

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Axis.h"
#include "Placement.h"

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "GeometryPyCXX.h"
// generated out of Axis.pyi

View File

@@ -28,11 +28,8 @@ rather than returning a new string for each call.
These modifications are Copyright (c) 2019 Zheng Lei (realthunder.dev@gmail.com)
*/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <array>
#endif
#include "Base64.h"

View File

@@ -20,12 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cassert>
#endif
#include "BaseClass.h"
#include "PyObjectBase.h"

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Type.h"
// generated out of BaseClass.pyi

View File

@@ -20,11 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <unordered_map>
#endif
#include "BindingManager.h"

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "GeometryPyCXX.h"
// generated out of BoundBox.pyi

View File

@@ -21,9 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <algorithm>
#include <string>
#include <string_view>
@@ -31,7 +28,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#endif
#include "Builder3D.h"
#include "Console.h"

View File

@@ -314,7 +314,6 @@ SET(FreeCADBase_SRCS
${FreeCADBase_UNITAPI_SRCS}
PyTools.c
PyTools.h
PreCompiled.cpp
PreCompiled.h
)
@@ -334,8 +333,9 @@ else()
endif()
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
ADD_MSVC_PRECOMPILED_HEADER(FreeCADBase PreCompiled.h PreCompiled.cpp FreeCADBase_CPP_SRCS)
target_precompile_headers(FreeCADBase PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
target_sources(FreeCADBase PRIVATE ${FreeCADBase_SRCS})

View File

@@ -20,13 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <iomanip>
#include <sstream>
#endif
#include "Color.h"

View File

@@ -21,9 +21,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <FCConfig.h>
#ifndef _PreComp_
#if defined(FC_OS_WIN32)
#include <windows.h>
#elif defined(FC_OS_LINUX) || defined(FC_OS_MACOSX)
@@ -31,7 +30,6 @@
#endif
#include <cstring>
#include <functional>
#endif
#include "Console.h"
#include "PyObjectBase.h"

View File

@@ -21,15 +21,13 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <FCConfig.h>
#ifndef _PreComp_
#ifdef FC_OS_WIN32
#include <windows.h>
#endif
#include <cstring>
#include <Python.h>
#endif
#include <frameobject.h>

View File

@@ -21,8 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
#include "CoordinateSystem.h"
#include "Exception.h"
#include "Matrix.h"

View File

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

View File

@@ -20,12 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QCoreApplication>
#include <QEvent>
#endif
#include "Debugger.h"
#include "Console.h"

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <cassert>
#include "DualQuaternion.h"

View File

@@ -21,10 +21,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <utility>
#endif
#include <FCConfig.h>
#include "Console.h"
#include "PyObjectBase.h"

View File

@@ -24,6 +24,8 @@
#ifndef BASE_EXCEPTION_H
#define BASE_EXCEPTION_H
#include <FCConfig.h>
#include <csignal>
#include <source_location>
#include <string>

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "ExceptionFactory.h"
#include <CXX/Objects.hxx>

View File

@@ -21,12 +21,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <list>
#endif
#include "Factory.h"
#include "Console.h"

View File

@@ -21,9 +21,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <FCConfig.h>
#ifndef _PreComp_
#include <algorithm>
#include <codecvt>
#include <cstring>
@@ -34,7 +33,6 @@
#else
#include <unistd.h>
#endif
#endif
#include "FileInfo.h"
#include "Exception.h"

View File

@@ -21,8 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
#include "FutureWatcherProgress.h"
using namespace Base;

View File

@@ -20,11 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <sstream>
#endif
#include "GeometryPyCXX.h"
#include "VectorPy.h"

View File

@@ -21,13 +21,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cassert>
#include <iostream>
#endif
#include <QAtomicInt>

View File

@@ -20,9 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <istream>
#include <qglobal.h>

View File

@@ -21,13 +21,10 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <sstream>
#include <boost/regex.hpp>
#endif
#include <FCConfig.h>
#include "Interpreter.h"
#include "Console.h"

View File

@@ -31,6 +31,8 @@
#undef _XOPEN_SOURCE
#endif // (re-)defined in pyconfig.h
#include <FCConfig.h>
#ifdef FC_OS_MACOSX
#undef toupper
#undef tolower

View File

@@ -21,11 +21,8 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cstring>
#include <sstream>
#endif
#include "Matrix.h"
#include "Converter.h"

View File

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

View File

@@ -21,8 +21,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Observer.h"

View File

@@ -22,9 +22,6 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <algorithm>
#include <iostream>
#include <memory>
@@ -40,12 +37,13 @@
#include <sstream>
#include <string>
#include <utility>
#endif
#include <QFileInfo>
#include <QLockFile>
#include <QDir>
#include <FCConfig.h>
#ifdef FC_OS_LINUX
#include <unistd.h>
#endif

View File

@@ -35,6 +35,8 @@
// Python stuff
using PyObject = struct _object;
#include <FCConfig.h>
#ifdef FC_OS_MACOSX
#undef toupper
#undef tolower

View File

@@ -21,10 +21,8 @@
* *
***************************************************************************/
#include <FCConfig.h>
#include "PreCompiled.h"
#ifndef _PreComp_
#ifdef FC_OS_WIN32
#include <xercesc/sax/SAXParseException.hpp>
#endif
@@ -32,7 +30,6 @@
#include <sstream>
#include <string>
#include <utility>
#endif
#ifdef FC_OS_LINUX
#include <unistd.h>

View File

@@ -20,16 +20,11 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <algorithm>
#include <array>
#include <cassert>
#include <codecvt>
#include <locale>
#endif
#include <zipios++/zipinputstream.h>

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <boost/iostreams/stream.hpp>
#include "Persistence.h"

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <fmt/format.h>
#include "Placement.h"

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "GeometryPyCXX.h"
#include "Matrix.h"
#include "PyWrapParseTupleAndKeywords.h"

View File

@@ -1,23 +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_
// Python
#include <Python.h>
@@ -136,7 +134,4 @@
#include <QTimeZone>
#include <QUuid>
#endif //_PreComp_
#endif // BASE_PRECOMPILED_H

View File

@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
// generated out of Precision.pyi
#include "PrecisionPy.h"

View File

@@ -20,8 +20,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include "ProgressIndicator.h"
namespace Base

View File

@@ -20,9 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Exception.h"
#include "ProgressIndicatorPy.h"

View File

@@ -28,8 +28,6 @@
* \date $Date: 2006/01/24 14:26:42 $
*/
#include "PreCompiled.h"
#include "PyExport.h"

View File

@@ -40,6 +40,9 @@
#endif
#include <Python.h>
#include <FCConfig.h>
#ifdef FC_OS_MACOSX
#undef toupper
#undef tolower

View File

@@ -20,12 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <sstream>
#endif
#include "PyObjectBase.h"
#include "Console.h"

View File

@@ -22,7 +22,6 @@
* *
**************************************************************************/
#include "PreCompiled.h"
#include <CXX/Extensions.hxx>
#include <Base/PythonTypeExt.h>

View File

@@ -20,15 +20,12 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <array>
#include <cmath>
#include <limits>
#include <numbers>
#include <sstream>
#include <string>
#endif
#include <fmt/format.h>

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cmath>
#include <functional>
#include <limits>
@@ -29,7 +27,6 @@
#include <sstream>
#include <string>
#include <vector>
#endif
#include "Unit.h"

View File

@@ -20,17 +20,12 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <map>
#include <vector>
#include <iostream>
#include <string>
#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <xercesc/sax2/Attributes.hpp>
#endif
#include <locale>

View File

@@ -20,12 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#endif
#include <boost/algorithm/string/predicate.hpp>
#include "Base/Exception.h"

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "GeometryPyCXX.h"
#include "PyWrapParseTupleAndKeywords.h"
#include "Tools.h"

View File

@@ -20,15 +20,10 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <mutex>
#include <vector>
#include <algorithm>
#include <cstdio>
#endif
#include "Sequencer.h"

View File

@@ -22,7 +22,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "ServiceProvider.h"

View File

@@ -21,10 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include "SmartPtrPy.h"
#include "Interpreter.h"
#include <CXX/Objects.hxx>

View File

@@ -84,7 +84,6 @@
*
**********************************************************************/
#include <PreCompiled.h>
#include "StackWalker.h"
#include <stdio.h>

View File

@@ -20,16 +20,11 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QBuffer>
#include <QIODevice>
#ifdef __GNUC__
#include <cstdint>
#endif
#endif
#include "Stream.h"
#include "Swap.h"

View File

@@ -20,9 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Swap.h"
unsigned short Base::SwapOrder()

View File

@@ -20,9 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <unicode/unistr.h>
#include <unicode/uchar.h>
#include <vector>
@@ -30,7 +27,6 @@
#include <sstream>
#include <QDateTime>
#include <QTimeZone>
#endif
#include "PyExport.h"
#include "Interpreter.h"

View File

@@ -20,14 +20,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <array>
#include <limits>
#include <set>
#endif
#include "Tools2D.h"
#include "Vector3D.h"

View File

@@ -20,9 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "BoundBox.h"
#include "Placement.h"
#include "Tools3D.h"

View File

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

View File

@@ -20,11 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cassert>
#endif
#include "Type.h"
#include "Interpreter.h"

View File

@@ -20,8 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Type.h"
#include "BindingManager.h"

View File

@@ -19,15 +19,12 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <set>
#endif
#include "UniqueNameManager.h"
std::tuple<std::string, std::string, unsigned int, Base::UnlimitedUnsigned>

View File

@@ -19,8 +19,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <algorithm>
#include <array>
#include <cmath>
@@ -28,7 +26,6 @@
#include <limits>
#include <ranges>
#include <vector>
#endif
#include <fmt/format.h>
#include <fmt/ranges.h>

View File

@@ -20,11 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <algorithm>
#include <ranges>
#endif
#include "Unit.h"

View File

@@ -20,10 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <iomanip>
#endif
#include <CXX/WrapPython.h>

View File

@@ -20,10 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <memory>
#endif
#include <CXX/Objects.hxx>

View File

@@ -19,8 +19,6 @@
* *
************************************************************************/
#include "PreCompiled.h"
#include <iomanip>
#include <sstream>
#include <string>

View File

@@ -21,11 +21,7 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QUuid>
#endif
#include <stdexcept>

View File

@@ -20,14 +20,9 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#endif
#include <cmath>
#include <limits>
#include <boost/math/special_functions/fpclassify.hpp>
#include "Vector3D.h"

View File

@@ -20,10 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <sstream>
#endif
#include "GeometryPyCXX.h"
#include "Vector3D.h"

View File

@@ -21,7 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
#include "ViewProj.h"
using namespace Base;

View File

@@ -21,13 +21,10 @@
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <memory>
#include <set>
#include <vector>
#include <string>
#endif
#include <limits>
#include <locale>

View File

@@ -20,13 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <xercesc/framework/MemoryManager.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
#endif
#include "Exception.h"
#include "XMLTools.h"

View File

@@ -21,8 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
#include "ZipHeader.h"
#include <zipios++/backbuffer.h>
#include <zipios++/zipinputstream.h>

View File

@@ -21,7 +21,6 @@
***************************************************************************/
#include "PreCompiled.h"
#include <sstream>
#if (defined(HAVE_SWIG) && (HAVE_SWIG == 1))
#if defined(__clang__)

View File

@@ -2,6 +2,8 @@
#include <gtest/gtest.h>
#include <QString>
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#pragma warning(disable : 4305)
@@ -16,7 +18,6 @@
#include <random>
#include <string>
#include <xercesc/util/PlatformUtils.hpp>
#include <QString>
namespace fs = std::filesystem;