From 310f337f57aa31118863622f062493ad21f4cd72 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sat, 22 Mar 2025 08:19:42 -0400 Subject: [PATCH] Add instructions to install with qt-base-dev. --- CMakeLists.txt | 26 ++++++++++++++++++++++++-- README.md | 26 ++++++++++++++++---------- example-app/CMakeLists.txt | 35 +++++++++++++++++++++-------------- src/app/CMakeLists.txt | 36 ++++++++++++++++++++---------------- src/qtk/CMakeLists.txt | 2 +- 5 files changed, 82 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c64a3b..e5b577f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ ## Author: Shaun Reed | Contact: shaunrd0@gmail.com | URL: www.shaunreed.com ## ## All Content (c) 2025 Shaun Reed, all rights reserved ## ################################################################################ -cmake_minimum_required(VERSION 3.23) +cmake_minimum_required(VERSION 3.28) ################################################################################ # Constants @@ -84,7 +84,7 @@ endif() set(QT_INSTALL_DIR "$ENV{HOME}/Qt/6.5.0/gcc_64/lib/cmake" CACHE PATH "Path to Qt6 install.") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install") -endif () +endif() set(QTK_RESOURCES "${CMAKE_SOURCE_DIR}/resources") set(QTK_OSX_ICONS ${CMAKE_SOURCE_DIR}/resources/icons/osx/kilroy.icns) @@ -205,3 +205,25 @@ foreach(VAR_NAME IN LISTS VAR_NAMES VAR_PATHS) message(STATUS "[Qtk] ${VAR_NAME}=${${VAR_NAME}}") endif() endforeach() +message(STATUS "[Qtk] Installation prefix: ${CMAKE_INSTALL_PREFIX}") +message(STATUS "[Qtk] Found Qt6: ${Qt6Core_VERSION}") + +# qt_generate_deploy_app_script is supported on Linux in QtCore >= 6.5.0. +# qt_generate_deploy_app_script supports Windows and OSX in QtCore >= 6.3. +# https://doc.qt.io/qt-6.5/qt-generate-deploy-app-script.html +# https://doc.qt.io/archives/qt-6.4/qt-generate-deploy-app-script.html +# The application can still build and run, we just can't install. +if(QTK_GUI OR QTK_EXAMPLE) + if(UNIX AND NOT APPLE) + # Ubuntu 24.04 provides QtCore 6.4.2 in qt-base-dev. + # This version of qt_generate_deploy_app_script does not support Linux. + if (Qt6_VERSION VERSION_LESS "6.5.0") + message(WARNING "[Qtk] Installation is only supported on Qt >=6.5.\n") + endif() + elseif(APPLE OR WIN32) + # Predates qt_generate_deploy_app_script. + if (Qt6_VERSION VERSION_LESS "6.3.0") + message(WARNING "[Qtk] Installation is only supported on Qt >=6.5.\n") + endif() + endif() +endif() diff --git a/README.md b/README.md index 95b1315..7f0c4ee 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Key features that are planned: - [ ] Basic text editor for quickly modifying shaders attached to objects. - [ ] Reduce size of application resources and git references. -For examples of using the libqtk API, see the [example-app](./example-app) +For examples of using libqtk, see the [example-app](./example-app) project in the root of this repository. To get textures loading on models look @@ -82,13 +82,19 @@ Simply open the root `CMakeLists.txt` with either of these editors and default configurations will be loaded. To simplify providing Qt to the build, Qt Creator is the recommended option. -This project has been ported to **Qt 6.6.0**, which is not yet available in -Ubuntu apt repositories. -To run this project, you will *need* to -install [Qt6 Open Source Binaries](https://www.qt.io/download-qt-installer) for -your system, **version 6.6.0** or later. -Be sure to take note of the Qt6 installation directory, as we will need it to -correctly set our `CMAKE_PREFIX_PATH` in the next steps. +If you have manually installed [Qt6 Open Source Binaries](https://www.qt.io/download-qt-installer) +for your system, be sure to correctly set your `CMAKE_PREFIX_PATH` in the next steps. +On Ubuntu 24.04 the default installation directory to use for this path using Qt 6.5.0 is `$HOME/Qt/6.5.0/gcc_64/lib/cmake`. + +The Ubuntu apt repositories contain all the packages we need to build all targets. +To build Qtk desktop application with the scene in the screenshots below run the following commands. + +```bash +sudo apt update && sudo apt install cmake build-essential git ccache libxkbcommon-dev libassimp-dev qt6-base-dev qt6-tools-dev +cmake -DQTK_GUI_SCENE=ON -B build +cmake --build build +./build/bin/qtk_gui +``` #### Build Options @@ -146,7 +152,7 @@ For this example we will configure the build with all options enabled. In the separate sections below we can install individual components with cmake. ```bash -sudo apt update -y && sudo apt install libassimp-dev cmake build-essential git ccache libgl1-mesa-dev libglvnd-dev zlib1g-dev -y +sudo apt update -y && sudo apt install cmake build-essential git ccache libxkbcommon-dev libassimp-dev qt6-base-dev qt6-tools-dev -y git clone https://github.com/shaunrd0/qtk cd qtk # Configure the build with all components enabled @@ -265,7 +271,7 @@ This project is using `clang-format` version `>=15.0.5`. On Ubuntu 24.04, clang-format 18 is available to install in apt repositories. ```bash -sudo apt install clang-format +sudo apt install clang-format clang-tidy ``` If `clang-format --version` is any earlier than `15.0.0`, running `clang-format` will fail because this project uses configuration options made available since `15.0.0`. diff --git a/example-app/CMakeLists.txt b/example-app/CMakeLists.txt index 71d7565..7bc945d 100644 --- a/example-app/CMakeLists.txt +++ b/example-app/CMakeLists.txt @@ -80,17 +80,24 @@ target_link_libraries(qtk_example PUBLIC Qt6::Widgets Qt6::OpenGLWidgets Qt6::Co target_link_libraries(qtk_example PUBLIC Qtk::qtk) target_include_directories(qtk_example PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") -install( - TARGETS qtk_example - COMPONENT qtk_example - BUNDLE DESTINATION . - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static - RUNTIME DESTINATION bin -) -qt_generate_deploy_app_script( - TARGET qtk_example - OUTPUT_SCRIPT QTK_EXAMPLE_DEPLOY_SCRIPT - NO_UNSUPPORTED_PLATFORM_ERROR -) -install(SCRIPT ${QTK_EXAMPLE_DEPLOY_SCRIPT} COMPONENT qtk_example) +# qt_generate_deploy_app_script supports Windows and OSX in QtCore >= 6.3. +# qt_generate_deploy_app_script is supported on Linux in QtCore >= 6.5.0. +if((Qt6_VERSION VERSION_GREATER_EQUAL "6.3.0" AND (WIN32 OR APPLE)) + OR Qt6_VERSION VERSION_GREATER_EQUAL "6.5.0") + install( + TARGETS qtk_example + COMPONENT qtk_example + BUNDLE DESTINATION . + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static + RUNTIME DESTINATION bin + ) + qt_generate_deploy_app_script( + TARGET qtk_example + OUTPUT_SCRIPT QTK_EXAMPLE_DEPLOY_SCRIPT + NO_UNSUPPORTED_PLATFORM_ERROR + ) + install(SCRIPT ${QTK_EXAMPLE_DEPLOY_SCRIPT} COMPONENT qtk_example) +elseif(NOT Qtk_IS_TOP_LEVEL) + message(WARNING "[Qtk] Installation is only supported on Qt >=6.5.\n") +endif() \ No newline at end of file diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 443a8a0..4b4bc4c 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -37,7 +37,7 @@ qt_add_executable(qtk_gui ${QTK_GUI_SOURCES}) target_link_libraries(qtk_gui PRIVATE qtk_plugin_library) if (QTK_GUI_SCENE) - target_compile_definitions(qtk_gui PUBLIC QTK_GUI_SCENE) + target_compile_definitions(qtk_gui PRIVATE -DQTK_GUI_SCENE) endif() if (WIN32) @@ -56,21 +56,25 @@ elseif(APPLE) ) endif() -install( - TARGETS qtk_gui - COMPONENT qtk_gui - BUNDLE DESTINATION . - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin -) - -qt_generate_deploy_app_script( - TARGET qtk_gui - OUTPUT_SCRIPT QTK_DEPLOY_SCRIPT - NO_UNSUPPORTED_PLATFORM_ERROR -) -install(SCRIPT ${QTK_DEPLOY_SCRIPT} COMPONENT qtk_gui) +# qt_generate_deploy_app_script supports Windows and OSX in QtCore >= 6.3. +# qt_generate_deploy_app_script is supported on Linux in QtCore >= 6.5.0. +if((Qt6_VERSION VERSION_GREATER_EQUAL "6.3.0" AND (WIN32 OR APPLE)) + OR Qt6_VERSION VERSION_GREATER_EQUAL "6.5.0") + install( + TARGETS qtk_gui + COMPONENT qtk_gui + BUNDLE DESTINATION . + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + ) + qt_generate_deploy_app_script( + TARGET qtk_gui + OUTPUT_SCRIPT QTK_DEPLOY_SCRIPT + NO_UNSUPPORTED_PLATFORM_ERROR + ) + install(SCRIPT ${QTK_DEPLOY_SCRIPT} COMPONENT qtk_gui) +endif() if(WIN32) if(MSVC AND TARGET Qt6::qmake) diff --git a/src/qtk/CMakeLists.txt b/src/qtk/CMakeLists.txt index 34c7cd3..254a3d4 100644 --- a/src/qtk/CMakeLists.txt +++ b/src/qtk/CMakeLists.txt @@ -55,7 +55,7 @@ target_sources( ) if(QTK_DEBUG) - target_compile_definitions(qtk PUBLIC QTK_DEBUG) + target_compile_definitions(qtk PUBLIC -DQTK_DEBUG) endif() set_target_properties(