From 6d51aef9cfbd6215b34db440b5edd4e5fe762dce Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sat, 11 Mar 2023 13:24:51 -0500 Subject: [PATCH] Cleanup --- .github/workflows/all-builds.yml | 84 +++++----------- CMakeLists.txt | 5 +- README.md | 11 ++- src/CMakeLists.txt | 163 +++++++++++++++---------------- src/app/CMakeLists.txt | 9 +- src/app/qtkscene.cpp | 1 - 6 files changed, 115 insertions(+), 158 deletions(-) diff --git a/.github/workflows/all-builds.yml b/.github/workflows/all-builds.yml index 97a4b0e..713265b 100644 --- a/.github/workflows/all-builds.yml +++ b/.github/workflows/all-builds.yml @@ -8,7 +8,7 @@ on: jobs: Build-Qtk: env: - CONFIG: -DQTK_UPDATE_SUBMODULES=ON -DQTK_DEBUG=OFF -DQTK_ENABLE_CCACHE=OFF -DQTK_INSTALL_GUI=ON -DQTK_INSTALL_LIB=ON -DQTK_INSTALL_PLUGINS=OFF + CONFIG: -DQTK_UPDATE_SUBMODULES=ON -DQTK_DEBUG=OFF -DQTK_ENABLE_CCACHE=OFF -DQTK_BUILD_GUI=ON -DQTK_INSTALL_LIBRARY=ON -DQTK_INSTALL_PLUGINS=OFF strategy: fail-fast: false matrix: @@ -70,11 +70,11 @@ jobs: shell: bash run: cmake --build build/ --target package --config Release -# - uses: actions/upload-artifact@v3 -# if: always() -# with: -# name: qtk-${{ matrix.os }}-install -# path: install/* + - name: Upload Qtk install directory + uses: actions/upload-artifact@v3 + with: + name: qtk-${{ matrix.os }}-install + path: install/* # TODO: Enable after trimming resources. # - name: Package Qtk Application Sources @@ -82,27 +82,18 @@ jobs: # shell: bash # run: | # cmake --build build/ --target package_source - +# # - name: Upload package artifacts # uses: actions/upload-artifact@v3 -# if: always() # with: -# name: qtk-packages-${{ matrix.os }} +# name: qtk-${{ matrix.os }}-packages # path: | -# build/packages/ +# build/packages/* # !build/packages/_CPack_Packages/* - - name: Upload logs on failure - uses: actions/upload-artifact@v3 - if: ${{ failure() && matrix.os == 'windows-latest' }} - with: - name: qtk-failed-packages-${{ matrix.os }} - path: | - build/_CPack_Packages/win64/NSIS/NSISOutput.log - Build-Qtk-Library: env: - CONFIG: -DQTK_UPDATE_SUBMODULES=ON -DQTK_DEBUG=OFF -DQTK_ENABLE_CCACHE=OFF -DQTK_INSTALL_GUI=OFF -DQTK_INSTALL_LIB=ON -DQTK_INSTALL_PLUGINS=OFF + CONFIG: -DQTK_UPDATE_SUBMODULES=ON -DQTK_DEBUG=OFF -DQTK_ENABLE_CCACHE=OFF -DQTK_BUILD_GUI=OFF -DQTK_INSTALL_LIBRARY=ON -DQTK_INSTALL_PLUGINS=OFF strategy: fail-fast: false matrix: @@ -164,32 +155,25 @@ jobs: shell: bash run: cmake --build build/ --target package --config Release -# - uses: actions/upload-artifact@v3 -# if: always() -# with: -# name: libqtk-${{ matrix.os }}-install -# path: install/* - -# - name: Upload package artifacts -# uses: actions/upload-artifact@v3 -# if: always() -# with: -# name: libqtk-packages-${{ matrix.os }} -# path: | -# build/packages/ -# !build/packages/_CPack_Packages/* - - - name: Upload logs on failure + - name: Upload libqtk install uses: actions/upload-artifact@v3 - if: ${{ failure() && matrix.os == 'windows-latest' }} + if: always() with: - name: libqtk-failed-packages-${{ matrix.os }} + name: libqtk-${{ matrix.os }}-install + path: install/* + + - name: Upload package artifacts + uses: actions/upload-artifact@v3 + if: always() + with: + name: libqtk-packages-${{ matrix.os }} path: | - build/_CPack_Packages/win64/NSIS/NSISOutput.log + build/packages/ + !build/packages/_CPack_Packages/* Build-Qtk-Plugins: env: - CONFIG: -DQTK_UPDATE_SUBMODULES=ON -DQTK_DEBUG=OFF -DQTK_ENABLE_CCACHE=OFF -DQTK_INSTALL_GUI=OFF -DQTK_INSTALL_LIB=OFF -DQTK_INSTALL_PLUGINS=ON + CONFIG: -DQTK_UPDATE_SUBMODULES=ON -DQTK_DEBUG=OFF -DQTK_ENABLE_CCACHE=OFF -DQTK_BUILD_GUI=OFF -DQTK_INSTALL_LIBRARY=OFF -DQTK_INSTALL_PLUGINS=ON strategy: fail-fast: false matrix: @@ -278,25 +262,3 @@ jobs: shell: bash run: | sudo apt install libassimp-dev - - - name: Build Qtk - if: matrix.os == 'windows-latest' - shell: bash - run: | - cmake -B build/ ${{ matrix.cmake }} -DQTK_DEBUG=OFF -DQTK_ENABLE_CCACHE=OFF - cmake --build build/ --config Release - - - name: Build Qtk - if: matrix.os != 'windows-latest' - shell: bash - run: | - cmake -B build/ ${{ matrix.cmake }} -DQTK_DEBUG=OFF -DQTK_ENABLE_CCACHE=OFF - cmake --build build/ --config Release -- -j $(nproc) - - # TODO: Enable with tag only when done testing -# Release-Qtk: -# needs: Build-Qtk -# strategy: -# fail-fast: false -# matrix: -# os: [ubuntu-latest, windows-latest, macos-latest] diff --git a/CMakeLists.txt b/CMakeLists.txt index 5acf1cc..6602dfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ if(WIN32) set(CMAKE_COMPILE_WARNING_AS_ERROR OFF) add_compile_options(/wd4131 /wd4127) endif() +add_compile_options(-fPIC) ################################################################################ # Project @@ -46,8 +47,8 @@ include(GNUInstallDirs) ################################################################################ option(QTK_DEBUG "Enable debugger" OFF) option(QTK_UPDATE_SUBMODULES "Update external project (assimp) submodule" OFF) -option(QTK_INSTALL_GUI "Build the Qtk desktop application" ON) -option(QTK_INSTALL_LIB "Install libqtk to CMAKE_INSTALL_PREFIX path." ON) +option(QTK_BUILD_GUI "Build the Qtk desktop application" ON) +option(QTK_INSTALL_LIBRARY "Install libqtk to CMAKE_INSTALL_PREFIX path." ON) option(QTK_INSTALL_PLUGINS "Install Qtk plugin collection to Qt Creator." OFF) option(QTK_BUILD_EXAMPLE "Build the Qtk example desktop application" ON) option(QTK_ENABLE_CCACHE "Enable ccache" ON) diff --git a/README.md b/README.md index 23f888b..daa9283 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ using libqtk. Below is an example of installing on a system path. ```bash -cmake -S qtk/ -B qtk/build/ -DCMAKE_PREFIX_PATH=$HOME/Qt/6.5.0/gcc_64 -DQTK_INSTALL_GUI=OFF -DQTK_INSTALL_PLUGINS=OFF -DQTK_DEBUG=OFF +cmake -S qtk/ -B qtk/build/ -DCMAKE_PREFIX_PATH=$HOME/Qt/6.5.0/gcc_64 -DQTK_BUILD_GUI=OFF -DQTK_INSTALL_PLUGINS=OFF -DQTK_DEBUG=OFF cmake --build qtk/build/ -j $(nproc --ignore=2) sudo cmake --install . --prefix=/usr/local -- Install configuration: "Release" @@ -133,7 +133,7 @@ interfaces. To build and install the Qtk plugin collection - ```bash -cmake -S /path/to/qtk -B /path/to/qtk/build -DCMAKE_PREFIX_PATH=$HOME/Qt/6.5.0/gcc_64 -DQTK_INSTALL_PLUGINS=ON -DQTK_INSTALL_GUI=OFF -DQTK_INSTALL_LIB=OFF +cmake -S /path/to/qtk -B /path/to/qtk/build -DCMAKE_PREFIX_PATH=$HOME/Qt/6.5.0/gcc_64 -DQTK_INSTALL_PLUGINS=ON -DQTK_BUILD_GUI=OFF -DQTK_INSTALL_LIBRARY=OFF cmake --build /path/to/qtk/build cmake --install /path/to/qtk/build ``` @@ -278,10 +278,11 @@ Any of the above options can be appended with `--trace-expand` to debug package generation issues. The contents of all packages will depend on how the build was configured. -If we are generating packages for *only* libqtk, we set `-DQTK_INSTALL_LIB=ON` +If we are generating packages for *only* libqtk, we +set `-DQTK_INSTALL_LIBRARY=ON` during the cmake configuration step. To generate packages for Qtk desktop application, we should -set `-DQTK_INSTALL_GUI=ON`, and optionally `-DQTK_INSTALL_LIB=ON` if we would +set `-DQTK_BUILD_GUI=ON`, and optionally `-DQTK_INSTALL_LIBRARY=ON` if we would like to bundle libqtk with the desktop application. The NSIS installer will allow component-specific path modification for all of @@ -295,6 +296,8 @@ Some useful links and resources that I have found while working on this project. [QtPlugin Import / Export plugins](https://doc.qt.io/qt-6/qtplugin.html) +[KDAB](https://www.kdab.com/) + ## Model Artists "Alien Hominid" (https://skfb.ly/onStx) by Nwilly_art is licensed under Creative diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5af1cac..63af681 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,68 +6,96 @@ ################################################################################ # Qtk Library + +# We always build libqtk since the plugins and GUI both depend on it. add_subdirectory(qtk) +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + COMPONENT libqtk + DESTINATION lib/cmake/${PROJECT_NAME} +) +install( + EXPORT qtk_export + FILE ${PROJECT_NAME}Targets.cmake + NAMESPACE ${PROJECT_NAME}:: + COMPONENT libqtk + DESTINATION lib/cmake/${PROJECT_NAME} +) +# System install for qtk_library +install( + TARGETS qtk_library + # Associate qtk_library target with qtk-export + EXPORT qtk_export + COMPONENT libqtk + FILE_SET HEADERS DESTINATION include + INCLUDES DESTINATION include + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static + RUNTIME DESTINATION bin +) # Qtk Application -if (QTK_INSTALL_GUI OR QTK_INSTALL_PLUGINS) +if(QTK_BUILD_GUI OR QTK_INSTALL_PLUGINS) add_subdirectory(app) +endif() - # Install custom Qtk plugins for Qt Designer. - if(QTK_INSTALL_PLUGINS) - install( - TARGETS qtk_library qtk_plugin_library - COMPONENT qtk_collection - LIBRARY DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" - ARCHIVE DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" - RUNTIME DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" - ) - install( - TARGETS qtk_collection - COMPONENT qtk_collection - LIBRARY DESTINATION "${QTK_PLUGIN_INSTALL_DIR}" - ARCHIVE DESTINATION "${QTK_PLUGIN_INSTALL_DIR}" - RUNTIME DESTINATION "${QTK_PLUGIN_INSTALL_DIR}" - ) - endif() +if(QTK_INSTALL_PLUGINS) + # Optionally install custom Qtk plugins for Qt Designer. + install( + TARGETS qtk_library qtk_plugin_library + COMPONENT qtk_collection + LIBRARY DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" + ARCHIVE DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" + RUNTIME DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" + ) + install( + TARGETS qtk_collection + COMPONENT qtk_collection + LIBRARY DESTINATION "${QTK_PLUGIN_INSTALL_DIR}" + ARCHIVE DESTINATION "${QTK_PLUGIN_INSTALL_DIR}" + RUNTIME DESTINATION "${QTK_PLUGIN_INSTALL_DIR}" + ) +endif() - if(QTK_INSTALL_GUI) - install( - TARGETS qtk_app qtk_library - COMPONENT qtk - BUNDLE DESTINATION . - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static - RUNTIME DESTINATION bin - ) +if(QTK_BUILD_GUI) + install( + TARGETS qtk_app + COMPONENT qtk + BUNDLE DESTINATION . + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static + RUNTIME DESTINATION bin + ) - qt_generate_deploy_app_script( - TARGET qtk_app - OUTPUT_SCRIPT QTK_DEPLOY_SCRIPT - NO_UNSUPPORTED_PLATFORM_ERROR - ) - install(SCRIPT ${QTK_DEPLOY_SCRIPT} COMPONENT qtk) + qt_generate_deploy_app_script( + TARGET qtk_app + OUTPUT_SCRIPT QTK_DEPLOY_SCRIPT + NO_UNSUPPORTED_PLATFORM_ERROR + ) + install(SCRIPT ${QTK_DEPLOY_SCRIPT} COMPONENT qtk) - if(WIN32) - if(MSVC AND TARGET Qt6::qmake) - get_target_property(QT6_QMAKE_LOCATION Qt6::qmake IMPORTED_LOCATION) - execute_process( - COMMAND "${QT6_QMAKE_LOCATION}" -query QT_INSTALL_PREFIX - RESULT_VARIABLE return_code - OUTPUT_VARIABLE QT6_INSTALL_PREFIX - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - file(TO_NATIVE_PATH "${QT6_INSTALL_PREFIX}/bin" QT6_INSTALL_PREFIX) + if(WIN32) + if(MSVC AND TARGET Qt6::qmake) + get_target_property(QT6_QMAKE_LOCATION Qt6::qmake IMPORTED_LOCATION) + execute_process( + COMMAND "${QT6_QMAKE_LOCATION}" -query QT_INSTALL_PREFIX + RESULT_VARIABLE return_code + OUTPUT_VARIABLE QT6_INSTALL_PREFIX + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + file(TO_NATIVE_PATH "${QT6_INSTALL_PREFIX}/bin" QT6_INSTALL_PREFIX) - set(VSUSER_FILE "${CMAKE_CURRENT_BINARY_DIR}/qtk_app.vcxproj.user") - file(WRITE ${VSUSER_FILE} "\n") - file(APPEND ${VSUSER_FILE} "\n") - file(APPEND ${VSUSER_FILE} " \n") - file(APPEND ${VSUSER_FILE} " Path=$(SolutionDir)\\lib\\$(Configuration);${QT6_INSTALL_PREFIX};$(Path)\n") - file(APPEND ${VSUSER_FILE} "$(LocalDebuggerEnvironment)\n") - file(APPEND ${VSUSER_FILE} " WindowsLocalDebugger\n") - file(APPEND ${VSUSER_FILE} " \n") - file(APPEND ${VSUSER_FILE} "\n") - endif() + set(VSUSER_FILE "${CMAKE_CURRENT_BINARY_DIR}/qtk_app.vcxproj.user") + file(WRITE ${VSUSER_FILE} "\n") + file(APPEND ${VSUSER_FILE} "\n") + file(APPEND ${VSUSER_FILE} " \n") + file(APPEND ${VSUSER_FILE} " Path=$(SolutionDir)\\lib\\$(Configuration);${QT6_INSTALL_PREFIX};$(Path)\n") + file(APPEND ${VSUSER_FILE} "$(LocalDebuggerEnvironment)\n") + file(APPEND ${VSUSER_FILE} " WindowsLocalDebugger\n") + file(APPEND ${VSUSER_FILE} " \n") + file(APPEND ${VSUSER_FILE} "\n") endif() endif() endif() @@ -82,35 +110,6 @@ configure_package_config_file( INSTALL_DESTINATION lib/cmake/${PROJECT_NAME} ) -if (QTK_INSTALL_LIB) - install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" - COMPONENT libqtk - DESTINATION lib/cmake/${PROJECT_NAME} - ) - install( - EXPORT qtk_export - FILE ${PROJECT_NAME}Targets.cmake - NAMESPACE ${PROJECT_NAME}:: - COMPONENT libqtk - DESTINATION lib/cmake/${PROJECT_NAME} - ) - # System install for qtk_library - install( - TARGETS qtk_library - # Associate qtk_library target with qtk-export - EXPORT qtk_export - COMPONENT libqtk - FILE_SET HEADERS DESTINATION include - INCLUDES DESTINATION include - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static - RUNTIME DESTINATION bin - ) -endif() - set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index e42867d..6bbfcb6 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -36,7 +36,7 @@ target_link_libraries(qtk_plugin_library PUBLIC Qt6::UiPlugin qtk_library) # Qtk Widget Collection Plugin ################################################################################ # Create a Qt Designer plugin for a collection of widgets from our library. -qt_add_plugin(qtk_collection SHARED EXCLUDE_FROM_ALL) +qt_add_plugin(qtk_collection SHARED) target_sources( qtk_collection PRIVATE widgetplugincollection.cpp widgetplugincollection.h @@ -54,13 +54,6 @@ set( main.cpp ) -qt6_add_big_resources(QTK_APP_SOURCES "${QTK_RESOURCES}/resources.qrc") -configure_file( - resources.h.in - "${CMAKE_CURRENT_BINARY_DIR}/resources.h" - @ONLY -) - qt_add_executable(qtk_app ${QTK_APP_SOURCES}) target_link_libraries(qtk_app PRIVATE qtk_plugin_library) diff --git a/src/app/qtkscene.cpp b/src/app/qtkscene.cpp index 9432cf5..ba7abb0 100644 --- a/src/app/qtkscene.cpp +++ b/src/app/qtkscene.cpp @@ -7,7 +7,6 @@ ##############################################################################*/ #include "qtkscene.h" -#include "resources.h" using namespace Qtk;