From a059456d860c7d019bbcf703699fe90fc01b8b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Reitb=C3=B6ck?= Date: Sun, 21 Sep 2025 17:19:17 +0200 Subject: [PATCH] Draft: 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/Draft/App/AppDraftUtils.cpp | 1 - src/Mod/Draft/App/AppDraftUtilsPy.cpp | 1 - src/Mod/Draft/App/CMakeLists.txt | 8 +++++++- src/Mod/Draft/App/PreCompiled.cpp | 23 ----------------------- 4 files changed, 7 insertions(+), 26 deletions(-) delete mode 100644 src/Mod/Draft/App/PreCompiled.cpp diff --git a/src/Mod/Draft/App/AppDraftUtils.cpp b/src/Mod/Draft/App/AppDraftUtils.cpp index 3bfddd9884..a6742cd5fd 100644 --- a/src/Mod/Draft/App/AppDraftUtils.cpp +++ b/src/Mod/Draft/App/AppDraftUtils.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Draft/App/AppDraftUtilsPy.cpp b/src/Mod/Draft/App/AppDraftUtilsPy.cpp index a0b831c097..a0ab38b580 100644 --- a/src/Mod/Draft/App/AppDraftUtilsPy.cpp +++ b/src/Mod/Draft/App/AppDraftUtilsPy.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Draft/App/CMakeLists.txt b/src/Mod/Draft/App/CMakeLists.txt index 993cabed86..da38dcbce3 100644 --- a/src/Mod/Draft/App/CMakeLists.txt +++ b/src/Mod/Draft/App/CMakeLists.txt @@ -11,11 +11,17 @@ set(DraftUtils_LIBS SET(DraftUtils_SRCS AppDraftUtils.cpp AppDraftUtilsPy.cpp - PreCompiled.cpp PreCompiled.h ) add_library(DraftUtils SHARED ${DraftUtils_SRCS}) + +if(FREECAD_USE_PCH) + target_precompile_headers(DraftUtils PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) +endif(FREECAD_USE_PCH) + target_include_directories( DraftUtils PRIVATE diff --git a/src/Mod/Draft/App/PreCompiled.cpp b/src/Mod/Draft/App/PreCompiled.cpp deleted file mode 100644 index 2432ed0264..0000000000 --- a/src/Mod/Draft/App/PreCompiled.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2015 Yorik van Havre * - * * - * 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"