From c6d001882d1ff2c4c301c178a6c7bdedee94284b Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 20 Dec 2020 14:26:33 +0000 Subject: [PATCH] implement PCH build option for components Signed-off-by: Ivailo Monev --- CMakeLists.txt | 3 ++ appveyor.yml | 2 +- cmake/modules/KatieBuildMacros.cmake | 11 ++++++ src/core/CMakeLists.txt | 2 + src/core/qt_pch.h | 51 ++++++++++++++++++++++++++ src/dbus/CMakeLists.txt | 2 + src/declarative/CMakeLists.txt | 2 + src/designer/CMakeLists.txt | 1 + src/designer/components/CMakeLists.txt | 1 + src/gui/CMakeLists.txt | 2 + src/network/CMakeLists.txt | 2 + src/script/CMakeLists.txt | 2 + src/scripttools/CMakeLists.txt | 2 + src/sql/CMakeLists.txt | 2 + src/svg/CMakeLists.txt | 2 + src/test/CMakeLists.txt | 2 + src/uitools/CMakeLists.txt | 2 + src/xml/CMakeLists.txt | 2 + 18 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/core/qt_pch.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7124eba74..8ef91ea7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,9 @@ add_feature_info(utils KATIE_UTILS "build maintainance utilities") option(KATIE_ALLINONE "Build targets from single source file" OFF) add_feature_info(allinone KATIE_ALLINONE "build targets from single source file") +option(KATIE_PCH "Build components with pre-compiled header" OFF) +add_feature_info(pch KATIE_PCH "build components with pre-compiled header") + option(WITH_ACCESSIBILITY "Build accessibility support" ON) add_feature_info(accessibility WITH_ACCESSIBILITY "build accessibility support") diff --git a/appveyor.yml b/appveyor.yml index 93107b972..8fe7fecde 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,7 +18,7 @@ build_script: export CXXFLAGS="$CXXFLAGS -w" - cmake . -Wno-dev -DKATIE_TESTS=ON -DKATIE_BENCHMARKS=ON -DKATIE_UTILS=ON -DKATIE_ALLINONE=ON + cmake . -Wno-dev -DKATIE_TESTS=ON -DKATIE_BENCHMARKS=ON -DKATIE_UTILS=ON -DKATIE_ALLINONE=ON -DKATIE_PCH=ON make -j $(nproc || echo 1) diff --git a/cmake/modules/KatieBuildMacros.cmake b/cmake/modules/KatieBuildMacros.cmake index de5accdfa..659f77f17 100644 --- a/cmake/modules/KatieBuildMacros.cmake +++ b/cmake/modules/KatieBuildMacros.cmake @@ -320,6 +320,17 @@ macro(KATIE_SETUP_OBJECT FORTARGET) endforeach() endmacro() +# a macro to setup pre-compiled header for target +macro(KATIE_SETUP_PCH FORTARGET) + if(KATIE_PCH) + if (NOT CMAKE_VERSION VERSION_LESS "3.16.0") + target_precompile_headers(${FORTARGET} PRIVATE "${CMAKE_SOURCE_DIR}/src/core/qt_pch.h") + else() + message(FATAL_ERROR "Pre-compiled headers option requires CMake v3.16+") + endif() + endif() +endmacro() + # a macro to remove conditional code from headers which is only relevant to the # process of building Katie itself macro(KATIE_OPTIMIZE_HEADERS DIR) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 9108b16d2..964a884bf 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -461,6 +461,8 @@ set_target_properties(KtCore PROPERTIES EXPORT_NAME Core ) +katie_setup_pch(KtCore) + install( TARGETS KtCore EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/src/core/qt_pch.h b/src/core/qt_pch.h new file mode 100644 index 000000000..389a9f84d --- /dev/null +++ b/src/core/qt_pch.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016-2020 Ivailo Monev +** +** This file is part of the QtCore module of the Katie Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT_PCH_H +#define QT_PCH_H + +#if defined __cplusplus +# include "qplatformdefs.h" +# include "qcoreapplication.h" +# include "qlist.h" +# include "qvariant.h" +# include "qobject.h" +# include "qregexp.h" +# include "qstring.h" +# include "qstringlist.h" +# include "qtextcodec.h" +#else +# include +#endif + +#endif diff --git a/src/dbus/CMakeLists.txt b/src/dbus/CMakeLists.txt index 68c4472f0..c5a23274a 100644 --- a/src/dbus/CMakeLists.txt +++ b/src/dbus/CMakeLists.txt @@ -109,6 +109,8 @@ set_target_properties(KtDBus PROPERTIES EXPORT_NAME DBus ) +katie_setup_pch(KtDBus) + install( TARGETS KtDBus EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/src/declarative/CMakeLists.txt b/src/declarative/CMakeLists.txt index 316137fd3..e736d83de 100644 --- a/src/declarative/CMakeLists.txt +++ b/src/declarative/CMakeLists.txt @@ -335,6 +335,8 @@ set_target_properties(KtDeclarative PROPERTIES EXPORT_NAME Declarative ) +katie_setup_pch(KtDeclarative) + install( TARGETS KtDeclarative EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/src/designer/CMakeLists.txt b/src/designer/CMakeLists.txt index 430ee8eb9..f1ea35b8e 100644 --- a/src/designer/CMakeLists.txt +++ b/src/designer/CMakeLists.txt @@ -291,6 +291,7 @@ set_target_properties(KtDesigner PROPERTIES ) katie_setup_object(KtDesigner sharedqtgradienteditor sharedqtpropertybrowser sharedfindwidget) +katie_setup_pch(KtDesigner) install( TARGETS KtDesigner diff --git a/src/designer/components/CMakeLists.txt b/src/designer/components/CMakeLists.txt index 00b987770..652014d79 100644 --- a/src/designer/components/CMakeLists.txt +++ b/src/designer/components/CMakeLists.txt @@ -226,6 +226,7 @@ set_target_properties(KtDesignerComponents PROPERTIES ) katie_setup_object(KtDesignerComponents sharedfindwidget sharedqtpropertybrowser sharedqtgradienteditor) +katie_setup_pch(KtDesignerComponents) install( TARGETS KtDesignerComponents diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 4b5564057..9aa6071f7 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1056,6 +1056,8 @@ set_target_properties(KtGui PROPERTIES EXPORT_NAME Gui ) +katie_setup_pch(KtGui) + install( TARGETS KtGui EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index 1648b2e51..33e266122 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -226,6 +226,8 @@ set_target_properties(KtNetwork PROPERTIES EXPORT_NAME Network ) +katie_setup_pch(KtNetwork) + install( TARGETS KtNetwork EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/src/script/CMakeLists.txt b/src/script/CMakeLists.txt index 367978d4b..535a3b4cc 100644 --- a/src/script/CMakeLists.txt +++ b/src/script/CMakeLists.txt @@ -244,6 +244,8 @@ set_target_properties(KtScript PROPERTIES EXPORT_NAME Script ) +katie_setup_pch(KtScript) + install( TARGETS KtScript EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/src/scripttools/CMakeLists.txt b/src/scripttools/CMakeLists.txt index 63909bdf2..d44b768f8 100644 --- a/src/scripttools/CMakeLists.txt +++ b/src/scripttools/CMakeLists.txt @@ -181,6 +181,8 @@ set_target_properties(KtScriptTools PROPERTIES EXPORT_NAME ScriptTools ) +katie_setup_pch(KtScriptTools) + install( TARGETS KtScriptTools EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/src/sql/CMakeLists.txt b/src/sql/CMakeLists.txt index eec43432d..d8aae6588 100644 --- a/src/sql/CMakeLists.txt +++ b/src/sql/CMakeLists.txt @@ -81,6 +81,8 @@ set_target_properties(KtSql PROPERTIES EXPORT_NAME Sql ) +katie_setup_pch(KtSql) + install( TARGETS KtSql EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/src/svg/CMakeLists.txt b/src/svg/CMakeLists.txt index 84f19f32b..f7f4f87ce 100644 --- a/src/svg/CMakeLists.txt +++ b/src/svg/CMakeLists.txt @@ -63,6 +63,8 @@ set_target_properties(KtSvg PROPERTIES EXPORT_NAME Svg ) +katie_setup_pch(KtSvg) + install( TARGETS KtSvg EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index fbefe7165..84769a15d 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -108,6 +108,8 @@ set_target_properties(KtTest PROPERTIES EXPORT_NAME Test ) +katie_setup_pch(KtTest) + install( TARGETS KtTest EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/src/uitools/CMakeLists.txt b/src/uitools/CMakeLists.txt index 1d649343d..97ae6cfbd 100644 --- a/src/uitools/CMakeLists.txt +++ b/src/uitools/CMakeLists.txt @@ -57,6 +57,8 @@ set_target_properties(KtUiTools PROPERTIES EXPORT_NAME UiTools ) +katie_setup_pch(KtUiTools) + install( TARGETS KtUiTools EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS} diff --git a/src/xml/CMakeLists.txt b/src/xml/CMakeLists.txt index bc619bdba..ac5f6b005 100644 --- a/src/xml/CMakeLists.txt +++ b/src/xml/CMakeLists.txt @@ -41,6 +41,8 @@ set_target_properties(KtXml PROPERTIES EXPORT_NAME Xml ) +katie_setup_pch(KtXml) + install( TARGETS KtXml EXPORT KatieTargets ${INSTALL_TARGETS_DEFAULT_ARGS}