From eef00632d4c039b808d2aae9075cf5475c618a8b Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Fri, 14 Mar 2025 15:04:49 -0400 Subject: [PATCH] Cmake changes. --- CMakeLists.txt | 2 ++ README.md | 9 +++-- resources/icons/osx/README.md | 13 ------- resources/resources.qrc | 2 +- src/CMakeLists.txt | 64 ++++++++++++++++++++++++++--------- src/app/CMakeLists.txt | 23 ++++++------- src/app/qtkmainwindow.ui | 2 +- tools/format.sh | 16 ++++++--- 8 files changed, 82 insertions(+), 49 deletions(-) delete mode 100644 resources/icons/osx/README.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 08aa479..1593cef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,8 @@ endif () set(QTK_RESOURCES "${CMAKE_SOURCE_DIR}/resources") set(QTK_OSX_ICONS ${CMAKE_SOURCE_DIR}/resources/icons/osx/kilroy.icns) +string(TIMESTAMP YEAR "%Y") +set(QTK_COPYRIGHT "All Content © 2021-${YEAR} Shaun Reed, all rights reserved.") # Point CMAKE_PREFIX_PATH to Qt6 install directory # If Qtk is built within Qt Creator this is not required. diff --git a/README.md b/README.md index c7c092b..f76b4cb 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Key features that are planned: - [ ] Runtime reloading of modified GLSL shaders attached to objects within scenes. - [ ] Multiple views of a scene at one time. - [ ] Camera control modes such as panning, orbiting, or following objects. -- [ ] Save / load for scene data. The current inheritance model is temporary. +- [ ] Save / load scene data. The current model requires writing C++ code. - [ ] Basic text editor for quickly modifying shaders attached to objects. - [ ] Reduce size of application resources and git references. @@ -226,6 +226,11 @@ Ubuntu clang-format version 18.1.3 (1ubuntu1) CLion has integration for IDE code reformatting actions with `clang-format`. If you're using CLion, the `.clang-format` configuration will be picked up by CLion automatically. +This repository provides the [`tools/format.sh`](./tools/format.sh) helper script to run `clang-tidy` and `clang-format` on Ubuntu 24.04. +Running the script will build Qtk, so it's important to ensure you can manually build from source first. + +If you'd still like to run these tools manually, see the instructions below. + `clang-tidy` can be run with the following commands. ```bash @@ -303,7 +308,7 @@ To generate packages for Qtk desktop application, we should set `-DQTK_GUI=ON`. If this option is not set we will only package libqtk. The NSIS installer will allow component-specific path modification for all of -these installation components through a GUI install application. +these installation components through a Windows GUI install application. ##### Resources diff --git a/resources/icons/osx/README.md b/resources/icons/osx/README.md deleted file mode 100644 index 7309721..0000000 --- a/resources/icons/osx/README.md +++ /dev/null @@ -1,13 +0,0 @@ - -```bash -sudo apt install icnsutils -``` - -```bash -convert icon.png -resize 32x32 kilroy_32.png -convert icon.png -resize 16x16 kilroy_16.png -convert icon.png -resize 48x48 kilroy_48.png -convert icon.png -resize 128x128 kilroy_128.png -convert icon.png -resize 256x256 kilroy_256.png -png2icns png2icns kilroy.icns kilroy_*.png -``` diff --git a/resources/resources.qrc b/resources/resources.qrc index 807349d..cd30d8d 100644 --- a/resources/resources.qrc +++ b/resources/resources.qrc @@ -17,7 +17,7 @@ fontawesome-free-6.2.1-desktop/svgs/regular/folder-open.svg fontawesome-free-6.2.1-desktop/svgs/regular/floppy-disk.svg fontawesome-free-6.2.1-desktop/svgs/brands/git-alt.svg - icon.png + icons/icon.png shaders/fragment/model.frag diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 29e4e48..4d3de10 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,15 +103,19 @@ configure_package_config_file( ) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") +set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md") set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") set(CPACK_PACKAGE_VENDOR "Shaun Reed") -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Qt OpenGL 3D graphics library.") -set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/shaunrd0/qtk") +if (QTK_GUI) + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Qt OpenGL 3D graphics renderer.") +else() + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Qt OpenGL 3D graphics library.") +endif() +set(CPACK_PACKAGE_HOMEPAGE_URL "https://git.shaunreed.com/shaunrd0/qtk") set(CPACK_SOURCE_IGNORE_FILES build*;install;\.git;\.github;\.idea) set(CPACK_PACKAGE_DIRECTORY packages/) set(CPACK_PACKAGE_CONTACT "shaunreed.com") -#set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/resources/icon.png") set(CPACK_THREADS 0) set(CPACK_PACKAGE_INSTALL_DIRECTORY "Qtk") @@ -122,6 +126,47 @@ if (QTK_SUBMODULES) list(REMOVE_ITEM CPACK_COMPONENTS_ALL Unspecified) endif() +if(APPLE) + # OSX + # Set icon for the splash image used in OSX DMG installers. + set(CPACK_PACKAGE_ICON "${QTK_RESOURCES}/icons/osx/kilroy_splash.bmp") + + # Set additional options for the OSX bundle. + set(CPACK_BUNDLE_NAME ${PROJECT_NAME}) + set(CPACK_BUNDLE_PLIST $/Info.plist) + set(CPACK_BUNDLE_ICON ${QTK_OSX_ICONS}) +else(UNIX) + # Linux + # Install icons for qtk. + install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-16.png + DESTINATION /usr/share/icons/hicolor/16x16/apps + RENAME qtk.png) + install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-32.png + DESTINATION /usr/share/icons/hicolor/32x32/apps + RENAME qtk.png) + install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-48.png + DESTINATION /usr/share/icons/hicolor/48x48/apps + RENAME qtk.png) + install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-64.png + DESTINATION /usr/share/icons/hicolor/64x64/apps + RENAME qtk.png) + install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-128.png + DESTINATION /usr/share/icons/hicolor/128x128/apps + RENAME qtk.png) + install(FILES ${QTK_RESOURCES}/icons/linux/kilroy-256.png + DESTINATION /usr/share/icons/hicolor/256x256/apps + RENAME qtk.png) + + # Install the desktop file for qtk. + install(FILES ${QTK_RESOURCES}/qtk.desktop + DESTINATION /usr/share/applications) + + # Set additional options for the debian APT package. + set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PACKAGE_HOMEPAGE_URL}) + set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) +endif() + + # Windows set(CPACK_NSIS_MODIFY_PATH ON) set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON) @@ -134,20 +179,7 @@ set( CPACK_NSIS_DELETE_ICONS_EXTRA "Delete '$SMPROGRAMS\\\\$START_MENU\\\\Qtk.lnk'" ) -# TODO: Icons for NSIS installer. -#set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/resources/icon.png") -#set(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/resources/icon.png") -# Debian -set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PACKAGE_HOMEPAGE_URL}) -set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) - -# OSX -set(CPACK_BUNDLE_NAME ${PROJECT_NAME}) -set(CPACK_BUNDLE_PLIST $/Info.plist) -set(CPACK_BUNDLE_ICON ${QTK_OSX_ICONS}) - -# Platform defaults for source bundles. if(WIN32) set(CPACK_SOURCE_GENERATOR ZIP) else() diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 5f85378..571fcc5 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -57,15 +57,14 @@ set( qt_add_executable(qtk_gui ${QTK_GUI_SOURCES}) target_link_libraries(qtk_gui PRIVATE qtk_plugin_library) -set_target_properties( - qtk_gui PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE - MACOSX_BUNDLE_BUNDLE_NAME Qtk - MACOSX_BUNDLE_ICON_FILE ${QTK_OSX_ICONS} - MACOSX_BUNDLE_GUI_IDENTIFIER ${CMAKE_PROJECT_NAME} - MACOSX_BUNDLE_INFO_STRING ${CMAKE_PROJECT_DESCRIPTION} - MACOSX_BUNDLE_COPYRIGHT "All Content (c) 2023 Shaun Reed, all rights reserved" - MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} - MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} -) +set_target_properties(qtk_gui PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_BUNDLE_NAME Qtk + MACOSX_BUNDLE_ICON_FILE ${QTK_OSX_ICONS} + MACOSX_BUNDLE_GUI_IDENTIFIER ${CMAKE_PROJECT_NAME} + MACOSX_BUNDLE_INFO_STRING ${CMAKE_PROJECT_DESCRIPTION} + MACOSX_BUNDLE_COPYRIGHT ${QTK_COPYRIGHT} + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} +) \ No newline at end of file diff --git a/src/app/qtkmainwindow.ui b/src/app/qtkmainwindow.ui index 324a7d9..494ce37 100644 --- a/src/app/qtkmainwindow.ui +++ b/src/app/qtkmainwindow.ui @@ -21,7 +21,7 @@ - ../resources/icon.png../resources/icon.png + ../resources/icons/icon.png../resources/icons/icon.png true diff --git a/tools/format.sh b/tools/format.sh index 3ec7a2f..a7c2f35 100755 --- a/tools/format.sh +++ b/tools/format.sh @@ -1,7 +1,15 @@ #!/usr/bin/env bash +# Helper script to run clang-tidy and clang-format. +# This should be executed from the root of the repository: +# +# git clone https://git.shaunreed.com/shaunrd0/qtk +# cd qtk +# ./tools/format.sh +# Configure and build qtk cmake -B build && cmake --build build -- -j $(nproc --ignore=1) -clang-tidy -p build/ --fix --config-file=.clang-tidy \ - src/**/*.cpp src/**/*.h example-app/*.cpp example-app/*.h -clang-format -i --style=file:.clang-format \ - src/**/*.cpp src/**/*.h example-app/*.cpp example-app/*.h + +# Run clang-tidy and clang-format +SOURCES="src/**/*.cpp src/**/*.h example-app/*.cpp example-app/*.h" +clang-tidy -p build/ --fix --config-file=.clang-tidy $SOURCES +clang-format -i --style=file:.clang-format $SOURCES