Cloud: 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 17:17:29 +02:00
parent 015896f4e4
commit 550786e6b0
11 changed files with 63 additions and 80 deletions

View File

@@ -20,12 +20,10 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <FCConfig.h>
#ifndef _PreComp_
#include <limits>
#endif
#if defined(FC_OS_WIN32)
#include <Windows.h>

View File

@@ -27,6 +27,8 @@
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <Mod/Cloud/CloudGlobal.h>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/framework/MemBufInputSource.hpp>
#include <xercesc/framework/XMLPScanToken.hpp>

View File

@@ -19,13 +19,18 @@ set(Cloud_LIBS
SET(Cloud_SRCS
AppCloud.cpp
PreCompiled.cpp
PreCompiled.h
)
add_library(Cloud SHARED ${Cloud_SRCS})
target_link_libraries(Cloud ${Cloud_LIBS})
if(FREECAD_USE_PCH)
target_precompile_headers(Cloud PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
SET_BIN_DIR(Cloud Cloud /Mod/Cloud)
SET_PYTHON_PREFIX_SUFFIX(Cloud)

View File

@@ -26,14 +26,6 @@
#include <FCConfig.h>
// Exporting of App classes
#ifdef FC_OS_WIN32
#define CloudAppExport __declspec(dllexport)
#else // for Linux
#define CloudAppExport
#endif
#ifdef _PreComp_
// standard
#include <cassert>
@@ -55,6 +47,4 @@
// Xerces
#include <xercesc/util/XercesDefs.hpp>
#endif //_PreComp_
#endif

View File

@@ -1,24 +1,47 @@
/***************************************************************************
* Copyright (c) 2019 Jean-Marie Verdun jmverdun3@gmail.com *
* *
* 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"
/***************************************************************************
* Copyright (c) 2021 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 *
* *
***************************************************************************/
#ifndef CLOUD_GLOBAL_H
#define CLOUD_GLOBAL_H
#include <FCGlobal.h>
// Cloud
#ifndef CloudAppExport
#ifdef CloudApp_EXPORTS
#define CloudAppExport FREECAD_DECL_EXPORT
#else
#define CloudAppExport FREECAD_DECL_IMPORT
#endif
#endif
// Cloud
#ifndef CloudGuiExport
#ifdef CloudGui_EXPORTS
#define CloudGuiExport FREECAD_DECL_EXPORT
#else
#define CloudGuiExport FREECAD_DECL_IMPORT
#endif
#endif
#endif // CLOUD_GLOBAL_H

View File

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

View File

@@ -15,7 +15,6 @@ SET(CloudGui_SRCS
${Cloud_QRC_SRCS}
AppCloudGui.cpp
Command.cpp
PreCompiled.cpp
PreCompiled.h
Workbench.cpp
Workbench.h
@@ -28,6 +27,12 @@ SET(Cloud_SVG
add_library(CloudGui SHARED ${CloudGui_SRCS} ${Cloud_SVG})
target_link_libraries(CloudGui ${CloudGui_LIBS})
if(FREECAD_USE_PCH)
target_precompile_headers(CloudGui PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
fc_copy_sources(CloudGui "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Cloud" ${Cloud_SVG})
SET_BIN_DIR(CloudGui CloudGui /Mod/Cloud)

View File

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

View File

@@ -1,24 +0,0 @@
/***************************************************************************
* Copyright (c) 2019 Jean-Marie Verdun jmverdun3@gmail.com *
* *
* 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>
// Importing of App classes
#ifdef FC_OS_WIN32
#define CloudAppExport __declspec(dllimport)
#define CloudGuiExport __declspec(dllexport)
#else // for Linux
#define CloudAppExport
#define CloudGuiExport
#endif
#ifdef _PreComp_
// standard
#include <cassert>
#include <cstdio>
@@ -60,6 +49,4 @@
// Qt Toolkit
#include <Gui/QtAll.h>
#endif //_PreComp_
#endif // GUI_PRECOMPILED_H

View File

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