diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5bff480..7199826 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,7 +36,7 @@ jobs: - name: Build project run: | - cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON cmake --build build - name: Run tests diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b818f4..a6e4d34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,10 @@ project( VERSION 0.0.0 LANGUAGES CXX) -option(BUILD_TESTS "Build tests" OFF) +option(BUILD_TESTING "Build tests" OFF) message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") -message(STATUS "Build tests: ${BUILD_TESTS}") +message(STATUS "Build tests: ${BUILD_TESTING}") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -25,7 +25,7 @@ configure_file(${CMAKE_SOURCE_DIR}/include/version.h.in add_subdirectory(src) add_subdirectory(app) -if(BUILD_TESTS) +if(BUILD_TESTING) enable_testing() add_subdirectory(tests) endif() diff --git a/README.md b/README.md index d8a6cc1..bf57919 100644 --- a/README.md +++ b/README.md @@ -294,11 +294,11 @@ Qt](https://doc.qt.io/qt-6/get-and-install-qt-cli.html). ### Test Googletest and QTest are used for building the unit tests and the end-to-end -tests. To build the tests, the `BUILD_TESTS` option must be set to `ON` when +tests. To build the tests, the `BUILD_TESTING` option must be set to `ON` when running cmake. For example: ```bash -cmake -G "Ninja" -S . -B ./build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON +cmake -G "Ninja" -S . -B ./build -DCMAKE_BUILD_TYPE=Debug -BUILD_TESTING=ON ``` this will uses the `Debug` build type with the tests enabled. To run the tests, @@ -381,5 +381,15 @@ more information. # TODO: - [ ] Add pre built binaries to the github releases + - For static build I used the followig configure command: + + ```bash + ./configure -release -static -no-pch -prefix ~/code/snapshot/3rdparty/Qt/ -no-gstreamer -fontconfig -submodules qtbase,qtmultimedia,qtwayland -- -S . -B ./build + ``` + + The Qt docs stated that plugins need to be linked in cmake when Qt is + compiled statically. This is done automatically when using dynamic linking, + thus explaining why I get pluging errors. + - [ ] Add an uninstall target? - [ ] Cross compile for raspberry pi diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 31765ea..052d16d 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,3 +1,9 @@ add_executable(snapshot main.cpp ${CMAKE_SOURCE_DIR}/resources/resources.qrc) target_link_libraries(snapshot PRIVATE snapshotapp) install(TARGETS snapshot DESTINATION bin) + +set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) +set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) +set(CPACK_GENERATOR "ZIP") + +include(CPack) diff --git a/scripts/install-qt b/scripts/install-qt index f8df6b6..55bbd48 100755 --- a/scripts/install-qt +++ b/scripts/install-qt @@ -1,28 +1,22 @@ #!/usr/bin/env bash set -euo pipefail -usage="Usage: $0 +usage="Usage: $0 Installs Qt 6.6.1 to 3rdparty/Qt. For this script to work, you need to set the QT_INSTALLER_JWT_TOKEN environment variable to your jwt token. Check the website of Qt for more information. +Optionally, you can add more Qt packages to install by adding them as +arguments. + Options: -h, --help Show this help message and exit" -while [[ $# -gt 0 ]]; do - case "$1" in - -h | --help) - echo "$usage" - exit 0 - ;; - *) - echo "Unknown option: $1" - echo "$usage" - exit 1 - ;; - esac -done +if [[ "$*" == *-h* ]] || [[ "$*" == *--help* ]]; then + echo "$usage" + exit 0 +fi tmp_dir=$(mktemp -d) this_dir=$(dirname "$(realpath "${BASH_SOURCE:-$0}")") @@ -32,6 +26,6 @@ multimedia="qt.qt6.661.addons.qtmultimedia" curl "https://d13lb3tujbc8s0.cloudfront.net/onlineinstallers/qt-unified-linux-x64-4.6.1-online.run" -o "$tmp_dir/qt-installer.run" chmod +x "$tmp_dir/qt-installer.run" -"$tmp_dir/qt-installer.run" --root "$install_dir" --accept-licenses --accept-obligations --default-answer --confirm-command install $base $multimedia +"$tmp_dir/qt-installer.run" --root "$install_dir" --accept-licenses --accept-obligations --default-answer --confirm-command install $base $multimedia $@ rm -rf "$tmp_dir" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7285e1b..f0f00b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,12 @@ -list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/3rdparty/Qt/6.6.1/gcc_64/lib/cmake) +list(APPEND CMAKE_PREFIX_PATH + ${CMAKE_SOURCE_DIR}/3rdparty/Qt/6.6.1/gcc_64/lib/cmake) +list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/3rdparty/Qt/lib/cmake) +set(Boost_USE_STATIC_LIBS ON) find_package(spdlog REQUIRED) find_package(Boost REQUIRED COMPONENTS filesystem) -find_package(Qt6 REQUIRED COMPONENTS Widgets Multimedia MultimediaWidgets) +find_package(Qt6 REQUIRED COMPONENTS Widgets Multimedia MultimediaWidgets + WaylandClient WaylandCompositor) message(STATUS "Qt6 was found at ${Qt6_DIR}") @@ -12,9 +16,16 @@ file(GLOB_RECURSE INCLUDES "${CMAKE_SOURCE_DIR}/include/*") add_library(snapshotapp ${SOURCES} ${INCLUDES}) target_include_directories( snapshotapp - PUBLIC ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/3rdparty/include ${Boost_INCLUDE_DIRS} + PUBLIC ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/3rdparty/include + ${Boost_INCLUDE_DIRS} INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/snapshotapp_autogen/include) target_link_libraries( - snapshotapp PUBLIC spdlog::spdlog_header_only Qt6::Widgets Qt6::Multimedia - Qt6::MultimediaWidgets Boost::filesystem) -install(TARGETS snapshotapp DESTINATION lib) + snapshotapp + PUBLIC spdlog::spdlog_header_only + Boost::boost + Boost::filesystem + Qt6::Widgets + Qt6::Multimedia + Qt6::MultimediaWidgets + Qt6::WaylandClient + Qt6::WaylandCompositor)