Skip to content

Commit

Permalink
feat: Support install for example and template in qt6
Browse files Browse the repository at this point in the history
  Creating wizard.json and dtk-exhibition.desktop depending on qt version.
`dtk-exhibition` is installed from `/usr/bin/` to `xxx/dtk6/DDeclarative/`.
  • Loading branch information
18202781743 committed Aug 17, 2023
1 parent 406fdde commit 466691a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ set(BUILD_DOCS ON CACHE BOOL "Generate doxygen-based documentation")

set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE STRING "Library install path")
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/dtk${PROJECT_VERSION_MAJOR}/DDeclarative" CACHE STRING "Headers install path")
set(TEMPLATE_INSTALL_DIR "share/qtcreator/templates/wizards/projects/qml-app-template" CACHE STRING "Directory to install QtCreator template")
set(TEMPLATE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/qtcreator/templates/wizards/projects/qml${DTK_VERSION_MAJOR}-app-template" CACHE STRING "Directory to install QtCreator template")
set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/Dtk${DTK_VERSION_MAJOR}Declarative" CACHE STRING "CMake config file install directory")
set(PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig" CACHE STRING "Directory to install pkg-config file")
set(MKSPECS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/qt${QT_VERSION_MAJOR}/mkspecs/modules" CACHE STRING "Qt pri module install directory")
Expand Down Expand Up @@ -112,7 +112,17 @@ if(BUILD_TESTING)
endif()

# Install wizards template
install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/misc/qml-app-template/" DESTINATION "${TEMPLATE_INSTALL_DIR}")
set(QML_TEMPLATE_QTVERSION_INDEX 0)
if(EnableQt5)
set(QML_TEMPLATE_QTVERSION_INDEX 3)
endif()
configure_package_config_file(
"${CMAKE_CURRENT_LIST_DIR}/misc/qml-app-template/wizard.json.in"
"${CMAKE_CURRENT_BINARY_DIR}/wizard.json"
INSTALL_DESTINATION "${TEMPLATE_INSTALL_DIR}"
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/wizard.json" DESTINATION "${TEMPLATE_INSTALL_DIR}")
install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/misc/qml-app-template/" DESTINATION "${TEMPLATE_INSTALL_DIR}" FILES_MATCHING PATTERN "*" PATTERN "*.in" EXCLUDE)

configure_package_config_file(
"${CMAKE_CURRENT_LIST_DIR}/misc/DtkDeclarativeConfig.cmake.in"
Expand Down
14 changes: 12 additions & 2 deletions examples/exhibition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,15 @@ target_link_libraries(${BIN_NAME} PRIVATE
Dtk${DTK_VERSION_MAJOR}::Gui
)

install(TARGETS ${BIN_NAME} DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES ${CMAKE_CURRENT_LIST_DIR}/dtk-exhibition.desktop DESTINATION "${CMAKE_INSTALL_DATADIR}/applications")
set(EXAMPLE_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
if (EnableQt6)
set(EXAMPLE_INSTALL_DIR "${LIB_INSTALL_DIR}/dtk${PROJECT_VERSION_MAJOR}/DDeclarative")
endif()
configure_package_config_file(
"${CMAKE_CURRENT_LIST_DIR}/dtk-exhibition.desktop.in"
"${CMAKE_CURRENT_BINARY_DIR}/dtk${DTK_VERSION_MAJOR}-exhibition.desktop"
INSTALL_DESTINATION "${EXAMPLE_INSTALL_DIR}"
)

install(TARGETS ${BIN_NAME} DESTINATION ${EXAMPLE_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dtk${DTK_VERSION_MAJOR}-exhibition.desktop DESTINATION "${CMAKE_INSTALL_DATADIR}/applications")
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[Desktop Entry]
Categories=DTK;Development;
Exec=@CMAKE_INSTALL_PREFIX@/@EXAMPLE_INSTALL_DIR@/dtk-exhibition
Icon=example
Name=DTK Exhibition
Exec=dtk-exhibition
Type=Application
Icon=example
Categories=DTK;Development;
X-Deepin-Vendor=user-custom
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"version": 1,
"supportedProjectTypes": [ "CMakeProjectManager.CMakeProject"],
"id": "A.Dtk QtQuick Application",
"id": "A.Dtk@DTK_VERSION_MAJOR@ QtQuick Application",
"category": "F.Project",
"trDescription": "Creates a Dtk QtQuick Application for UOS.",
"trDisplayName": "Dtk QtQuick Application",
"trDescription": "Creates a Dtk@DTK_VERSION_MAJOR@ QtQuick Application for UOS.",
"trDisplayName": "Dtk@DTK_VERSION_MAJOR@ QtQuick Application",
"trDisplayCategory": "Dtk QML Application",
"featuresRequired": [ "QtSupport.Wizards.FeatureQt.5.6" ],
"options":
Expand Down Expand Up @@ -39,7 +39,7 @@
"type": "ComboBox",
"data":
{
"index": 3,
"index": @QML_TEMPLATE_QTVERSION_INDEX@,
"items":
[
{
Expand Down

0 comments on commit 466691a

Please sign in to comment.