From a6f7cb950a3d7b8a17cbda9e6f19fec9e6e28396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Reitb=C3=B6ck?= Date: Sat, 13 Sep 2025 17:29:53 +0200 Subject: [PATCH] Points: 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/Points/App/AppPoints.cpp | 1 - src/Mod/Points/App/AppPointsPy.cpp | 4 +--- src/Mod/Points/App/CMakeLists.txt | 7 +++---- src/Mod/Points/App/Points.cpp | 4 +--- src/Mod/Points/App/PointsAlgos.cpp | 5 ++--- src/Mod/Points/App/PointsFeature.cpp | 4 +--- src/Mod/Points/App/PointsGrid.cpp | 1 - src/Mod/Points/App/PointsPyImp.cpp | 4 +--- src/Mod/Points/App/PreCompiled.cpp | 24 ---------------------- src/Mod/Points/App/PreCompiled.h | 4 ---- src/Mod/Points/App/Properties.cpp | 4 +--- src/Mod/Points/App/PropertyPointKernel.cpp | 4 +--- src/Mod/Points/App/Structured.cpp | 4 +--- src/Mod/Points/Gui/AppPointsGui.cpp | 1 - src/Mod/Points/Gui/CMakeLists.txt | 13 ++++++------ src/Mod/Points/Gui/Command.cpp | 4 +--- src/Mod/Points/Gui/DlgPointsReadImp.cpp | 1 - src/Mod/Points/Gui/DlgPointsReadImp.h | 2 ++ src/Mod/Points/Gui/PreCompiled.cpp | 24 ---------------------- src/Mod/Points/Gui/PreCompiled.h | 3 --- src/Mod/Points/Gui/ViewProvider.cpp | 3 --- src/Mod/Points/Gui/Workbench.cpp | 1 - 22 files changed, 21 insertions(+), 101 deletions(-) delete mode 100644 src/Mod/Points/App/PreCompiled.cpp delete mode 100644 src/Mod/Points/Gui/PreCompiled.cpp diff --git a/src/Mod/Points/App/AppPoints.cpp b/src/Mod/Points/App/AppPoints.cpp index 06c29385b0..3424377515 100644 --- a/src/Mod/Points/App/AppPoints.cpp +++ b/src/Mod/Points/App/AppPoints.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Points/App/AppPointsPy.cpp b/src/Mod/Points/App/AppPointsPy.cpp index c0e7cf9ba6..4fbbb775b5 100644 --- a/src/Mod/Points/App/AppPointsPy.cpp +++ b/src/Mod/Points/App/AppPointsPy.cpp @@ -20,10 +20,8 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include -#endif + #include #include diff --git a/src/Mod/Points/App/CMakeLists.txt b/src/Mod/Points/App/CMakeLists.txt index dc881659d0..6bd76c72dd 100644 --- a/src/Mod/Points/App/CMakeLists.txt +++ b/src/Mod/Points/App/CMakeLists.txt @@ -49,7 +49,6 @@ SET(Points_SRCS PointsFeature.h PointsGrid.cpp PointsGrid.h - PreCompiled.cpp PreCompiled.h Properties.cpp Properties.h @@ -65,9 +64,9 @@ set(Points_Scripts ) if(FREECAD_USE_PCH) - add_definitions(-D_PreComp_) - GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Points_SRCS}) - ADD_MSVC_PRECOMPILED_HEADER(Points PreCompiled.h PreCompiled.cpp PCH_SRCS) + target_precompile_headers(Points PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) endif(FREECAD_USE_PCH) target_sources(Points PRIVATE ${Points_SRCS} ${Points_Scripts}) diff --git a/src/Mod/Points/App/Points.cpp b/src/Mod/Points/App/Points.cpp index 169f29491a..58ebb82860 100644 --- a/src/Mod/Points/App/Points.cpp +++ b/src/Mod/Points/App/Points.cpp @@ -20,13 +20,11 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include #include -#endif + #include #include diff --git a/src/Mod/Points/App/PointsAlgos.cpp b/src/Mod/Points/App/PointsAlgos.cpp index b09781805d..e39b19eb0d 100644 --- a/src/Mod/Points/App/PointsAlgos.cpp +++ b/src/Mod/Points/App/PointsAlgos.cpp @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ +#include + #ifdef FC_OS_LINUX #include #endif @@ -32,7 +32,6 @@ #include #include // needed for compilation on some systems #include -#endif #include #include diff --git a/src/Mod/Points/App/PointsFeature.cpp b/src/Mod/Points/App/PointsFeature.cpp index 3467a29518..898586c0b9 100644 --- a/src/Mod/Points/App/PointsFeature.cpp +++ b/src/Mod/Points/App/PointsFeature.cpp @@ -20,11 +20,9 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include -#endif + #include "PointsFeature.h" diff --git a/src/Mod/Points/App/PointsGrid.cpp b/src/Mod/Points/App/PointsGrid.cpp index 6b43641d5a..1674313f9f 100644 --- a/src/Mod/Points/App/PointsGrid.cpp +++ b/src/Mod/Points/App/PointsGrid.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include "PointsGrid.h" diff --git a/src/Mod/Points/App/PointsPyImp.cpp b/src/Mod/Points/App/PointsPyImp.cpp index f52e2ef171..2d201b8d23 100644 --- a/src/Mod/Points/App/PointsPyImp.cpp +++ b/src/Mod/Points/App/PointsPyImp.cpp @@ -20,10 +20,8 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include -#endif + #include #include diff --git a/src/Mod/Points/App/PreCompiled.cpp b/src/Mod/Points/App/PreCompiled.cpp deleted file mode 100644 index 7b200a1bf2..0000000000 --- a/src/Mod/Points/App/PreCompiled.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2002 Jürgen Riegel * - * * - * 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/Points/App/PreCompiled.h b/src/Mod/Points/App/PreCompiled.h index 3f4dfc9306..cd3633efe4 100644 --- a/src/Mod/Points/App/PreCompiled.h +++ b/src/Mod/Points/App/PreCompiled.h @@ -25,8 +25,6 @@ #include -#ifdef _PreComp_ - // standard #include @@ -48,6 +46,4 @@ // Qt #include -#endif //_PreComp_ - #endif diff --git a/src/Mod/Points/App/Properties.cpp b/src/Mod/Points/App/Properties.cpp index 889de8561d..23262d21e5 100644 --- a/src/Mod/Points/App/Properties.cpp +++ b/src/Mod/Points/App/Properties.cpp @@ -20,13 +20,11 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include #include -#endif + #include #include diff --git a/src/Mod/Points/App/PropertyPointKernel.cpp b/src/Mod/Points/App/PropertyPointKernel.cpp index 5a4c04877c..cb5e2d02bf 100644 --- a/src/Mod/Points/App/PropertyPointKernel.cpp +++ b/src/Mod/Points/App/PropertyPointKernel.cpp @@ -20,13 +20,11 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include -#endif + #include #include diff --git a/src/Mod/Points/App/Structured.cpp b/src/Mod/Points/App/Structured.cpp index 11cf94091b..e62f7d1282 100644 --- a/src/Mod/Points/App/Structured.cpp +++ b/src/Mod/Points/App/Structured.cpp @@ -20,11 +20,9 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include -#endif + #include "Structured.h" diff --git a/src/Mod/Points/Gui/AppPointsGui.cpp b/src/Mod/Points/Gui/AppPointsGui.cpp index 359430780f..ae68b30b85 100644 --- a/src/Mod/Points/Gui/AppPointsGui.cpp +++ b/src/Mod/Points/Gui/AppPointsGui.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Points/Gui/CMakeLists.txt b/src/Mod/Points/Gui/CMakeLists.txt index 727f691a57..63232411b8 100644 --- a/src/Mod/Points/Gui/CMakeLists.txt +++ b/src/Mod/Points/Gui/CMakeLists.txt @@ -32,7 +32,6 @@ SET(PointsGui_SRCS ${Resource_SRCS} AppPointsGui.cpp Command.cpp - PreCompiled.cpp PreCompiled.h ViewProvider.cpp ViewProvider.h @@ -48,18 +47,18 @@ SET(PointsGuiIcon_SVG Resources/icons/PointsWorkbench.svg ) -if(FREECAD_USE_PCH) - add_definitions(-D_PreComp_) - GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${PointsGui_SRCS}) - ADD_MSVC_PRECOMPILED_HEADER(PointsGui PreCompiled.h PreCompiled.cpp PCH_SRCS) -endif(FREECAD_USE_PCH) - add_library(PointsGui SHARED ${PointsGui_SRCS} ${PointsGui_Scripts} ${PointsGuiIcon_SVG} ) +if(FREECAD_USE_PCH) + target_precompile_headers(PointsGui PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) +endif(FREECAD_USE_PCH) + target_include_directories( PointsGui PRIVATE diff --git a/src/Mod/Points/Gui/Command.cpp b/src/Mod/Points/Gui/Command.cpp index 0663980f2c..266ef1ae68 100644 --- a/src/Mod/Points/Gui/Command.cpp +++ b/src/Mod/Points/Gui/Command.cpp @@ -20,13 +20,11 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include #include #include -#endif + #include #include diff --git a/src/Mod/Points/Gui/DlgPointsReadImp.cpp b/src/Mod/Points/Gui/DlgPointsReadImp.cpp index ff9f0384d5..c69c9ae510 100644 --- a/src/Mod/Points/Gui/DlgPointsReadImp.cpp +++ b/src/Mod/Points/Gui/DlgPointsReadImp.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include "DlgPointsReadImp.h" #include "ui_DlgPointsRead.h" diff --git a/src/Mod/Points/Gui/DlgPointsReadImp.h b/src/Mod/Points/Gui/DlgPointsReadImp.h index abe5103fcb..84c44436f9 100644 --- a/src/Mod/Points/Gui/DlgPointsReadImp.h +++ b/src/Mod/Points/Gui/DlgPointsReadImp.h @@ -23,6 +23,8 @@ #ifndef POINTSGUI_DLGREADPOINTS_H #define POINTSGUI_DLGREADPOINTS_H +#include + #include #include diff --git a/src/Mod/Points/Gui/PreCompiled.cpp b/src/Mod/Points/Gui/PreCompiled.cpp deleted file mode 100644 index 7b200a1bf2..0000000000 --- a/src/Mod/Points/Gui/PreCompiled.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2002 Jürgen Riegel * - * * - * 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/Points/Gui/PreCompiled.h b/src/Mod/Points/Gui/PreCompiled.h index f86249a912..7c3eac22e5 100644 --- a/src/Mod/Points/Gui/PreCompiled.h +++ b/src/Mod/Points/Gui/PreCompiled.h @@ -25,7 +25,6 @@ #include -#ifdef _PreComp_ // STL #include @@ -53,6 +52,4 @@ #include #include -#endif //_PreComp_ - #endif // POINTSGUI_PRECOMPILED_H diff --git a/src/Mod/Points/Gui/ViewProvider.cpp b/src/Mod/Points/Gui/ViewProvider.cpp index 8f263f45b2..291ea8a93d 100644 --- a/src/Mod/Points/Gui/ViewProvider.cpp +++ b/src/Mod/Points/Gui/ViewProvider.cpp @@ -20,8 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include @@ -35,7 +33,6 @@ #include #include #include -#endif #include #include diff --git a/src/Mod/Points/Gui/Workbench.cpp b/src/Mod/Points/Gui/Workbench.cpp index 1b16f7b273..14ff49f6f5 100644 --- a/src/Mod/Points/Gui/Workbench.cpp +++ b/src/Mod/Points/Gui/Workbench.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include