From 061daaebe057fa2af737ca6e471d1f440136ccff Mon Sep 17 00:00:00 2001 From: Rick Vogel Date: Fri, 18 Nov 2022 13:59:10 +0100 Subject: [PATCH] add integration test; install headers; matrix paths --- .github/workflows/cmake.yml | 80 ++++++++++++------- CMakeLists.txt | 13 ++- examples/iotdashboard/CMakeLists.txt | 24 ++++-- examples/iotdashboard/main.cpp | 4 + .../iotdashboard_smoketest/CMakeLists.txt | 57 +++++++++++++ src/CMakeLists.txt | 5 ++ support/CMakeLists.txt | 7 +- 7 files changed, 144 insertions(+), 46 deletions(-) create mode 100644 examples/iotdashboard_smoketest/CMakeLists.txt diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 73fcb512..2459a089 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,5 +1,11 @@ name: CMake Build Matrix +# Directories +# - $GITHUB_WORKSPACE/qskinny_source : Checkout directory for qskinny sources +# - $GITHUB_WORKSPACE/qskinny_build : Build directory for QSkinny CMake +# - $GITHUB_WORKSPACE/qskinny_install : Install directory for QSkinny package +# - $GITHUB_WORKSPACE/qskinny_build_test : Build directory for QSkinny CMake integration test + on: push: branches: [cmake] @@ -185,12 +191,16 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - name: Git Checkout + uses: actions/checkout@v3 + with: + path: qskinny_source - name: Print env run: | echo github.event.action: ${{ github.event.action }} echo github.event_name: ${{ github.event_name }} + - name: Install dependencies on windows if: startsWith(matrix.config.os, 'windows') run: | @@ -207,6 +217,7 @@ jobs: ninja --version cmake --version gcc --version + - name: Install dependencies on ubuntu9 if: startsWith(matrix.config.name, 'Ubuntu GCC 9') run: | @@ -242,6 +253,7 @@ jobs: sudo update-alternatives --install /usr/bin/cmake cmake /opt/cmake/bin/cmake 1 --force echo cmake version after cmake --version + - name: Install dependencies on macos if: startsWith(matrix.config.os, 'macos') run: | @@ -253,7 +265,15 @@ jobs: if: startsWith(matrix.config.name, 'Ubuntu') && endsWith(matrix.config.name, 'Qt6') run: sudo apt-get install libxkbcommon-dev -y - - uses: actions/checkout@v2 + - name: Install hunspell for Ubuntu + if: false && startsWith(matrix.config.name, 'Ubuntu') + run: | + sudo apt-get install -y libhunspell-dev + + - name: Install pinyin for Ubuntu + if: false && startsWith(matrix.config.name, 'Ubuntu') + run: | + sudo apt-get install -y libimepinyin-dev - name: Cache Qt5 if: endsWith(matrix.config.name, 'Qt5') @@ -278,7 +298,7 @@ jobs: version: "5.15.2" target: "desktop" install-deps: "true" - modules: "qtwebengine" + modules: "qtwebengine qtpositioning" cached: ${{ steps.cache-qt-5-15.outputs.cache-hit }} setup-python: "false" tools: "" @@ -292,49 +312,53 @@ jobs: version: "6.2.4" target: "desktop" install-deps: "true" - modules: "qtwebengine" + modules: "qtwebengine qtpositioning" cached: ${{ steps.cache-qt-6-2.outputs.cache-hit }} setup-python: "false" tools: "" set-env: "true" tools-only: "false" - - name: Install hunspell for Ubuntu - if: startsWith(matrix.config.name, 'Ubuntu') - run: | - sudo apt-get install -y libhunspell-dev - - - name: Install pinyin for Ubuntu - if: startsWith(matrix.config.name, 'Ubuntu') - run: | - sudo apt-get install -y libimepinyin-dev - - - name: Configure + - name: Configure ( QSkinny ) shell: bash run: | - mkdir build - mkdir instdir + mkdir qskinny_build + mkdir qskinny_install cmake \ - -S . \ - -B . \ + -S qskinny_source \ + -B qskinny_build \ -G "${{ matrix.config.generators }}" \ -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \ - -DCMAKE_INSTALL_PREFIX:PATH=instdir \ - -D${{ matrix.config.cmake.qtdirkey }}:PATH="${{ matrix.config.cmake.qtdirvalue }}" \ - -DENABLE_HUNSPELL:BOOL=ON \ - -DENABLE_PINYIN:BOOL=ON + -DCMAKE_INSTALL_PREFIX:PATH=qskinny_install \ + -D${{ matrix.config.cmake.qtdirkey }}:PATH="${{ matrix.config.cmake.qtdirvalue }}" - - name: Build + - name: Build ( QSkinny ) shell: bash - run: cmake --build . --config ${{ matrix.config.build_type }} + run: cmake --build qskinny_build --config ${{ matrix.config.build_type }} #- name: Tests # shell: bash # run: ctest -j14 -C Release -T test --output-on-failure - # - name: Install Strip - # shell: bash - # run: cmake --install . --strip + - name: Install ( QSkinny ) Strip + shell: bash + run: cmake --install . --strip + + - name: Configure ( CMake Integration Test ) + shell: bash + run: | + mkdir qskinny_build_test + cmake \ + -S qskinny_source/examples/iotdashboard_smoketest \ + -B qskinny_build_test \ + -G "${{ matrix.config.generators }}" \ + -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \ + -D${{ matrix.config.cmake.qtdirkey }}:PATH="${{ matrix.config.cmake.qtdirvalue }}" \ + -DQSkinny_DIR:PATH=qskinny_install/lib/cmake/QSkinny + + - name: Build ( CMake Integration Test ) + shell: bash + run: cmake --build qskinny_build_test --config ${{ matrix.config.build_type }} # - name: Pack # shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index ec020358..6862e77d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,10 +99,6 @@ set(QSK_INSTALL_EXAMPLES examples) set(CMAKE_DEBUG_POSTFIX d) # define binary install directory globally set(CMAKE_INSTALL_BINDIR ${QSK_INSTALL_BINS}$<$:/debug>) -# define library install directory globally -# set(CMAKE_INSTALL_LIBDIR lib$<$:/debug>) -# define install rpath globally -# set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QSK_INSTALL_LIBS}) add_subdirectory(src) add_subdirectory(skins) @@ -131,10 +127,11 @@ set(PACKAGE_NAMESPACE Qsk) set(PACKAGE_LOCATION lib/cmake/${PROJECT_NAME}) install(TARGETS qskinny EXPORT ${PACKAGE_NAME}Targets - LIBRARY DESTINATION ${QSK_INSTALL_LIBS} - ARCHIVE DESTINATION ${QSK_INSTALL_LIBS} - RUNTIME DESTINATION ${QSK_INSTALL_LIBS} - INCLUDES DESTINATION ${QSK_INSTALL_HEADERS}) + LIBRARY DESTINATION ${QSK_INSTALL_LIBS} + ARCHIVE DESTINATION ${QSK_INSTALL_LIBS} + RUNTIME DESTINATION ${QSK_INSTALL_LIBS} + INCLUDES DESTINATION ${QSK_INSTALL_HEADERS} + PUBLIC_HEADER DESTINATION ${QSK_INSTALL_HEADERS}) include(CMakePackageConfigHelpers) write_basic_package_version_file( diff --git a/examples/iotdashboard/CMakeLists.txt b/examples/iotdashboard/CMakeLists.txt index d3545c78..ca7d374a 100644 --- a/examples/iotdashboard/CMakeLists.txt +++ b/examples/iotdashboard/CMakeLists.txt @@ -80,8 +80,22 @@ set_target_properties(${TARGET_NAME} AUTORCC ON FOLDER examples) -target_link_libraries(${TARGET_NAME} - PRIVATE - qskinny - qsktestsupport - ${Qt}::Svg) \ No newline at end of file +if(TARGET Qsk::qskinny) + # integration test + # - qsktestsupport doesn't exists + # - qskinny has a namespace Qsk + target_link_libraries(${TARGET_NAME} + PRIVATE + Qsk::qskinny + ${Qt}::Svg) +else() + target_link_libraries(${TARGET_NAME} + PRIVATE + qskinny + qsktestsupport + ${Qt}::Svg) + + target_compile_definitions(${TARGET_NAME} + PRIVATE + USE_SHORTCUTS) +endif() \ No newline at end of file diff --git a/examples/iotdashboard/main.cpp b/examples/iotdashboard/main.cpp index 78b71d87..86d42373 100644 --- a/examples/iotdashboard/main.cpp +++ b/examples/iotdashboard/main.cpp @@ -7,7 +7,9 @@ #include "GraphicProvider.h" #include "Skin.h" +#ifdef USE_SHORTCUTS #include +#endif #include #include @@ -75,9 +77,11 @@ int main( int argc, char* argv[] ) qskSetup->setSkin( "DaytimeSkin" ); +#ifdef USE_SHORTCUTS // With CTRL-B you can rotate a couple of visual debug modes SkinnyShortcut::enable( SkinnyShortcut::RotateSkin | SkinnyShortcut::DebugBackground | SkinnyShortcut::DebugStatistics | SkinnyShortcut::Quit ); +#endif MainWindow window; window.show(); diff --git a/examples/iotdashboard_smoketest/CMakeLists.txt b/examples/iotdashboard_smoketest/CMakeLists.txt new file mode 100644 index 00000000..3d65b45c --- /dev/null +++ b/examples/iotdashboard_smoketest/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 3.18) + +project(iotdashboard_smoketest) + +find_package(QSkinny REQUIRED) + +if("${Qt5_DIR}" STREQUAL "" AND "${Qt6_DIR}" STREQUAL "") + message(FATAL_ERROR "Neither Qt5_DIR nor Qt6_DIR defined!") +else() + # force include Qt's private headers + if(NOT "${Qt5_DIR}" STREQUAL "") + set(Qt5Core_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5Gui_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5OpenGL_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5Quick_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5QuickWidgets_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5Svg_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5WebEngine_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5WebEngineCore_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5Widgets_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + elseif(NOT "${Qt6_DIR}" STREQUAL "") + #set(Qt6Core_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + #set(Qt6Gui_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt6OpenGL_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + #set(Qt6Quick_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + #set(Qt6QuickWidgets_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + #set(Qt6Svg_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt6WebEngine_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt6WebEngineCore_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt6WebEngineQuick_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + #set(Qt6Widgets_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + endif() +endif() + +if(NOT "${Qt5_DIR}" STREQUAL "") + find_package(Qt5 REQUIRED COMPONENTS Core Gui OpenGL Quick Svg Widgets) + find_package(Qt5 OPTIONAL_COMPONENTS QuickWidgets WebEngine WebEngineCore) + set(Qt Qt${Qt5_VERSION_MAJOR}) + set(Qt_VERSION ${Qt5_VERSION}) + set(Qt_VERSION_MAJOR ${Qt5_VERSION_MAJOR}) + set(Qt_VERSION_MINOR ${Qt5_VERSION_MINOR}) + set(Qt_VERSION_PATCH ${Qt5_VERSION_PATCH}) +elseif(NOT "${Qt6_DIR}" STREQUAL "") + + string(REPLACE "/lib/cmake/Qt6" "" Qt6_PREFIX_DIR "${Qt6_DIR}") + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${Qt6_PREFIX_DIR}) + + find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL Quick QuickWidgets Svg Widgets) + find_package(Qt6 OPTIONAL_COMPONENTS QuickWidgets WebEngineCore WebEngineQuick) + set(Qt Qt${Qt6_VERSION_MAJOR}) + set(Qt_VERSION ${Qt6_VERSION}) + set(Qt_VERSION_MAJOR ${Qt6_VERSION_MAJOR}) + set(Qt_VERSION_MINOR ${Qt6_VERSION_MINOR}) + set(Qt_VERSION_PATCH ${Qt6_VERSION_PATCH}) +endif() + +add_subdirectory(../iotdashboard ${CMAKE_CURRENT_BINARY_DIR}/../iotdashboard) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 01faf6ba..ed4b122b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -449,3 +449,8 @@ set_target_properties(${TARGET_NAME} set_target_properties(${TARGET_NAME} PROPERTIES AUTOGEN_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/qskinny_autogen) + +list(TRANSFORM TARGET_HEADERS PREPEND "${CMAKE_CURRENT_LIST_DIR}/") +set_target_properties(${TARGET_NAME} + PROPERTIES + PUBLIC_HEADER "${TARGET_HEADERS}") \ No newline at end of file diff --git a/support/CMakeLists.txt b/support/CMakeLists.txt index 11b43ce0..a1bec638 100644 --- a/support/CMakeLists.txt +++ b/support/CMakeLists.txt @@ -48,7 +48,7 @@ endif() target_compile_definitions(${TARGET_NAME} PRIVATE - PLUGIN_PATH=${CMAKE_INSTALL_PREFIX}/skins) # TODO this'll work only locally since CMAKE_INSTALL_PREFIX is an absolute path + PLUGIN_PATH=${CMAKE_INSTALL_PREFIX}/skins) target_include_directories(${TARGET_NAME} PUBLIC @@ -58,13 +58,10 @@ if(ENABLE_ENSURE_SKINS) target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/skins) target_compile_definitions(${TARGET_NAME} PRIVATE ENSURE_SKINS) - # TODO - # use_install_rpath: QMAKE_RPATHDIR *= $${QSK_INSTALL_PLUGINS}/skins - # use_local_rpath: QMAKE_RPATHDIR *= $${QSK_PLUGIN_DIR}/skins target_link_libraries(${TARGET_NAME} PRIVATE squiekskin material3skin) endif() -install(TARGETS ${TARGET_NAME} DESTINATION lib) # TODO unify lib install directory \ No newline at end of file +install(TARGETS ${TARGET_NAME} DESTINATION ${QSK_INSTALL_LIBS}) \ No newline at end of file