From fa2089d877f7e4ba740e4e52b7fc36ab8b7ffebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Reitb=C3=B6ck?= Date: Sat, 13 Sep 2025 20:22:10 +0200 Subject: [PATCH] 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 " from sources, also there is no need for the "#ifdef _PreComp_" anymore --- src/Mod/Web/App/AppWeb.cpp | 3 --- src/Mod/Web/App/CMakeLists.txt | 14 +++++++------- src/Mod/Web/App/PreCompiled.cpp | 23 ----------------------- src/Mod/Web/App/PreCompiled.h | 4 ---- src/Mod/Web/App/Server.cpp | 4 +--- 5 files changed, 8 insertions(+), 40 deletions(-) delete mode 100644 src/Mod/Web/App/PreCompiled.cpp diff --git a/src/Mod/Web/App/AppWeb.cpp b/src/Mod/Web/App/AppWeb.cpp index fff8c4c787..5e226dc6e0 100644 --- a/src/Mod/Web/App/AppWeb.cpp +++ b/src/Mod/Web/App/AppWeb.cpp @@ -20,11 +20,8 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include -#endif #include #include diff --git a/src/Mod/Web/App/CMakeLists.txt b/src/Mod/Web/App/CMakeLists.txt index e48746090c..bb809a309e 100644 --- a/src/Mod/Web/App/CMakeLists.txt +++ b/src/Mod/Web/App/CMakeLists.txt @@ -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 + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) +endif(FREECAD_USE_PCH) + if (FREECAD_WARN_ERROR) target_compile_warn_error(Web) endif() diff --git a/src/Mod/Web/App/PreCompiled.cpp b/src/Mod/Web/App/PreCompiled.cpp deleted file mode 100644 index b25d69a63f..0000000000 --- a/src/Mod/Web/App/PreCompiled.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2014 Werner Mayer * - * * - * 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" diff --git a/src/Mod/Web/App/PreCompiled.h b/src/Mod/Web/App/PreCompiled.h index 02f5cf78c2..b33f4d2376 100644 --- a/src/Mod/Web/App/PreCompiled.h +++ b/src/Mod/Web/App/PreCompiled.h @@ -25,8 +25,6 @@ #include -#ifdef _PreComp_ - // standard #include @@ -38,6 +36,4 @@ #include #include -#endif //_PreComp_ - #endif diff --git a/src/Mod/Web/App/Server.cpp b/src/Mod/Web/App/Server.cpp index 853cb54774..a7f886ae66 100644 --- a/src/Mod/Web/App/Server.cpp +++ b/src/Mod/Web/App/Server.cpp @@ -20,13 +20,11 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include #include -#endif + #include #include