From 832345ff22bc67c63c818ba2275ff7188ffe8443 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sun, 2 Apr 2023 11:31:03 +0200 Subject: [PATCH] minor improvements --- CMakeLists.txt | 65 +++++++++++++++++++++++++----------------- cmake/QskFindQt.cmake | 48 +++++++++++++++++++------------ support/CMakeLists.txt | 49 ++++++++++++++----------------- support/fonts.conf.in | 9 ------ 4 files changed, 90 insertions(+), 81 deletions(-) delete mode 100644 support/fonts.conf.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 7035039f..334bba51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,40 +1,53 @@ -cmake_minimum_required(VERSION 3.16.3) +############################################################################ +# QSkinny - Copyright (C) 2016 Uwe Rathmann +# This file may be used under the terms of the QSkinny License, Version 1.0 +############################################################################ + +cmake_minimum_required(VERSION 3.16.3) # unclear - TODO + +macro(qsk_setup_options) + + option(BUILD_QSKDLL "Build libs ( not plugins ) as shared library" ON) + option(BUILD_QML_EXPORT "Exporting QSkinny to QML" ON) + + option(BUILD_TOOLS "Build qskinny tools" ON) + option(BUILD_INPUTCONTEXT "Build virtual keyboard support" ON) + option(BUILD_EXAMPLES "Build qskinny examples" ON) + option(BUILD_PLAYGROUND "Build qskinny playground" ON) + + # we actually want to use cmake_dependent_option - minimum cmake version ?? + + option( BUILD_SVG2QVG_STANDALONE "Build svg2qvg without qskinny library dependency" ON ) + if( NOT BUILD_TOOLS ) + set( BUILD_SVG2QVG_STANDALONE OFF ) + endif() + + if( NOT BUILD_INPUTCONTEXT ) + set( ENABLE_PINYIN OFF ) + set( ENABLE_HUNSPELL OFF ) + endif() + + option(ENABLE_ENSURE_SKINS "Examples add skins manually, when not finding plugins" ON) + +endmacro() + +############################################################################ +# QSkinny +############################################################################ project(QSkinny LANGUAGES C CXX HOMEPAGE_URL "https://github.com/uwerat/qskinny" VERSION 999.99.9) -option(BUILD_QSKDLL "Build libs ( not plugins ) as shared library" ON) -option(BUILD_QML_EXPORT "Exporting QSkinny to QML" ON) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) -option(BUILD_TOOLS "Build qskinny tools" ON) -option(BUILD_INPUTCONTEXT "Build virtual keyboard support" ON) -option(BUILD_EXAMPLES "Build qskinny examples" ON) -option(BUILD_PLAYGROUND "Build qskinny playground" ON) +qsk_setup_options() -# we actually want to use cmake_dependent_option - minimum cmake version ?? - -option( BUILD_SVG2QVG_STANDALONE "Build svg2qvg without qskinny library dependency" ON ) -if( NOT BUILD_TOOLS ) - set( BUILD_SVG2QVG_STANDALONE OFF ) -endif() - -if( NOT BUILD_INPUTCONTEXT ) - set( ENABLE_PINYIN OFF ) - set( ENABLE_HUNSPELL OFF ) -endif() - -option(ENABLE_ENSURE_SKINS "Examples will load skins manually, when not finding plugins" ON) -if ( NOT ( BUILD_EXAMPLES OR BUILD_PLAYGROUND ) ) - set( ENABLE_ENSURE_SKINS OFF ) -endif() +include(GNUInstallDirs) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -#set(CMAKE_FIND_DEBUG_MODE TRUE) -set_property(GLOBAL PROPERTY USE_FOLDERS ON) - include("QskFindQt") include("QskAutogen") include("QskBuild") diff --git a/cmake/QskFindQt.cmake b/cmake/QskFindQt.cmake index bb3e8978..5a480955 100644 --- a/cmake/QskFindQt.cmake +++ b/cmake/QskFindQt.cmake @@ -8,46 +8,56 @@ # standard cmake features are good enough or if we need to introduce # something sort of additional option. TODO ... -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) +find_package(QT "5.15" NAMES Qt6 Qt5 REQUIRED COMPONENTS Quick) if ( QT_FOUND ) # Would like to have a status message about where the Qt installation # has been found without having the mess of CMAKE_FIND_DEBUG_MODE - # All I found was + # With Qt6 there seems to be: _qt_cmake_dir message(STATUS "Found Qt ${QT_VERSION} ${_qt_cmake_dir}") - - if(QT_VERSION VERSION_LESS "5.15.0") - message(FATAL_ERROR "Couldn't find any Qt >= 5.15 !") - endif() else() message(FATAL_ERROR "Couldn't find any Qt package !") endif() -# Not sure if using find_package here is a good idea. -# In situations, where the Qt installation that has been found -# above has not been built with all modules we might end up with modules -# from other Qt installations/versions. Might be better to limit -# finding packages from the same package. TODO ... - -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Gui OpenGL Quick ) +# Using find_package is probably no good idea as all other Qt modules should +# be located below ${_qt_cmake_dir}. Otherwise we might end up with modules +# from different packages. TODO ... if( BUILD_TOOLS ) # needed for building the svg2qvg tool - find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS Svg) + find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Svg) endif() -# some examples need additional modules - if( BUILD_EXAMPLES OR BUILD_PLAYGROUND ) - find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS QuickWidgets) + # On embedded systems you often find optimized Qt installations without + # Qt/Widgets support. QSkinny itself does not need Qt/Widgets - however + # playground/grids demonstrates the differences between the various + # grid layouts. So no big deal when it is missing. + + find_package(Qt${QT_VERSION_MAJOR} QUIET OPTIONAL_COMPONENTS QuickWidgets) + if (NOT Qt${QT_VERSION_MAJOR}QuickWidgets_FOUND) + message(STATUS "No Qt/Quick Widgets support: skipping some unimportant examples") + endif() endif() if(BUILD_PLAYGROUND) + # When building Qt most of the time is spent on the WebEngine modules + # while only few applications need it. So it is a common situation to + # have Qt installations without. + # playground/webview shows how to use the Qt/Quick frontend from + # C++, but QSkinny itself does not need the WebEngine at all. + if (QT_VERSION_MAJOR VERSION_LESS 6) - find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS WebEngine) + find_package(Qt${QT_VERSION_MAJOR} QUIET OPTIONAL_COMPONENTS WebEngine) + set( Qt5WebEngineQuick_FOUND ${Qt5WebEngine_FOUND} ) else() - find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS WebEngineCore WebEngineQuick) + find_package(Qt${QT_VERSION_MAJOR} QUIET + OPTIONAL_COMPONENTS WebEngineCore WebEngineQuick) + endif() + + if( NOT Qt${QT_VERSION_MAJOR}WebEngineQuick_FOUND) + message(STATUS "No Qt/Quick WebEngine support: skipping some unimportant examples") endif() endif() diff --git a/support/CMakeLists.txt b/support/CMakeLists.txt index a820d803..be83fbb6 100644 --- a/support/CMakeLists.txt +++ b/support/CMakeLists.txt @@ -19,29 +19,6 @@ else() qsk_add_library(${target} STATIC ${SOURCES}) endif() -set(HACK_FONT_CONFIG ON) - -if(HACK_FONT_CONFIG) - - message( STATUS "Building an dummy fontconfig enviroment for faster startups" ) - - # On systems where many fonts are installed we have a significant effect - # on the startup performance when building the font cache. To avoid this - # penalty we configure an empty environment - # ( this code should be moved to a cmake function TODO ... - - set(QSK_FONTDIR ${CMAKE_CURRENT_LIST_DIR}/fonts) - set(QSK_FONTCACHEDIR ${CMAKE_CURRENT_BINARY_DIR}/fontconfig) - set(QSK_FONTCONF_FILE ${QSK_FONTCACHEDIR}/fonts.conf) - - configure_file(fonts.conf.cmake.in ${QSK_FONTCONF_FILE} - @ONLY - NEWLINE_STYLE LF) - - target_compile_definitions(${target} - PRIVATE FONTCONFIG_FILE=${QSK_FONTCONF_FILE}) -endif() - target_link_libraries(${target} PUBLIC qskinny) if (BUILD_QSKDLL) @@ -53,14 +30,32 @@ target_compile_definitions(${target} target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) -if(ENABLE_ENSURE_SKINS) - #set( ENABLE_ENSURE_SKINS OFF ) -endif() - if(ENABLE_ENSURE_SKINS) target_include_directories(${target} PRIVATE ${CMAKE_SOURCE_DIR}/skins) target_compile_definitions(${target} PRIVATE ENSURE_SKINS) target_link_libraries(${target} PRIVATE squiekskin material3skin) endif() +set(HIDE_SYSTEM_FONTS ON) + +if(HIDE_SYSTEM_FONTS) + message( STATUS "Hiding system fonts from the examples" ) + + # The fonts being used in the examples are included and we do not + # need the fonts from the system. To avoid, that setting up the font + # cache slows doesn the stratup performance we hide the system fonts + # be using a dummy font config environment. + # ( this hack is pretty old ( Qt 5.4 ) - maybe it is not needed anymore TODO ) + + set(QSK_FONTDIR ${CMAKE_CURRENT_LIST_DIR}/fonts) + set(QSK_FONTCACHEDIR ${CMAKE_CURRENT_BINARY_DIR}/fontconfig) + set(QSK_FONTCONF_FILE ${QSK_FONTCACHEDIR}/fonts.conf) + + configure_file(fonts.conf.cmake.in ${QSK_FONTCONF_FILE} + @ONLY NEWLINE_STYLE LF) + + target_compile_definitions(${target} + PRIVATE FONTCONFIG_FILE=${QSK_FONTCONF_FILE}) +endif() + install(TARGETS ${target} DESTINATION ${QSK_INSTALL_LIBS}) diff --git a/support/fonts.conf.in b/support/fonts.conf.in deleted file mode 100644 index ac65f704..00000000 --- a/support/fonts.conf.in +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - FONTDIR - FONTCACHEDIR/cache - -