tests / build-test (push) Has been cancelled
Adds an UpdateManager that queries the Gitea releases API once per day, stores the last check state in a JSON file, and offers to pull + rebuild the source repository when a newer version exists. The running binary is left untouched until the next launch. Also sets the app version from the version file at build time instead of the hardcoded 1.0.0, and copies the version file next to the executable.
129 lines
5.5 KiB
CMake
129 lines
5.5 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
project(PacManager VERSION 1.0.0 LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_AUTOMOC ON)
|
|
set(CMAKE_AUTORCC ON)
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
# Find Qt6
|
|
find_package(Qt6 REQUIRED COMPONENTS Widgets Network)
|
|
|
|
# Main executable
|
|
set(SOURCES
|
|
src/main.cpp
|
|
src/main-window.cpp
|
|
src/pacman-manager.cpp
|
|
src/plugin-manager.cpp
|
|
src/history-manager.cpp
|
|
src/package-model.cpp
|
|
src/update-manager.cpp
|
|
resources/resources.qrc
|
|
)
|
|
|
|
set(HEADERS
|
|
include/package-manager.h
|
|
include/pacman-manager.h
|
|
include/plugin-manager.h
|
|
include/provider-plugin.h
|
|
include/main-window.h
|
|
include/history-manager.h
|
|
include/package-model.h
|
|
include/update-manager.h
|
|
)
|
|
|
|
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
|
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE include)
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets Qt6::Network)
|
|
|
|
# Copy the version file next to the executable so UpdateManager can read the
|
|
# running build's version at runtime.
|
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
${CMAKE_CURRENT_SOURCE_DIR}/version
|
|
$<TARGET_FILE_DIR:${PROJECT_NAME}>/version)
|
|
|
|
# Install
|
|
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
|
install(FILES version DESTINATION bin)
|
|
install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME})
|
|
|
|
# Tests
|
|
enable_testing()
|
|
add_executable(pacman-manager-test tests/pacman-manager.test.cpp src/pacman-manager.cpp)
|
|
target_include_directories(pacman-manager-test PRIVATE include)
|
|
add_test(NAME pacman-manager-test COMMAND pacman-manager-test)
|
|
|
|
add_executable(flatpak-manager-test tests/flatpak-manager.test.cpp
|
|
plugins/flatpak-provider/flatpak-manager.cpp)
|
|
target_include_directories(flatpak-manager-test PRIVATE include plugins/flatpak-provider)
|
|
add_test(NAME flatpak-manager-test COMMAND flatpak-manager-test)
|
|
|
|
# Real end-to-end test of the Flatpak provider against the live flatpak CLI
|
|
# (installs and uninstalls a small app). Skipped when flatpak is missing.
|
|
add_executable(flatpak-integration-test tests/flatpak-integration.test.cpp
|
|
plugins/flatpak-provider/flatpak-manager.cpp)
|
|
target_include_directories(flatpak-integration-test PRIVATE include plugins/flatpak-provider)
|
|
add_test(NAME flatpak-integration-test COMMAND flatpak-integration-test)
|
|
|
|
add_executable(package-utils-test tests/package-utils.test.cpp)
|
|
target_include_directories(package-utils-test PRIVATE include)
|
|
add_test(NAME package-utils-test COMMAND package-utils-test)
|
|
|
|
# Plugin manager test: needs Qt (QSettings/QLibrary) and the example plugin
|
|
# built next to the test binary, so it is only enabled with the plugin option.
|
|
if(FWS_BUILD_EXAMPLE_PLUGIN)
|
|
add_executable(plugin-manager-test tests/plugin-manager.test.cpp
|
|
src/plugin-manager.cpp src/pacman-manager.cpp
|
|
plugins/flatpak-provider/flatpak-manager.cpp)
|
|
target_include_directories(plugin-manager-test PRIVATE include plugins/flatpak-provider)
|
|
target_link_libraries(plugin-manager-test PRIVATE Qt6::Core)
|
|
add_dependencies(plugin-manager-test example-provider-plugin)
|
|
add_custom_command(TARGET plugin-manager-test POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory
|
|
$<TARGET_FILE_DIR:plugin-manager-test>/plugins
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
$<TARGET_FILE:example-provider-plugin>
|
|
$<TARGET_FILE_DIR:plugin-manager-test>/plugins/
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
$<TARGET_FILE:flatpak-provider-plugin>
|
|
$<TARGET_FILE_DIR:plugin-manager-test>/plugins/)
|
|
add_test(NAME plugin-manager-test COMMAND plugin-manager-test)
|
|
endif()
|
|
|
|
# Optional example external provider plugin. Demonstrates the plugin mechanism:
|
|
# the produced library is copied next to the executable and discovered at
|
|
# runtime by PluginManager (see the Providers page).
|
|
option(FWS_BUILD_EXAMPLE_PLUGIN "Build the example external provider plugin" OFF)
|
|
if(FWS_BUILD_EXAMPLE_PLUGIN)
|
|
add_library(example-provider-plugin MODULE plugins/example-provider/example-provider.cpp)
|
|
target_include_directories(example-provider-plugin PRIVATE include)
|
|
set_target_properties(example-provider-plugin PROPERTIES
|
|
OUTPUT_NAME "sample-provider"
|
|
CXX_STANDARD 17
|
|
CXX_STANDARD_REQUIRED ON)
|
|
add_custom_command(TARGET example-provider-plugin POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:PacManager>/plugins
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:example-provider-plugin>
|
|
$<TARGET_FILE_DIR:PacManager>/plugins/)
|
|
endif()
|
|
|
|
# Flatpak provider plugin. Flatpak ships as an external plugin (not compiled
|
|
# into the binary): the produced .so is copied next to the executable and
|
|
# discovered at runtime by PluginManager, so it can be updated or removed
|
|
# independently of the core app.
|
|
add_library(flatpak-provider-plugin MODULE
|
|
plugins/flatpak-provider/flatpak-provider.cpp
|
|
plugins/flatpak-provider/flatpak-manager.cpp)
|
|
target_include_directories(flatpak-provider-plugin PRIVATE include plugins/flatpak-provider)
|
|
set_target_properties(flatpak-provider-plugin PROPERTIES
|
|
OUTPUT_NAME "flatpak-provider"
|
|
CXX_STANDARD 17
|
|
CXX_STANDARD_REQUIRED ON)
|
|
add_custom_command(TARGET flatpak-provider-plugin POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:PacManager>/plugins
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:flatpak-provider-plugin>
|
|
$<TARGET_FILE_DIR:PacManager>/plugins/)
|