diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,8 @@ include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(GtkUpdateIconCache) +include(ECMGenerateExportHeader) +include(ECMSetupVersion) # Dependencies set(REQUIRED_QT_VERSION 5.11.0) @@ -29,7 +31,14 @@ option(BINARY_ICONS_RESOURCE "Install Qt binary resource files containing breeze icons (breeze-icons.rcc, breeze-icons-dark.rcc)" ${BINARY_ICONS_RESOURCE_OPTION_DEFAULT}) option(SKIP_INSTALL_ICONS "Skip installing the icons files" OFF) +ecm_setup_version(PROJECT + VARIABLE_PREFIX BREEZEICONS + VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/breezeicons_version.h" + PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5BreezeIconsConfigVersion.cmake" + SOVERSION 5) + if(BINARY_ICONS_RESOURCE) + find_package(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) find_package(Qt5 NO_MODULE REQUIRED Core) add_executable(qrcAlias qrcAlias.cpp) target_link_libraries(qrcAlias PUBLIC Qt5::Core) @@ -91,4 +100,33 @@ add_subdirectory(icons) add_subdirectory(icons-dark) +if(BINARY_ICONS_RESOURCE) + # create a Config.cmake and a ConfigVersion.cmake file and install them + set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5BreezeIcons") + + include(CMakePackageConfigHelpers) + + configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/KF5BreezeIconsConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/KF5BreezeIconsConfig.cmake" + INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} + ) + + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/KF5BreezeIconsConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/KF5BreezeIconsConfigVersion.cmake" + DESTINATION "${CMAKECONFIG_INSTALL_DIR}" + COMPONENT Devel + ) + + install(EXPORT KF5BreezeIconsTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5BreezeIconsTargets.cmake NAMESPACE KF5:: ) + + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/breezeicons_version.h + DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel + ) + + add_subdirectory(src) +endif() + feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES) diff --git a/KF5BreezeIconsConfig.cmake.in b/KF5BreezeIconsConfig.cmake.in new file mode 100644 --- /dev/null +++ b/KF5BreezeIconsConfig.cmake.in @@ -0,0 +1,8 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(Qt5Gui "@REQUIRED_QT_VERSION@") + + +include("${CMAKE_CURRENT_LIST_DIR}/KF5BreezeIconsTargets.cmake") +@PACKAGE_INCLUDE_QCHTARGETS@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,48 @@ +set(kbreezeicons_SRCS + main.cpp +) + +# add our icons for normal mode +qt5_add_resources(kbreezeicons_SRCS + ${CMAKE_BINARY_DIR}/icons/res/breeze-icons.qrc + OPTIONS --root /icons/breeze +) + +# add our icons for dark mode +qt5_add_resources(kbreezeicons_SRCS + ${CMAKE_BINARY_DIR}/icons-dark/res/breeze-icons-dark.qrc + OPTIONS --root /icons/breeze-dark +) + +add_library(KF5BreezeIcons ${kbreezeicons_SRCS}) +add_library(KF5::BreezeIcons ALIAS KF5BreezeIcons) +ecm_generate_export_header(KF5BreezeIcons + BASE_NAME BreezeIcons + GROUP_BASE_NAME KF + VERSION ${KF5_VERSION} + DEPRECATED_BASE_VERSION 0 + DEPRECATION_VERSIONS 4.8 5.0 5.63 5.64 + EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} +) + +# at the moment no installed headers +# target_include_directories(KF5BreezeIcons INTERFACE "$") + +target_link_libraries(KF5BreezeIcons + PUBLIC + Qt5::Gui +) +if (TARGET Qt5::DBus) + target_link_libraries(KF5BreezeIcons PRIVATE Qt5::DBus) +endif() + +set_target_properties(KF5BreezeIcons PROPERTIES VERSION ${BREEZEICONS_VERSION_STRING} + SOVERSION ${BREEZEICONS_SOVERSION} + EXPORT_NAME BreezeIcons +) + +install(TARGETS KF5BreezeIcons EXPORT KF5BreezeIconsTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) + +include(ECMGeneratePriFile) +ecm_generate_pri_file(BASE_NAME BreezeIcons LIB_NAME KF5BreezeIcons DEPS "gui" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/BreezeIcons) +install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: LGPL-2.0-or-later + + Copyright (C) 2019 Christoph Cullmann + + 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. +*/ + +#include +#include +#include + +/** + * ensure we default to the breeze icons we compile into this libary + * as resources (both normal + dark) + */ +static void setFallbackThemeName() +{ + // decide if we want normal or dark theme based on application palette + const auto darkTheme = qGuiApp->palette().color(QPalette::Base).lightness() < 128; + + // just enforce fallback theme, allowing the users to overwrite this + QIcon::setFallbackThemeName(darkTheme ? QStringLiteral("breeze-dark") : QStringLiteral("breeze")); +} + +// ensure this is done on startup +Q_COREAPP_STARTUP_FUNCTION(setFallbackThemeName)