Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart-Steensma authored and BartSte committed Jan 5, 2024
1 parent 1696d21 commit 0d8b4e1
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 9 additions & 15 deletions scripts/install-qt
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail

usage="Usage: $0
usage="Usage: $0 <optional packages>
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}")")
Expand All @@ -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"
27 changes: 21 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}")

Expand All @@ -12,9 +16,20 @@ 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)

qt_import_plugins(snapshotapp INCLUDE QWaylandIntegrationPlugin)

0 comments on commit 0d8b4e1

Please sign in to comment.