mirror of https://github.com/linuxdeepin/dtkcore
chore: add DtkDConfig package
Add DtkDConfigConfig.cmake file. Now find_package(DtkCore) can also find DConfig support. Log: add DtkDConfig package
This commit is contained in:
parent
191a8fb64f
commit
d7433df0b2
|
@ -25,7 +25,7 @@ Copyright: None
|
|||
License: CC0-1.0
|
||||
|
||||
# qt
|
||||
Files: *.pro *.pri *.qrc
|
||||
Files: *.pro *.pri *.qrc *.prf
|
||||
Copyright: None
|
||||
License: CC0-1.0
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required (VERSION 3.10)
|
||||
|
||||
set (DVERSION "5.6.2" CACHE STRING "define project version")
|
||||
set (DVERSION "5.6.4" CACHE STRING "define project version")
|
||||
|
||||
project (DtkCore
|
||||
VERSION ${DVERSION}
|
||||
|
@ -19,7 +19,8 @@ endif ()
|
|||
set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/dtk${PROJECT_VERSION_MAJOR}/DCore")
|
||||
set (TOOL_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/dtk${PROJECT_VERSION_MAJOR}/DCore/bin")
|
||||
set (LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
|
||||
set (MKSPECS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/qt5/mkspecs/modules" CACHE STRING "INSTALL DIR FOR qt pri files")
|
||||
set (MKSPECS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/qt5/mkspecs/modules" CACHE STRING "Install dir for qt pri files")
|
||||
set (FEATURES_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/qt5/mkspecs/features" CACHE STRING "Install dir for qt prf files")
|
||||
set (CONFIG_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/DtkCore" CACHE STRING "Install dir for cmake config files")
|
||||
|
||||
set (BUILD_EXAMPLES ON CACHE BOOL "Build examples")
|
||||
|
@ -67,11 +68,12 @@ if(BUILD_EXAMPLES)
|
|||
add_subdirectory(examples)
|
||||
endif()
|
||||
add_subdirectory(tools)
|
||||
install(FILES cmake/DtkCMake/DtkCMakeConfig.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/DtkCMake/")
|
||||
install(FILES cmake/DtkCMake/DtkCMakeConfig.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/DtkCMake")
|
||||
install(FILES cmake/DtkTools/DtkToolsConfig.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/DtkTools")
|
||||
install(FILES cmake/DtkTools/DtkSettingsToolsMacros.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/DtkTools")
|
||||
install(FILES cmake/DtkDConfig/DtkDConfigConfig.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/DtkDConfig")
|
||||
|
||||
configure_package_config_file(misc/DtkConfig.cmake.in
|
||||
configure_package_config_file(misc/DtkCoreConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/DtkCoreConfig.cmake
|
||||
INSTALL_DESTINATION ${CONFIG_CMAKE_INSTALL_DIR}
|
||||
PATH_VARS TOOL_INSTALL_DIR)
|
||||
|
@ -88,6 +90,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dtkcore.pc DESTINATION "${CMAKE_INSTAL
|
|||
|
||||
configure_file(misc/qt_lib_dtkcore.pri.in qt_lib_dtkcore.pri @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qt_lib_dtkcore.pri DESTINATION "${MKSPECS_INSTALL_DIR}")
|
||||
install(FILES misc/dtk_install_dconfig.prf DESTINATION ${FEATURES_INSTALL_DIR})
|
||||
set(CONFIGNAME include/global/dtkcore_config.h)
|
||||
file(WRITE ${CONFIGNAME}
|
||||
"// it is auto make config\n"
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
# SPDX-FileCopyrightText: 2022 Uniontech Software Technology Co.,Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
# This cmake file is used to deploy files that dconfig's meta and override configure.
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
# get subpath according `FILE` and `BASE`.
|
||||
# e.g: FILE = /a/b/c/d/foo.json, BASE = /a/b, then return SUBPATH = /c/d/
|
||||
function(get_subpath FILE BASE SUBPATH)
|
||||
get_filename_component(BASE_FILE_PATH ${BASE} REALPATH)
|
||||
get_filename_component(FILE_PATH ${FILE} REALPATH)
|
||||
string(REPLACE ${BASE_FILE_PATH} "" SUBPATH_FILE_NAME ${FILE_PATH})
|
||||
get_filename_component(SUBPATH_PATH ${SUBPATH_FILE_NAME} DIRECTORY)
|
||||
|
||||
set(${SUBPATH} ${SUBPATH_PATH} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(NOT DEFINED DSG_DATA_DIR)
|
||||
set(DSG_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/dsg)
|
||||
endif()
|
||||
|
||||
add_definitions(-DDSG_DATA_DIR=${DSG_DATA_DIR})
|
||||
# deploy some `meta` 's configure.
|
||||
#
|
||||
# FILES - deployed files.
|
||||
# BASE - used to get subpath, if it's empty, only copy files, and ignore it's subpath structure.
|
||||
# APPID - working for the app.
|
||||
# COMMONID - working for common.
|
||||
#
|
||||
# e.g:
|
||||
# dconfig_meta_files(APPID dconfigexample BASE ./configs FILES ./configs/example.json ./configs/a/example.json)
|
||||
#
|
||||
function(dconfig_meta_files)
|
||||
set(oneValueArgs BASE APPID COMMONID)
|
||||
set(multiValueArgs FILES)
|
||||
|
||||
cmake_parse_arguments(METAITEM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
foreach(_current_FILE ${METAITEM_FILES})
|
||||
set(SUBPATH "")
|
||||
if (DEFINED METAITEM_BASE)
|
||||
GET_SUBPATH(${_current_FILE} ${METAITEM_BASE} SUBPATH)
|
||||
endif()
|
||||
|
||||
if (DEFINED METAITEM_APPID)
|
||||
install(FILES "${_current_FILE}" DESTINATION ${DSG_DATA_DIR}/configs/${METAITEM_APPID}/${SUBPATH})
|
||||
elseif (DEFINED METAITEM_COMMONID)
|
||||
install(FILES ${_current_FILE} DESTINATION ${DSG_DATA_DIR}/configs/${SUBPATH})
|
||||
else()
|
||||
message(FATAL_ERROR "Please set APPID or COMMONID for the meta item." ${_current_FILE})
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
||||
# deploy some `meta` 's override configure.
|
||||
#
|
||||
# configuration for the `meta_name` 's override configure.
|
||||
#
|
||||
# FILES - deployed files.
|
||||
# BASE - used to get subpath, if it's empty, only copy files, and ignore it's subpath structure.
|
||||
# APPID - working for the app, if it's empty, working for all app.
|
||||
# META_NAME - override for the meta configure.
|
||||
#
|
||||
# e.g :
|
||||
#dconfig_override_files(APPID dconfigexample BASE ./configs META_NAME example FILES ./configs/dconf-example.override.json ./configs/a/dconf-example.override.a.json)
|
||||
#
|
||||
function(dconfig_override_files)
|
||||
set(options)
|
||||
set(oneValueArgs BASE APPID META_NAME)
|
||||
set(multiValueArgs FILES)
|
||||
|
||||
cmake_parse_arguments(OVERRIDEITEM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT DEFINED OVERRIDEITEM_META_NAME)
|
||||
message(FATAL_ERROR "Please set meta_name for the override configuration." ${FILES})
|
||||
endif()
|
||||
|
||||
foreach(_current_FILE ${OVERRIDEITEM_FILES})
|
||||
set(SUBPATH "")
|
||||
if (DEFINED OVERRIDEITEM_BASE)
|
||||
GET_SUBPATH(${_current_FILE} ${OVERRIDEITEM_BASE} SUBPATH)
|
||||
endif()
|
||||
|
||||
if (DEFINED OVERRIDEITEM_APPID)
|
||||
install(FILES "${_current_FILE}" DESTINATION ${DSG_DATA_DIR}/configs/overrides/${OVERRIDEITEM_APPID}/${OVERRIDEITEM_META_NAME}/${SUBPATH})
|
||||
else()
|
||||
install(FILES "${_current_FILE}" DESTINATION ${DSG_DATA_DIR}/configs/overrides/${OVERRIDEITEM_META_NAME}/${SUBPATH})
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
|
@ -9,7 +9,7 @@ find_dependency(Qt5Xml)
|
|||
if (LINUX)
|
||||
find_dependency(Qt5DBus)
|
||||
endif()
|
||||
|
||||
find_dependency(DtkDConfig)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/DtkCoreTargets.cmake)
|
||||
|
||||
set(DtkCore_LIBRARIES Dtk::Core)
|
|
@ -0,0 +1,83 @@
|
|||
# This prf file is used to deploy files that dconfig's meta and override configure.
|
||||
#
|
||||
# get variable `$$DSG_DATA_DIR` 's value, it’s consistent with class DConfigFile code.
|
||||
isEmpty(DSG_DATA_DIR) {
|
||||
isEmpty(PREFIX) {
|
||||
DSG_DATA_DIR=/usr/share/dsg
|
||||
} else {
|
||||
DSG_DATA_DIR=$$PREFIX/share/dsg
|
||||
}
|
||||
}
|
||||
|
||||
# deploy some `meta` 's configure.
|
||||
#
|
||||
# files - deployed files.
|
||||
# base - used to get subpath, if it's empty, only copy files, and ignore it's subpath structure.
|
||||
# appid - working for the app, if it's empty, depending on `TEMPLATE`.
|
||||
# commonid - working for common, if it's empyt, depending on `TEMPLATE`.
|
||||
#
|
||||
# e.g:
|
||||
# dconfig_example.files += \
|
||||
# $$PWD/configs/dconf-example.json \
|
||||
# $$PWD/configs/a/dconf-example.json
|
||||
# dconfig_example.base = $$PWD/configs
|
||||
# dconfig_example.appid = $$TARGET
|
||||
#
|
||||
# dconfig_example2.files += $$PWD/configs/a/dconf-example.json
|
||||
#
|
||||
# DCONFIG_META_FILES += dconfig_example dconfig_example2
|
||||
#
|
||||
for(metaitem, DCONFIG_META_FILES) {
|
||||
eval(dconfig_meta_$${metaitem}.files = $$eval($${metaitem}.files))
|
||||
eval(dconfig_meta_$${metaitem}.base = $$eval($${metaitem}.base))
|
||||
isEmpty($${metaitem}.appid) {
|
||||
is_common_configuration=true
|
||||
isEmpty($${metaitem}.commonid) {
|
||||
equals(TEMPLATE, app) {
|
||||
eval(dconfig_meta_$${metaitem}.path = $$DSG_DATA_DIR/configs/$$TARGET/)
|
||||
is_common_configuration=false
|
||||
}
|
||||
}
|
||||
if ($$is_common_configuration) {
|
||||
eval(dconfig_meta_$${metaitem}.path = $$DSG_DATA_DIR/configs)
|
||||
}
|
||||
} else {
|
||||
eval(dconfig_meta_$${metaitem}.path = $$DSG_DATA_DIR/configs/$$eval($${metaitem}.appid))
|
||||
}
|
||||
INSTALLS += dconfig_meta_$${metaitem}
|
||||
}
|
||||
|
||||
|
||||
# deploy some `meta` 's override configure.
|
||||
#
|
||||
# configuration for the `meta_name` 's override configure.
|
||||
#
|
||||
# files - deployed files.
|
||||
# base - used to get subpath, if it's empty, only copy files, and ignore it's subpath structure.
|
||||
# appid - working for the app, if it's empty, working for all app.
|
||||
# meta_name - override for the meta configure.
|
||||
#
|
||||
# e.g :
|
||||
# dconfig_example.files += \
|
||||
# $$PWD/configs/dconf-example.override.json \
|
||||
# $$PWD/configs/a/dconf-example.override.a.json
|
||||
# dconfig_example.base = $$PWD/configs
|
||||
# dconfig_example.meta_name = example
|
||||
# dconfig_example.appid = $$TARGET
|
||||
#
|
||||
# dconfig_example2.files += $$PWD/configs/a/dconf-example.override.a.json
|
||||
# dconfig_example2.meta_name = example2
|
||||
#
|
||||
# DCONFIG_OVERRIDE_FILES += dconfig_example dconfig_example2
|
||||
#
|
||||
for(overrideitem, DCONFIG_OVERRIDE_FILES) {
|
||||
eval(dconfig_override_$${overrideitem}.files = $$eval($${overrideitem}.files))
|
||||
eval(dconfig_override_$${overrideitem}.base = $$eval($${overrideitem}.base))
|
||||
isEmpty($${overrideitem}.meta_name) : error("Please set meta_name for the override configuration." $${overrideitem})
|
||||
isEmpty($${overrideitem}.appid) {
|
||||
eval(dconfig_override_$${overrideitem}.path = $$DSG_DATA_DIR/configs/overrides/$$eval($${overrideitem}.meta_name))
|
||||
} else {
|
||||
eval(dconfig_override_$${overrideitem}.path = $$DSG_DATA_DIR/configs/overrides/$$eval($${overrideitem}.appid)/$$eval($${overrideitem}.meta_name))
|
||||
}
|
||||
INSTALLS += dconfig_override_$${overrideitem}
|
||||
}
|
Loading…
Reference in New Issue