Clean up cmake.

This commit is contained in:
Shaun Reed 2025-03-14 13:34:45 -04:00
parent ea25ba312a
commit 6ebe953236
22 changed files with 140 additions and 54 deletions

View File

@ -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.

View File

@ -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

View File

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# $1: Input path to an image to use for generating icons.
# Helper script to generate qtk's icons for Linux given a path to an input PNG.
sudo apt install imagemagick
convert "$1" -resize 256x256 kilroy-256.png
convert "$1" -resize 128x128 kilroy-128.png
convert "$1" -resize 64x64 kilroy-64.png
convert "$1" -resize 48x48 kilroy-48.png
convert "$1" -resize 32x32 kilroy-32.png
convert "$1" -resize 16x16 kilroy-16.png

View File

@ -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
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
# $1: Input path to an image to use for generating icons.
# Helper script to generate qtk's icons for OSX given a path to an input PNG.
sudo apt install icnsutils imagemagick
convert "$1" -resize 32x32 kilroy_32.png
convert "$1" -resize 16x16 kilroy_16.png
convert "$1" -resize 48x48 kilroy_48.png
convert "$1" -resize 128x128 kilroy_128.png
convert "$1" -resize 256x256 kilroy_256.png
# For the application bundle in OSX.
png2icns png2icns kilroy.icns kilroy_*.png
# For the splash image in DMG installers.
convert "$1" -resize 800x600! kilroy_splash.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
# $1: Input path to an image to use for generating icons.
# Helper script to generate qtk's icons for OSX given a path to an input PNG.
sudo apt install imagemagick
# For the NSIS (un)installer executable shortcut icon.
convert "$1" -resize 256x256,128x128,64x64,48x48,32x32,16x16 -background transparent -colors 256 kilroy.ico
# For the NSIS installer splash screen.
convert "$1" -resize 164x314! -background white -flatten kilroy_splash.bmp

6
resources/qtk.desktop Normal file
View File

@ -0,0 +1,6 @@
[Desktop Entry]
Name=Qtk
Exec=/usr/bin/qtk_gui
Icon=qtk
Type=Application
Categories=Utility;

View File

@ -17,7 +17,7 @@
<file>fontawesome-free-6.2.1-desktop/svgs/regular/folder-open.svg</file>
<file>fontawesome-free-6.2.1-desktop/svgs/regular/floppy-disk.svg</file>
<file>fontawesome-free-6.2.1-desktop/svgs/brands/git-alt.svg</file>
<file>icon.png</file>
<file alias="icon.png">icons/icon.png</file>
</qresource>
<qresource prefix="/shaders">
<file alias="model.frag">shaders/fragment/model.frag</file>

View File

@ -103,18 +103,82 @@ 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")
if (WIN32)
# Windows
# Set icon for the splash image used in Windows NSIS installers.
set(CPACK_PACKAGE_ICON "${QTK_RESOURCES}/icons/win/kilroy_splash.bmp")
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
# https://nsis.sourceforge.io/Reference/CreateShortCut
set(
CPACK_NSIS_CREATE_ICONS_EXTRA
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Qtk.lnk' '$INSTDIR\\\\bin\\\\qtk_gui.exe'"
)
set(
CPACK_NSIS_DELETE_ICONS_EXTRA
"Delete '$SMPROGRAMS\\\\$START_MENU\\\\Qtk.lnk'"
)
# Set icon for the installer executable.
# set(CPACK_NSIS_MUI_ICON "${QTK_RESOURCES}/icons/win/kilroy.ico")
# Set icon for uninstaller executable.
# set(CPACK_NSIS_MUI_UNIICON "${QTK_RESOURCES}/icons/win/kilroy.ico")
elseif(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 $<TARGET_BUNDLE_CONTENT_DIR:qtk_gui>/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()
# Remove any assimp components if defined by submodule.
if (QTK_SUBMODULES)
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
@ -122,31 +186,6 @@ if (QTK_SUBMODULES)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL Unspecified)
endif()
# Windows
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
# https://nsis.sourceforge.io/Reference/CreateShortCut
set(
CPACK_NSIS_CREATE_ICONS_EXTRA
"CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Qtk.lnk' '$INSTDIR\\\\bin\\\\qtk_gui.exe'"
)
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 $<TARGET_BUNDLE_CONTENT_DIR:qtk_gui>/Info.plist)
set(CPACK_BUNDLE_ICON ${QTK_OSX_ICONS})
# Platform defaults for source bundles.
if(WIN32)
set(CPACK_SOURCE_GENERATOR ZIP)

View File

@ -57,15 +57,18 @@ 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
if (WIN32)
set_target_properties(qtk_gui PROPERTIES WIN32_EXECUTABLE TRUE)
elseif(APPLE)
set_target_properties(
qtk_gui PROPERTIES
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_COPYRIGHT ${QTK_COPYRIGHT}
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
)
endif()

View File

@ -21,7 +21,7 @@
</property>
<property name="windowIcon">
<iconset>
<normaloff>../resources/icon.png</normaloff>../resources/icon.png</iconset>
<normaloff>../resources/icons/icon.png</normaloff>../resources/icons/icon.png</iconset>
</property>
<property name="unifiedTitleAndToolBarOnMac">
<bool>true</bool>

View File

@ -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