2016-11-08 19:57:57 +01:00
|
|
|
cmake_minimum_required(VERSION 3.3.0 FATAL_ERROR)
|
|
|
|
|
2016-04-16 00:50:31 +02:00
|
|
|
# applies Qt specific configuration
|
|
|
|
# for GUI applications, QtGuiAppConfig must be included before
|
2017-02-11 02:31:43 +01:00
|
|
|
# this module must be included before AppTarget/LibraryTarget
|
|
|
|
|
|
|
|
if(NOT BASIC_PROJECT_CONFIG_DONE)
|
|
|
|
message(FATAL_ERROR "Before including the QtConfig module, the BasicConfig module must be included.")
|
|
|
|
endif()
|
|
|
|
if(QT_CONFIGURED)
|
|
|
|
message(FATAL_ERROR "The QtConfig module can not be included when Qt usage has already been configured.")
|
|
|
|
endif()
|
|
|
|
if(TARGET_CONFIG_DONE)
|
|
|
|
message(FATAL_ERROR "Can not include QtConfig module when targets are already configured.")
|
|
|
|
endif()
|
2016-04-16 00:50:31 +02:00
|
|
|
|
|
|
|
# add the Core module as it is always required
|
|
|
|
# also add additional Qt/KF modules which must have been specified before if required
|
|
|
|
# the Gui/Widgets/Quick modules should be added by including QtGuiAppConfig
|
2016-07-16 23:12:02 +02:00
|
|
|
set(QT_REPOS base ${ADDITIONAL_QT_REPOS})
|
2017-08-06 00:41:50 +02:00
|
|
|
set(QT_MODULES ${ADDITIONAL_QT_MODULES} Core)
|
2016-04-16 00:50:31 +02:00
|
|
|
set(KF_MODULES ${ADDITIONAL_KF_MODULES})
|
2016-10-08 19:07:28 +02:00
|
|
|
|
2017-02-20 20:03:57 +01:00
|
|
|
# allow specifying a custom directory for Qt plugins
|
|
|
|
set(QT_PLUGIN_DIR "" CACHE STRING "specifies the directory to install Qt plugins")
|
|
|
|
|
2016-10-08 19:07:28 +02:00
|
|
|
include(QtLinkage)
|
2016-04-16 00:50:31 +02:00
|
|
|
|
2016-07-27 18:51:25 +02:00
|
|
|
# check whether D-Bus interfaces need to be processed
|
|
|
|
if(DBUS_FILES)
|
|
|
|
message(STATUS "Project has D-Bus interface declarations which will be processed.")
|
|
|
|
# the D-Bus Qt module is required
|
|
|
|
list(APPEND QT_MODULES DBus)
|
|
|
|
endif()
|
|
|
|
|
2016-11-08 19:57:57 +01:00
|
|
|
# remove duplicates
|
2016-10-08 19:07:28 +02:00
|
|
|
list(REMOVE_DUPLICATES QT_REPOS)
|
|
|
|
list(REMOVE_DUPLICATES QT_MODULES)
|
2016-11-08 19:57:57 +01:00
|
|
|
if(IMPORTED_QT_MODULES)
|
|
|
|
list(REMOVE_DUPLICATES IMPORTED_QT_MODULES)
|
|
|
|
endif()
|
2016-10-08 19:07:28 +02:00
|
|
|
if(KF_MODULES)
|
|
|
|
list(REMOVE_DUPLICATES KF_MODULES)
|
|
|
|
endif()
|
2016-11-08 19:57:57 +01:00
|
|
|
if(IMPORTED_KF_MODULES)
|
|
|
|
list(REMOVE_DUPLICATES IMPORTED_KF_MODULES)
|
|
|
|
endif()
|
2016-10-08 19:07:28 +02:00
|
|
|
|
2016-07-27 18:51:25 +02:00
|
|
|
# actually find the required Qt/KF modules
|
|
|
|
foreach(QT_MODULE ${QT_MODULES})
|
2016-10-29 00:26:06 +02:00
|
|
|
# using those helpers allows using static Qt 5 build
|
|
|
|
find_qt5_module(${QT_MODULE} REQUIRED)
|
|
|
|
use_qt5_module(${QT_MODULE} REQUIRED)
|
2016-07-27 18:51:25 +02:00
|
|
|
endforeach()
|
2016-11-08 19:57:57 +01:00
|
|
|
foreach(QT_MODULE ${IMPORTED_QT_MODULES})
|
|
|
|
if(NOT "${QT_MODULE}" IN_LIST QT_MODULES)
|
|
|
|
find_qt5_module(${QT_MODULE} REQUIRED)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2016-07-27 18:51:25 +02:00
|
|
|
foreach(KF_MODULE ${KF_MODULES})
|
2016-10-29 00:26:06 +02:00
|
|
|
# only shared KF5 modules supported
|
2016-07-27 18:51:25 +02:00
|
|
|
find_package(KF5${KF_MODULE} REQUIRED)
|
2016-10-29 00:26:06 +02:00
|
|
|
set(KF5_${KF_MODULE}_DYNAMIC_LIB KF5::${KF_MODULE})
|
|
|
|
link_against_library(KF5_${KF_MODULE} "AUTO_LINKAGE" REQUIRED)
|
2016-07-27 18:51:25 +02:00
|
|
|
endforeach()
|
2016-11-08 19:57:57 +01:00
|
|
|
foreach(KF_MODULE ${IMPORTED_KF_MODULES})
|
|
|
|
if(NOT "${KF_MODULE}" IN_LIST KF_MODULES)
|
|
|
|
find_package(KF5${KF_MODULE} REQUIRED)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2016-07-27 18:51:25 +02:00
|
|
|
|
2017-09-03 18:03:41 +02:00
|
|
|
# built-in platform, imageformat and iconengine plugins when linking statically against Qt Gui
|
2017-10-08 19:26:56 +02:00
|
|
|
# -> determine whether application target links statically against Qt Gui
|
|
|
|
if(META_PROJECT_TYPE STREQUAL "application")
|
|
|
|
set(USING_STATIC_QT_GUI_FOR_APPLICATION NO)
|
|
|
|
foreach(MODULE Gui Widgets Quick)
|
|
|
|
if(QT5_${MODULE}_STATIC_LIB IN_LIST LIBRARIES OR QT5_${MODULE}_STATIC_LIB IN_LIST PRIVATE_LIBRARIES)
|
|
|
|
set(USING_STATIC_QT_GUI_FOR_APPLICATION YES)
|
|
|
|
message(STATUS "Linking application ${META_PROJECT_NAME} against static Qt 5 plugins.")
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2017-09-03 18:03:41 +02:00
|
|
|
# -> link against plugins according to platform and configuration
|
2017-10-08 19:26:56 +02:00
|
|
|
if(USING_STATIC_QT_GUI_FOR_APPLICATION)
|
2016-11-26 21:58:42 +01:00
|
|
|
if(NOT USE_STATIC_QT5_Gui)
|
|
|
|
find_qt5_module(Gui REQUIRED)
|
2016-08-19 16:16:10 +02:00
|
|
|
endif()
|
2017-09-03 18:03:41 +02:00
|
|
|
|
|
|
|
# ensure platform integration plugins for corresponding platforms are built-in when creating a GUI application
|
2017-08-06 00:44:20 +02:00
|
|
|
if(WIN32)
|
2017-10-08 19:26:56 +02:00
|
|
|
use_static_qt5_plugin(Gui WindowsIntegration ON OFF)
|
2017-08-06 00:44:20 +02:00
|
|
|
elseif(APPLE)
|
2017-10-08 19:26:56 +02:00
|
|
|
use_static_qt5_plugin(Gui CocoaIntegration ON OFF)
|
2017-09-03 18:03:41 +02:00
|
|
|
elseif(TARGET ${QT5_Gui_STATIC_PREFIX}QXcbIntegrationPlugin)
|
2017-10-08 19:26:56 +02:00
|
|
|
use_static_qt5_plugin(Gui XcbIntegration ON OFF)
|
2017-08-06 00:44:20 +02:00
|
|
|
else()
|
|
|
|
message(WARNING "The required platform plugin for your platform is unknown an can not be linked in statically.")
|
|
|
|
endif()
|
2017-09-03 18:03:41 +02:00
|
|
|
|
|
|
|
# ensure image format plugins (beside SVG) are built-in if configured
|
|
|
|
if(IMAGE_FORMAT_SUPPORT)
|
|
|
|
foreach(IMAGE_FORMAT ${IMAGE_FORMAT_SUPPORT})
|
|
|
|
if(IMAGE_FORMAT EQUAL "Svg")
|
|
|
|
# the image format plugin of the Qt Svg module is handled separately
|
|
|
|
set(SVG_SUPPORT ON)
|
|
|
|
list(REMOVE_ITEM IMAGE_FORMAT_SUPPORT Svg)
|
|
|
|
else()
|
2017-10-08 19:26:56 +02:00
|
|
|
use_static_qt5_plugin(Gui "${IMAGE_FORMAT}" ON OFF)
|
2017-09-03 18:03:41 +02:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# allow importing image format plugins via config.h
|
|
|
|
include(ListToString)
|
|
|
|
list_to_string(" " "\\\n Q_IMPORT_PLUGIN(Q" "Plugin)" "${IMAGE_FORMAT_SUPPORT}" IMAGE_FORMAT_SUPPORT_ARRAY)
|
|
|
|
endif()
|
|
|
|
|
2017-08-20 02:23:02 +02:00
|
|
|
# ensure SVG plugins are built-in if configured
|
2017-09-03 18:03:41 +02:00
|
|
|
if((SVG_SUPPORT OR SVG_ICON_SUPPORT) AND NOT USE_STATIC_QT5_Svg)
|
|
|
|
find_qt5_module(Svg REQUIRED)
|
|
|
|
endif()
|
|
|
|
if(SVG_SUPPORT)
|
2017-10-08 19:26:56 +02:00
|
|
|
use_static_qt5_plugin(Svg Svg ON OFF)
|
2017-08-11 22:13:44 +02:00
|
|
|
endif()
|
2017-08-20 02:23:02 +02:00
|
|
|
if(SVG_ICON_SUPPORT)
|
2017-10-08 19:26:56 +02:00
|
|
|
use_static_qt5_plugin(Svg SvgIcon ON OFF)
|
2017-08-11 22:13:44 +02:00
|
|
|
endif()
|
2016-08-19 16:16:10 +02:00
|
|
|
endif()
|
|
|
|
|
2016-07-27 21:42:27 +02:00
|
|
|
# option for built-in translations
|
2017-02-11 02:56:19 +01:00
|
|
|
option(BUILTIN_TRANSLATIONS "enables/disables built-in translations when building applications and libraries" OFF)
|
2016-07-27 21:42:27 +02:00
|
|
|
|
|
|
|
# determine relevant Qt translation files
|
|
|
|
set(QT_TRANSLATION_FILES)
|
|
|
|
set(QT_TRANSLATION_SEARCH_PATHS)
|
|
|
|
if(CMAKE_FIND_ROOT_PATH)
|
|
|
|
list(APPEND QT_TRANSLATION_SEARCH_PATHS "${CMAKE_FIND_ROOT_PATH}/share/qt/translations")
|
|
|
|
endif()
|
|
|
|
list(APPEND QT_TRANSLATION_SEARCH_PATHS "${CMAKE_INSTALL_PREFIX}/share/qt/translations")
|
|
|
|
list(APPEND QT_TRANSLATION_SEARCH_PATHS "/usr/share/qt/translations")
|
|
|
|
foreach(QT_TRANSLATION_PATH ${QT_TRANSLATION_SEARCH_PATHS})
|
|
|
|
if(IS_DIRECTORY "${QT_TRANSLATION_PATH}")
|
|
|
|
foreach(QT_REPO ${QT_REPOS})
|
|
|
|
file(GLOB QT_QM_FILES "${QT_TRANSLATION_PATH}/qt${QT_REPO}_*.qm")
|
|
|
|
if(QT_QM_FILES)
|
2017-02-26 18:40:06 +01:00
|
|
|
# add files to list of built-in translations
|
|
|
|
# but only if that configuration is enabled and if we're building the final application
|
|
|
|
if(BUILTIN_TRANSLATIONS AND "${META_PROJECT_TYPE}" STREQUAL "application")
|
2016-07-27 21:42:27 +02:00
|
|
|
file(COPY ${QT_QM_FILES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
list(APPEND QM_FILES ${QT_QM_FILES})
|
|
|
|
endif()
|
|
|
|
list(APPEND QT_TRANSLATION_FILES "qt${QT_REPO}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# make relevant Qt translations available as array via config.h
|
|
|
|
include(ListToString)
|
2017-02-11 02:04:12 +01:00
|
|
|
list_to_string("," " \\\n QStringLiteral(\"" "\")" "${QT_TRANSLATION_FILES}" QT_TRANSLATION_FILES_ARRAY)
|
2016-07-27 21:42:27 +02:00
|
|
|
|
2016-04-16 00:50:31 +02:00
|
|
|
# enable lrelease and add install target for localization
|
2017-08-06 00:40:11 +02:00
|
|
|
option(ENABLE_QT_TRANSLATIONS "specifies whether Qt translations should be updated/released" ON)
|
|
|
|
if(ENABLE_QT_TRANSLATIONS AND TS_FILES)
|
2016-04-16 00:50:31 +02:00
|
|
|
message(STATUS "Project has translations which will be released.")
|
2017-01-07 16:09:38 +01:00
|
|
|
set(APP_SPECIFIC_QT_TRANSLATIONS_AVAILABLE YES)
|
2016-04-16 00:50:31 +02:00
|
|
|
|
|
|
|
# the LinguistTools module is required
|
|
|
|
# (but not add it to QT_MODULES because we don't link against it)
|
|
|
|
find_package(Qt5LinguistTools REQUIRED)
|
|
|
|
|
2017-08-01 10:47:27 +02:00
|
|
|
set(LUPDATE_OPTIONS "" CACHE STRING "specifies options passed to lupdate")
|
|
|
|
|
2016-04-16 00:50:31 +02:00
|
|
|
# adds the translations and a target for it
|
2016-04-24 20:53:14 +02:00
|
|
|
qt5_create_translation(QM_FILES
|
|
|
|
${HEADER_FILES} ${SRC_FILES}
|
|
|
|
${WIDGETS_HEADER_FILES} ${WIDGETS_SRC_FILES} ${WIDGETS_UI_FILES}
|
|
|
|
${QML_HEADER_FILES} ${QML_SRC_FILES} ${QML_RES_FILES}
|
|
|
|
${TS_FILES}
|
2017-08-01 10:47:27 +02:00
|
|
|
OPTIONS ${LUPDATE_OPTIONS}
|
2016-04-24 20:53:14 +02:00
|
|
|
)
|
2017-10-16 09:56:35 +02:00
|
|
|
add_custom_target(${META_PROJECT_NAME}_translations DEPENDS ${QM_FILES})
|
|
|
|
if(NOT TARGET translations)
|
|
|
|
add_custom_target(translations DEPENDS ${META_PROJECT_NAME}_translations)
|
|
|
|
else()
|
|
|
|
add_dependencies(translations ${META_PROJECT_NAME}_translations)
|
|
|
|
endif()
|
2016-04-16 00:50:31 +02:00
|
|
|
|
2017-07-20 01:43:48 +02:00
|
|
|
# add install target for translations
|
|
|
|
if(NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
|
|
|
|
install(FILES ${QM_FILES}
|
|
|
|
DESTINATION share/${META_PROJECT_NAME}/translations
|
|
|
|
COMPONENT localization
|
2016-04-16 00:50:31 +02:00
|
|
|
)
|
2017-07-20 01:43:48 +02:00
|
|
|
if(NOT TARGET install-localization)
|
|
|
|
set(LOCALIZATION_TARGET "install-localization")
|
|
|
|
add_custom_target(${LOCALIZATION_TARGET}
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=localization -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
|
|
|
)
|
|
|
|
add_dependencies(${LOCALIZATION_TARGET} ${META_PROJECT_NAME}_translations)
|
|
|
|
endif()
|
2016-04-16 00:50:31 +02:00
|
|
|
endif()
|
2016-07-16 23:12:02 +02:00
|
|
|
|
2017-01-07 16:09:38 +01:00
|
|
|
list(APPEND APP_SPECIFIC_QT_TRANSLATION_FILES "${META_PROJECT_NAME}")
|
2017-09-08 16:46:35 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# make application specific translation available as array via config.h
|
|
|
|
# (even if this project has no translations, there might be some from dependencies)
|
|
|
|
if(APP_SPECIFIC_QT_TRANSLATION_FILES)
|
2017-02-11 02:04:12 +01:00
|
|
|
list_to_string("," " \\\n QStringLiteral(\"" "\")" "${APP_SPECIFIC_QT_TRANSLATION_FILES}" APP_SPECIFIC_QT_TRANSLATION_FILES_ARRAY)
|
2017-01-07 16:09:38 +01:00
|
|
|
else()
|
|
|
|
set(APP_SPECIFIC_QT_TRANSLATIONS_AVAILABLE NO)
|
2016-04-16 00:50:31 +02:00
|
|
|
endif()
|
|
|
|
|
2017-02-26 18:42:08 +01:00
|
|
|
# built-in translations
|
|
|
|
if(BUILTIN_TRANSLATIONS AND QM_FILES)
|
|
|
|
# write a qrc file for the qm files and add it to the resource files
|
|
|
|
set(TRANSLATIONS_QRC_FILE_NAME "${META_PROJECT_VARNAME_LOWER}_translations.qrc")
|
|
|
|
set(TRANSLATIONS_QRC_FILE "${CMAKE_CURRENT_BINARY_DIR}/${TRANSLATIONS_QRC_FILE_NAME}")
|
|
|
|
file(WRITE "${TRANSLATIONS_QRC_FILE}" "<RCC><qresource prefix=\"/translations\">")
|
|
|
|
foreach(QM_FILE ${QM_FILES})
|
|
|
|
get_filename_component(QM_FILE_NAME "${QM_FILE}" NAME)
|
|
|
|
file(APPEND "${TRANSLATIONS_QRC_FILE}" "<file>${QM_FILE_NAME}</file>")
|
|
|
|
endforeach()
|
|
|
|
file(APPEND "${TRANSLATIONS_QRC_FILE}" "</qresource></RCC>")
|
|
|
|
list(APPEND RES_FILES "${TRANSLATIONS_QRC_FILE}")
|
|
|
|
list(APPEND AUTOGEN_DEPS ${QM_FILES})
|
|
|
|
list(APPEND BUILTIN_TRANSLATION_FILES "${TRANSLATIONS_QRC_FILE_NAME}")
|
|
|
|
endif()
|
|
|
|
|
2016-04-16 00:50:31 +02:00
|
|
|
# generate DBus interfaces
|
|
|
|
if(DBUS_FILES)
|
2017-07-09 23:45:17 +02:00
|
|
|
qt5_add_dbus_interfaces(GENERATED_DBUS_FILES ${DBUS_FILES})
|
2016-04-16 00:50:31 +02:00
|
|
|
endif()
|
|
|
|
|
2016-07-16 23:12:02 +02:00
|
|
|
# add icons to be built-in
|
|
|
|
if(REQUIRED_ICONS)
|
|
|
|
set(BUILTIN_ICON_THEMES "" CACHE STRING "specifies icon themes to be built-in")
|
2017-02-11 02:56:19 +01:00
|
|
|
option(BUILTIN_ICON_THEMES_IN_LIBRARIES "specifies whether icon themes should also be built-in when building libraries" OFF)
|
|
|
|
if(BUILTIN_ICON_THEMES AND (BUILTIN_ICON_THEMES_IN_LIBRARIES OR (NOT "${META_PROJECT_TYPE}" STREQUAL "library")))
|
2016-07-16 23:12:02 +02:00
|
|
|
set(ICON_THEME_FILES)
|
|
|
|
set(ICON_SEARCH_PATHS)
|
|
|
|
if(CMAKE_FIND_ROOT_PATH)
|
2016-08-27 15:00:55 +02:00
|
|
|
# find icons from the regular prefix when cross-compiling
|
2016-07-16 23:12:02 +02:00
|
|
|
list(APPEND ICON_SEARCH_PATHS "${CMAKE_FIND_ROOT_PATH}/share/icons")
|
|
|
|
endif()
|
|
|
|
list(APPEND ICON_SEARCH_PATHS "${CMAKE_INSTALL_PREFIX}/share/icons")
|
|
|
|
list(APPEND ICON_SEARCH_PATHS "/usr/share/icons")
|
2017-02-11 02:56:28 +01:00
|
|
|
set(BUILTIN_ICONS_DIR "${CMAKE_CURRENT_BINARY_DIR}/icons")
|
|
|
|
set(DEFAULT_THEME_INDEX_FILE "${BUILTIN_ICONS_DIR}/default/index.theme")
|
|
|
|
file(REMOVE_RECURSE "${BUILTIN_ICONS_DIR}")
|
|
|
|
file(MAKE_DIRECTORY "${BUILTIN_ICONS_DIR}")
|
2016-07-16 23:12:02 +02:00
|
|
|
foreach(ICON_THEME ${BUILTIN_ICON_THEMES})
|
2016-08-27 15:00:55 +02:00
|
|
|
string(REGEX MATCHALL "([^:]+|[^:]+$)" ICON_THEME_PARTS "${ICON_THEME}")
|
|
|
|
list(LENGTH ICON_THEME_PARTS ICON_THEME_PARTS_LENGTH)
|
|
|
|
if("${ICON_THEME_PARTS_LENGTH}" STREQUAL 2)
|
|
|
|
list(GET ICON_THEME_PARTS 0 ICON_THEME)
|
|
|
|
list(GET ICON_THEME_PARTS 1 NEW_ICON_THEME_NAME)
|
|
|
|
else()
|
|
|
|
set(NEW_ICON_THEME_NAME "${ICON_THEME}")
|
|
|
|
endif()
|
2016-07-16 23:12:02 +02:00
|
|
|
foreach(ICON_SEARCH_PATH ${ICON_SEARCH_PATHS})
|
|
|
|
set(ICON_THEME_PATH "${ICON_SEARCH_PATH}/${ICON_THEME}")
|
2016-08-27 15:00:55 +02:00
|
|
|
set(NEW_ICON_THEME_PATH "${ICON_SEARCH_PATH}/${ICON_THEME}")
|
2016-07-16 23:12:02 +02:00
|
|
|
if(IS_DIRECTORY "${ICON_THEME_PATH}")
|
2016-11-01 14:05:48 +01:00
|
|
|
message(STATUS "The specified icon theme \"${ICON_THEME}\" has been located under \"${ICON_THEME_PATH}\" and will be built-in.")
|
2016-08-27 15:00:55 +02:00
|
|
|
# find index files
|
2016-11-01 14:05:48 +01:00
|
|
|
if(NOT ICON_THEME STREQUAL FALLBACK_ICON_THEME)
|
|
|
|
file(GLOB GLOBBED_ICON_THEME_INDEX_FILES LIST_DIRECTORIES false "${ICON_THEME_PATH}/index.theme" "${ICON_THEME_PATH}/icon-theme.cache")
|
|
|
|
else()
|
|
|
|
# only index.theme required when icons are provided as fallback anyways
|
|
|
|
file(GLOB GLOBBED_ICON_THEME_INDEX_FILES LIST_DIRECTORIES false "${ICON_THEME_PATH}/index.theme")
|
|
|
|
endif()
|
2016-08-27 15:00:55 +02:00
|
|
|
# make the first specified built-in the default theme
|
2016-07-16 23:12:02 +02:00
|
|
|
if(NOT EXISTS "${DEFAULT_THEME_INDEX_FILE}")
|
2017-02-11 02:56:28 +01:00
|
|
|
file(MAKE_DIRECTORY "${BUILTIN_ICONS_DIR}/default")
|
2016-08-27 15:00:55 +02:00
|
|
|
file(WRITE "${DEFAULT_THEME_INDEX_FILE}" "[Icon Theme]\nInherits=${NEW_ICON_THEME_NAME}")
|
2016-07-16 23:12:02 +02:00
|
|
|
list(APPEND ICON_THEME_FILES "<file>default/index.theme</file>")
|
|
|
|
endif()
|
2016-11-01 14:05:48 +01:00
|
|
|
# find required icons, except the icon theme is provided as fallback anyways
|
|
|
|
if(NOT ICON_THEME STREQUAL FALLBACK_ICON_THEME)
|
|
|
|
set(GLOB_PATTERNS)
|
|
|
|
foreach(REQUIRED_ICON ${REQUIRED_ICONS})
|
|
|
|
list(APPEND GLOB_PATTERNS
|
|
|
|
"${ICON_THEME_PATH}/${REQUIRED_ICON}"
|
|
|
|
"${ICON_THEME_PATH}/${REQUIRED_ICON}.*"
|
|
|
|
"${ICON_THEME_PATH}/*/${REQUIRED_ICON}"
|
|
|
|
"${ICON_THEME_PATH}/*/${REQUIRED_ICON}.*"
|
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
file(GLOB_RECURSE GLOBBED_ICON_THEME_FILES LIST_DIRECTORIES false ${GLOB_PATTERNS})
|
|
|
|
else()
|
|
|
|
message(STATUS "Icon files for specified theme \"${ICON_THEME}\" are skipped because these are provided as fallback anyways.")
|
|
|
|
set(GLOBBED_ICON_THEME_FILES)
|
|
|
|
endif()
|
2016-08-27 15:00:55 +02:00
|
|
|
# make temporary copy of required icons and create resource list for Qt
|
2016-07-16 23:12:02 +02:00
|
|
|
foreach(ICON_THEME_FILE ${GLOBBED_ICON_THEME_INDEX_FILES} ${GLOBBED_ICON_THEME_FILES})
|
2017-02-11 02:04:12 +01:00
|
|
|
# resolve symlinks
|
2016-07-16 23:12:02 +02:00
|
|
|
if(IS_SYMLINK "${ICON_THEME_FILE}")
|
|
|
|
string(REGEX REPLACE "^${ICON_SEARCH_PATH}/" "" ICON_THEME_FILE_RELATIVE_PATH "${ICON_THEME_FILE}")
|
2016-08-27 15:00:55 +02:00
|
|
|
string(REGEX REPLACE "(^[^/\\]+)" "${NEW_ICON_THEME_NAME}" NEW_ICON_THEME_FILE_RELATIVE_PATH "${ICON_THEME_FILE_RELATIVE_PATH}")
|
|
|
|
set(ICON_THEME_FILE_ALIAS " alias=\"${NEW_ICON_THEME_FILE_RELATIVE_PATH}\"")
|
2016-07-16 23:12:02 +02:00
|
|
|
get_filename_component(ICON_THEME_FILE "${ICON_THEME_FILE}" REALPATH)
|
|
|
|
else()
|
2016-07-27 21:42:27 +02:00
|
|
|
unset(ICON_THEME_FILE_ALIAS)
|
2016-07-16 23:12:02 +02:00
|
|
|
endif()
|
|
|
|
string(REGEX REPLACE "^${ICON_SEARCH_PATH}/" "" ICON_THEME_FILE_RELATIVE_PATH "${ICON_THEME_FILE}")
|
2016-08-27 15:00:55 +02:00
|
|
|
string(REGEX REPLACE "(^[^/\\]+)" "${NEW_ICON_THEME_NAME}" NEW_ICON_THEME_FILE_RELATIVE_PATH "${ICON_THEME_FILE_RELATIVE_PATH}")
|
2016-07-16 23:12:02 +02:00
|
|
|
get_filename_component(ICON_THEME_FILE_DIR "${ICON_THEME_FILE_RELATIVE_PATH}" DIRECTORY)
|
2016-08-27 15:00:55 +02:00
|
|
|
string(REGEX REPLACE "(^[^/\\]+)" "${NEW_ICON_THEME_NAME}" NEW_ICON_THEME_FILE_DIR "${ICON_THEME_FILE_DIR}")
|
2017-02-11 02:56:28 +01:00
|
|
|
file(MAKE_DIRECTORY "${BUILTIN_ICONS_DIR}/${NEW_ICON_THEME_FILE_DIR}")
|
|
|
|
file(COPY "${ICON_THEME_FILE}" DESTINATION "${BUILTIN_ICONS_DIR}/${NEW_ICON_THEME_FILE_DIR}")
|
2016-08-27 15:00:55 +02:00
|
|
|
list(APPEND ICON_THEME_FILES "<file${ICON_THEME_FILE_ALIAS}>${NEW_ICON_THEME_FILE_RELATIVE_PATH}</file>")
|
2016-07-16 23:12:02 +02:00
|
|
|
endforeach()
|
|
|
|
break()
|
|
|
|
endif()
|
2016-08-27 15:00:55 +02:00
|
|
|
unset(ICON_THEME_PATH)
|
2016-07-16 23:12:02 +02:00
|
|
|
endforeach()
|
2016-08-27 15:00:55 +02:00
|
|
|
if(NOT ICON_THEME_PATH)
|
|
|
|
message(FATAL_ERROR "The specified icon theme \"${ICON_THEME}\" coud not be found.")
|
|
|
|
endif()
|
2016-07-16 23:12:02 +02:00
|
|
|
endforeach()
|
2017-02-09 23:34:13 +01:00
|
|
|
set(BUILTIN_ICON_THEMES_QRC_FILE "${CMAKE_CURRENT_BINARY_DIR}/icons/${META_PROJECT_NAME}_builtinicons.qrc")
|
2016-07-27 18:51:25 +02:00
|
|
|
list(REMOVE_DUPLICATES ICON_THEME_FILES)
|
2016-07-16 23:12:02 +02:00
|
|
|
string(CONCAT BUILTIN_ICON_THEMES_QRC_FILE_CONTENT "<RCC><qresource prefix=\"/icons\">" ${ICON_THEME_FILES} "</qresource></RCC>")
|
|
|
|
file(WRITE "${BUILTIN_ICON_THEMES_QRC_FILE}" "${BUILTIN_ICON_THEMES_QRC_FILE_CONTENT}")
|
|
|
|
list(APPEND RES_FILES "${BUILTIN_ICON_THEMES_QRC_FILE}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-07-10 00:22:20 +02:00
|
|
|
|
2017-08-31 02:14:52 +02:00
|
|
|
# export Qt resources from specified RES_FILES
|
2017-02-11 02:04:12 +01:00
|
|
|
foreach(RES_FILE ${RES_FILES})
|
|
|
|
get_filename_component(RES_EXT ${RES_FILE} EXT)
|
|
|
|
if(RES_EXT STREQUAL ".qrc")
|
|
|
|
get_filename_component(RES_NAME ${RES_FILE} NAME_WE)
|
|
|
|
list(APPEND QT_RESOURCES "${RES_NAME}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2017-08-06 00:41:00 +02:00
|
|
|
|
2017-08-31 02:14:52 +02:00
|
|
|
# export Qt resources required by static libraries the static library depends on
|
|
|
|
if(STATIC_LIBRARIES_QT_RESOURCES)
|
|
|
|
list(REMOVE_DUPLICATES STATIC_LIBRARIES_QT_RESOURCES)
|
|
|
|
list(APPEND QT_RESOURCES ${STATIC_LIBRARIES_QT_RESOURCES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# enable Qt resources required by static libraries the shared library or application depends on
|
2017-08-06 00:41:00 +02:00
|
|
|
if(LIBRARIES_QT_RESOURCES)
|
|
|
|
list(REMOVE_DUPLICATES LIBRARIES_QT_RESOURCES)
|
|
|
|
|
|
|
|
# make enabling resources of static dependencies available via config.h
|
|
|
|
unset(ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES)
|
|
|
|
foreach(QT_RESOURCE ${LIBRARIES_QT_RESOURCES})
|
|
|
|
set(ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES
|
|
|
|
"${ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES} \\\n struct initializer_${QT_RESOURCE} { \\\n initializer_${QT_RESOURCE}() { Q_INIT_RESOURCE(${QT_RESOURCE}); } \\\n ~initializer_${QT_RESOURCE}() { Q_CLEANUP_RESOURCE(${QT_RESOURCE}); } \\\n } dummy_${QT_RESOURCE};"
|
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# prevent duplicated resources
|
2017-02-11 02:04:12 +01:00
|
|
|
if(QT_RESOURCES)
|
|
|
|
list(REMOVE_DUPLICATES QT_RESOURCES)
|
|
|
|
endif()
|
|
|
|
|
2017-02-09 16:20:15 +01:00
|
|
|
# enable moc, uic and rcc by default for all targets
|
2016-04-16 00:50:31 +02:00
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
2016-07-10 00:22:20 +02:00
|
|
|
if(WIDGETS_UI_FILES AND WIDGETS_GUI)
|
2016-04-16 00:50:31 +02:00
|
|
|
set(CMAKE_AUTOUIC ON)
|
2016-04-16 18:32:56 +02:00
|
|
|
if(INSTALL_UI_HEADER)
|
2016-08-19 16:16:10 +02:00
|
|
|
# also add install for header files generated by uic
|
2016-04-16 18:32:56 +02:00
|
|
|
foreach(UI_FILE WIDGETS_UI_FILES)
|
|
|
|
get_filename_component(UI_NAME "${UI_FILE}" NAME_WE)
|
|
|
|
install(
|
|
|
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/ui_${UI_NAME}.h"
|
|
|
|
DESTINATION "include/${META_PROJECT_NAME}/ui"
|
2016-08-19 16:16:10 +02:00
|
|
|
COMPONENT ui-header
|
2016-04-16 18:32:56 +02:00
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2016-04-16 00:50:31 +02:00
|
|
|
endif()
|
2017-02-11 02:31:43 +01:00
|
|
|
|
|
|
|
set(QT_CONFIGURED YES)
|