From 41e55025e17b2f8e17294bc8cff7b47e8f6af1f7 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 1 Jan 2014 11:35:56 +0100 Subject: Generate forward headers. Install them in the proper directory. Let cmake find them. Had to rename conversion_check.h to conversioncheck.h Had to improve the scripts to support multiple libs in one framework :) --- src/core/CMakeLists.txt | 42 ++++++++------- src/core/conversion_check.h | 124 -------------------------------------------- src/core/conversioncheck.h | 124 ++++++++++++++++++++++++++++++++++++++++++++ src/core/kconfiggroup.cpp | 4 +- src/core/kconfiggroup.h | 2 +- src/gui/CMakeLists.txt | 31 ++++++----- 6 files changed, 167 insertions(+), 160 deletions(-) delete mode 100644 src/core/conversion_check.h create mode 100644 src/core/conversioncheck.h (limited to 'src') diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ea272d31..8b6e52e8 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -19,35 +19,39 @@ add_library(KF5ConfigCore ${libkconfigcore_SRCS}) generate_export_header(KF5ConfigCore BASE_NAME KConfigCore) add_library(KF5::ConfigCore ALIAS KF5ConfigCore) +target_include_directories(KF5ConfigCore INTERFACE "$" "$") + target_link_libraries(KF5ConfigCore PUBLIC Qt5::Core) if(WIN32) target_link_libraries(KF5ConfigCore PRIVATE ${KDEWIN_LIBRARIES}) endif() -if(IS_ABSOLUTE "${INCLUDE_INSTALL_DIR}") - target_include_directories(KF5ConfigCore INTERFACE "$" ) -else() - target_include_directories(KF5ConfigCore INTERFACE "$" ) -endif() - set_target_properties(KF5ConfigCore PROPERTIES VERSION ${KCONFIG_VERSION_STRING} SOVERSION ${KCONFIG_SOVERSION} EXPORT_NAME ConfigCore ) +ecm_generate_headers( + KAuthorized + KConfig + KConfigBackend + KConfigBase + KConfigGroup + KDesktopFile + KSharedConfig + KCoreConfigSkeleton + KEMailSettings + ConversionCheck + + MODULE_NAME KConfigCore + REQUIRED_HEADERS KConfigCore_HEADERS +) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/KConfigCore DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel) + install(TARGETS KF5ConfigCore EXPORT KF5ConfigTargets ${INSTALL_TARGETS_DEFAULT_ARGS}) -install( FILES - ${CMAKE_CURRENT_BINARY_DIR}/kconfigcore_export.h - conversion_check.h - kconfig.h - #kconfigbackend.h re-enable post-API review and implementation (4.2?) - kconfigbase.h - kconfiggroup.h - kdesktopfile.h - ksharedconfig.h - kcoreconfigskeleton.h - kauthorized.h - kemailsettings.h - DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/kconfigcore_export.h + ${KConfigCore_HEADERS} + DESTINATION ${INCLUDE_INSTALL_DIR}/kconfigcore COMPONENT Devel ) diff --git a/src/core/conversion_check.h b/src/core/conversion_check.h deleted file mode 100644 index 55bd8826..00000000 --- a/src/core/conversion_check.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - This file is part of the KDE libraries - Copyright (c) 2006 Thomas Braxton - - 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef CONVERSION_CHECK_H -#define CONVERSION_CHECK_H - -#include -#include -#include -#include -#include -#include - -class QColor; -class QFont; - -namespace ConversionCheck -{ - -// used to distinguish between supported/unsupported types -struct supported { }; -struct unsupported { }; - -// traits type class to define support for constraints -template -struct QVconvertible { - typedef unsupported toQString; - typedef unsupported toQVariant; -}; - -// constraint classes -template -struct type_toQString { - void constraint() - { - supported x = y; - Q_UNUSED(x); - } - typename QVconvertible::toQString y; -}; - -template -struct type_toQVariant { - void constraint() - { - supported x = y; - Q_UNUSED(x); - } - typename QVconvertible::toQVariant y; -}; - -// check if T is convertible to QString thru QVariant -// if not supported can't be used in QList functions -template -inline void to_QString() -{ - void (type_toQString::*x)() = &type_toQString::constraint; - Q_UNUSED(x); -} - -// check if T is convertible to QVariant & supported in readEntry/writeEntry -template -inline void to_QVariant() -{ - void (type_toQVariant::*x)() = &type_toQVariant::constraint; - Q_UNUSED(x); -} - -// define for all types handled in readEntry/writeEntry -// string_support - is supported by QVariant(type).toString(), -// can be used in QList functions -// variant_support - has a QVariant constructor -#define QVConversions(type, string_support, variant_support) \ - template <> struct QVconvertible {\ - typedef string_support toQString;\ - typedef variant_support toQVariant;\ - } - -// The only types needed here are the types handled in readEntry/writeEntry -// the default QVconvertible will take care of the rest. -QVConversions(bool, supported, supported); -QVConversions(int, supported, supported); -QVConversions(unsigned int, supported, supported); -QVConversions(long long, supported, supported); -QVConversions(unsigned long long, supported, supported); -QVConversions(float, supported, supported); -QVConversions(double, supported, supported); -QVConversions(QString, supported, supported); -QVConversions(QColor, unsupported, supported); -QVConversions(QFont, supported, supported); -QVConversions(QDateTime, unsupported, supported); -QVConversions(QDate, unsupported, supported); -QVConversions(QSize, unsupported, supported); -QVConversions(QRect, unsupported, supported); -QVConversions(QPoint, unsupported, supported); -QVConversions(QSizeF, unsupported, supported); -QVConversions(QRectF, unsupported, supported); -QVConversions(QPointF, unsupported, supported); -QVConversions(QByteArray, supported, supported); -QVConversions(QStringList, unsupported, supported); -QVConversions(QVariantList, unsupported, supported); -QVConversions(QUrl, supported, supported); -QVConversions(QList, unsupported, supported); -} - -#endif - diff --git a/src/core/conversioncheck.h b/src/core/conversioncheck.h new file mode 100644 index 00000000..55bd8826 --- /dev/null +++ b/src/core/conversioncheck.h @@ -0,0 +1,124 @@ +/* + This file is part of the KDE libraries + Copyright (c) 2006 Thomas Braxton + + 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef CONVERSION_CHECK_H +#define CONVERSION_CHECK_H + +#include +#include +#include +#include +#include +#include + +class QColor; +class QFont; + +namespace ConversionCheck +{ + +// used to distinguish between supported/unsupported types +struct supported { }; +struct unsupported { }; + +// traits type class to define support for constraints +template +struct QVconvertible { + typedef unsupported toQString; + typedef unsupported toQVariant; +}; + +// constraint classes +template +struct type_toQString { + void constraint() + { + supported x = y; + Q_UNUSED(x); + } + typename QVconvertible::toQString y; +}; + +template +struct type_toQVariant { + void constraint() + { + supported x = y; + Q_UNUSED(x); + } + typename QVconvertible::toQVariant y; +}; + +// check if T is convertible to QString thru QVariant +// if not supported can't be used in QList functions +template +inline void to_QString() +{ + void (type_toQString::*x)() = &type_toQString::constraint; + Q_UNUSED(x); +} + +// check if T is convertible to QVariant & supported in readEntry/writeEntry +template +inline void to_QVariant() +{ + void (type_toQVariant::*x)() = &type_toQVariant::constraint; + Q_UNUSED(x); +} + +// define for all types handled in readEntry/writeEntry +// string_support - is supported by QVariant(type).toString(), +// can be used in QList functions +// variant_support - has a QVariant constructor +#define QVConversions(type, string_support, variant_support) \ + template <> struct QVconvertible {\ + typedef string_support toQString;\ + typedef variant_support toQVariant;\ + } + +// The only types needed here are the types handled in readEntry/writeEntry +// the default QVconvertible will take care of the rest. +QVConversions(bool, supported, supported); +QVConversions(int, supported, supported); +QVConversions(unsigned int, supported, supported); +QVConversions(long long, supported, supported); +QVConversions(unsigned long long, supported, supported); +QVConversions(float, supported, supported); +QVConversions(double, supported, supported); +QVConversions(QString, supported, supported); +QVConversions(QColor, unsupported, supported); +QVConversions(QFont, supported, supported); +QVConversions(QDateTime, unsupported, supported); +QVConversions(QDate, unsupported, supported); +QVConversions(QSize, unsupported, supported); +QVConversions(QRect, unsupported, supported); +QVConversions(QPoint, unsupported, supported); +QVConversions(QSizeF, unsupported, supported); +QVConversions(QRectF, unsupported, supported); +QVConversions(QPointF, unsupported, supported); +QVConversions(QByteArray, supported, supported); +QVConversions(QStringList, unsupported, supported); +QVConversions(QVariantList, unsupported, supported); +QVConversions(QUrl, supported, supported); +QVConversions(QList, unsupported, supported); +} + +#endif + diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index c720cc66..14d27f94 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -219,7 +219,7 @@ static QString formatError(int expected, int got) QVariant KConfigGroup::convertToQVariant(const char *pKey, const QByteArray &value, const QVariant &aDefault) { // if a type handler is added here you must add a QVConversions definition - // to conversion_check.h, or ConversionCheck::to_QVariant will not allow + // to conversioncheck.h, or ConversionCheck::to_QVariant will not allow // readEntry to convert to QVariant. switch (aDefault.type()) { case QVariant::Invalid: @@ -938,7 +938,7 @@ void KConfigGroup::writeEntry(const char *key, const QVariant &value, QByteArray data; // if a type handler is added here you must add a QVConversions definition - // to conversion_check.h, or ConversionCheck::to_QVariant will not allow + // to conversioncheck.h, or ConversionCheck::to_QVariant will not allow // writeEntry to convert to QVariant. switch (value.type()) { case QVariant::Invalid: diff --git a/src/core/kconfiggroup.h b/src/core/kconfiggroup.h index cc8a51b1..1bcce58f 100644 --- a/src/core/kconfiggroup.h +++ b/src/core/kconfiggroup.h @@ -729,7 +729,7 @@ private: group.writeEntry(key, QByteArray(M_enum.valueToKeys(value)), flags); \ } -#include "conversion_check.h" +#include "conversioncheck.h" template T KConfigGroup::readCheck(const char *key, const T &defaultValue) const diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 974b05cc..eef8c2a8 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -15,27 +15,30 @@ add_library(KF5ConfigGui ${libkconfiggui_SRCS}) generate_export_header(KF5ConfigGui BASE_NAME KConfigGui) add_library(KF5::ConfigGui ALIAS KF5ConfigGui) -target_link_libraries(KF5ConfigGui PUBLIC Qt5::Gui Qt5::Xml KF5::ConfigCore) +target_include_directories(KF5ConfigGui INTERFACE "$" "$") -if(IS_ABSOLUTE "${INCLUDE_INSTALL_DIR}") - target_include_directories(KF5ConfigGui INTERFACE "$" ) -else() - target_include_directories(KF5ConfigGui INTERFACE "$" ) -endif() +target_link_libraries(KF5ConfigGui PUBLIC Qt5::Gui Qt5::Xml KF5::ConfigCore) set_target_properties(KF5ConfigGui PROPERTIES VERSION ${KCONFIG_VERSION_STRING} SOVERSION ${KCONFIG_SOVERSION} EXPORT_NAME ConfigGui ) +ecm_generate_headers( + KConfigGui + KConfigLoader + KConfigSkeleton + KStandardShortcut + KWindowConfig + + MODULE_NAME KConfigGui REQUIRED_HEADERS KConfigGui_HEADERS +) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/KConfigGui DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel) + install(TARGETS KF5ConfigGui EXPORT KF5ConfigTargets ${INSTALL_TARGETS_DEFAULT_ARGS}) -install( FILES - ${CMAKE_CURRENT_BINARY_DIR}/kconfiggui_export.h - kconfiggui.h - kconfigloader.h - kconfigskeleton.h - kstandardshortcut.h - kwindowconfig.h - DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/kconfiggui_export.h + ${KConfigGui_HEADERS} + DESTINATION ${INCLUDE_INSTALL_DIR}/kconfiggui COMPONENT Devel ) -- cgit v1.2.1