Web: 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 20:22:10 +02:00
parent 13c8b52a6a
commit f323323e8b
5 changed files with 8 additions and 40 deletions

View File

@@ -20,11 +20,8 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#include <sstream>
#endif
#include <Base/Console.h>
#include <Base/Interpreter.h>

View File

@@ -5,18 +5,11 @@ set(Web_LIBS
SET(Web_SRCS
AppWeb.cpp
PreCompiled.cpp
PreCompiled.h
Server.cpp
Server.h
)
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Web_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(Web PreCompiled.h PreCompiled.cpp PCH_SRCS)
endif(FREECAD_USE_PCH)
add_library(Web SHARED ${Web_SRCS})
target_include_directories(
@@ -32,6 +25,13 @@ target_include_directories(
${QtNetwork_INCLUDE_DIRS}
)
target_link_libraries(Web ${Web_LIBS})
if(FREECAD_USE_PCH)
target_precompile_headers(Web PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">
)
endif(FREECAD_USE_PCH)
if (FREECAD_WARN_ERROR)
target_compile_warn_error(Web)
endif()

View File

@@ -1,23 +0,0 @@
/***************************************************************************
* Copyright (c) 2014 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_
// standard
#include <stdexcept>
@@ -38,6 +36,4 @@
#include <QCoreApplication>
#include <QTcpSocket>
#endif //_PreComp_
#endif

View File

@@ -20,13 +20,11 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QCoreApplication>
#include <QTcpSocket>
#include <memory>
#include <stdexcept>
#endif
#include <Base/Exception.h>
#include <Base/Interpreter.h>