From abc6b9e7d06b360e47c0d878bd231a1faeff2be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Reitb=C3=B6ck?= Date: Tue, 23 Sep 2025 21:47:27 +0200 Subject: [PATCH] Test: 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/Test/Gui/AppTestGui.cpp | 1 - src/Mod/Test/Gui/CMakeLists.txt | 13 ++++++------- src/Mod/Test/Gui/PreCompiled.cpp | 23 ----------------------- src/Mod/Test/Gui/PreCompiled.h | 6 +----- src/Mod/Test/Gui/UnitTestImp.cpp | 4 +--- src/Mod/Test/Gui/UnitTestPy.cpp | 4 +--- 6 files changed, 9 insertions(+), 42 deletions(-) delete mode 100644 src/Mod/Test/Gui/PreCompiled.cpp diff --git a/src/Mod/Test/Gui/AppTestGui.cpp b/src/Mod/Test/Gui/AppTestGui.cpp index 93e977087f..12810e5dcd 100644 --- a/src/Mod/Test/Gui/AppTestGui.cpp +++ b/src/Mod/Test/Gui/AppTestGui.cpp @@ -20,7 +20,6 @@ * * ***************************************************************************/ -#include "PreCompiled.h" #include #include diff --git a/src/Mod/Test/Gui/CMakeLists.txt b/src/Mod/Test/Gui/CMakeLists.txt index dbc3a9d6ef..240c645f69 100644 --- a/src/Mod/Test/Gui/CMakeLists.txt +++ b/src/Mod/Test/Gui/CMakeLists.txt @@ -32,7 +32,6 @@ SET(TestGui_SRCS ${Dialogs_SRCS} ${Resource_SRCS} AppTestGui.cpp - PreCompiled.cpp PreCompiled.h ) SET(TestGuiPy_SRCS @@ -43,14 +42,14 @@ SET(TestGuiIcon_SVG Resources/icons/TestWorkbench.svg ) -if(FREECAD_USE_PCH) - add_definitions(-D_PreComp_) - GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${TestGui_SRCS}) - ADD_MSVC_PRECOMPILED_HEADER(QtUnitGui PreCompiled.h PreCompiled.cpp PCH_SRCS) -endif(FREECAD_USE_PCH) - add_library(QtUnitGui SHARED ${TestGui_SRCS} ${TestGuiPy_SRCS} ${TestGuiIcon_SVG}) +if(FREECAD_USE_PCH) + target_precompile_headers(QtUnitGui PRIVATE + $<$:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h"> + ) +endif(FREECAD_USE_PCH) + target_include_directories( QtUnitGui PRIVATE diff --git a/src/Mod/Test/Gui/PreCompiled.cpp b/src/Mod/Test/Gui/PreCompiled.cpp deleted file mode 100644 index 01419be663..0000000000 --- a/src/Mod/Test/Gui/PreCompiled.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2006 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/Test/Gui/PreCompiled.h b/src/Mod/Test/Gui/PreCompiled.h index b88a01c6ed..b9024a2dd3 100644 --- a/src/Mod/Test/Gui/PreCompiled.h +++ b/src/Mod/Test/Gui/PreCompiled.h @@ -25,13 +25,9 @@ #include -#ifdef _PreComp_ - // Qt Toolkit #include #include #include -#endif //_PreComp_ - -#endif // __PRECOMPILED_GUI__ +#endif // TEST_GUI_PRECOMPILED_H diff --git a/src/Mod/Test/Gui/UnitTestImp.cpp b/src/Mod/Test/Gui/UnitTestImp.cpp index 39e7891689..f021d62e35 100644 --- a/src/Mod/Test/Gui/UnitTestImp.cpp +++ b/src/Mod/Test/Gui/UnitTestImp.cpp @@ -20,11 +20,9 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include -#endif + #include #include diff --git a/src/Mod/Test/Gui/UnitTestPy.cpp b/src/Mod/Test/Gui/UnitTestPy.cpp index f2ec12814c..b8d98422ba 100644 --- a/src/Mod/Test/Gui/UnitTestPy.cpp +++ b/src/Mod/Test/Gui/UnitTestPy.cpp @@ -20,11 +20,9 @@ * * ***************************************************************************/ -#include "PreCompiled.h" -#ifndef _PreComp_ #include #include -#endif + #include