mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-27 15:14:35 +00:00
Bake the release tag into the binary so the app knows what it is running; plain builds keep the "dev" default and never offer an update. The CI workflow already exported the tag on Linux and macOS, so only the Windows job needed it. Read the newest version from the redirect GitHub serves for /releases/latest, which avoids the REST API and its unauthenticated rate limit and needs no JSON parser. Networking goes through the curl command rather than a linked library: curl handles TLS, redirects and proxies, it ships on all three platforms, and it keeps the bundling scripts free of another shared library. An application cannot reliably replace its own files while running, so every platform follows one shape: unpack beside the current install, write a script that waits for this process to exit before swapping, then launch it detached and quit. Staging beside the install keeps the move on one filesystem and fails early when the location is read-only. The Windows script copies without mirroring so the progress files kept inside the install directory survive. Check quietly a few seconds after startup and offer the result in a banner above the pages, with a manual check in the settings popover. Co-authored-by: Cursor <cursoragent@cursor.com>
93 lines
3.9 KiB
CMake
93 lines
3.9 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(maturita C)
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
# GTK4 is found through pkg-config everywhere: Linux/macOS packages, MSYS2,
|
|
# vcpkg and the native MSVC (gvsbuild) package all ship .pc files.
|
|
if(MSVC)
|
|
# On MSVC the Unix-style flags pkg-config prints are not understood, so
|
|
# ask for the native "/I" and ".lib" form instead.
|
|
find_program(PKG_CONFIG_EXECUTABLE
|
|
NAMES pkg-config pkg-config.exe pkgconf pkgconf.exe)
|
|
if(NOT PKG_CONFIG_EXECUTABLE)
|
|
message(FATAL_ERROR
|
|
"pkg-config was not found. A native GTK4 install for MSVC "
|
|
"(e.g. gvsbuild) provides it; set PKG_CONFIG_PATH to "
|
|
"<GTK>/lib/pkgconfig. See README.md.")
|
|
endif()
|
|
|
|
execute_process(
|
|
COMMAND "${PKG_CONFIG_EXECUTABLE}" --cflags gtk4 --msvc-syntax
|
|
OUTPUT_VARIABLE GTK4_CFLAGS_RAW
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
RESULT_VARIABLE GTK4_CFLAGS_RESULT)
|
|
execute_process(
|
|
COMMAND "${PKG_CONFIG_EXECUTABLE}" --libs gtk4 --msvc-syntax
|
|
OUTPUT_VARIABLE GTK4_LIBS_RAW
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
RESULT_VARIABLE GTK4_LIBS_RESULT)
|
|
|
|
if(NOT GTK4_CFLAGS_RESULT EQUAL 0 OR NOT GTK4_LIBS_RESULT EQUAL 0)
|
|
message(FATAL_ERROR
|
|
"pkg-config could not find GTK4. Set PKG_CONFIG_PATH to "
|
|
"<GTK>/lib/pkgconfig (for example C:\\gtk\\lib\\pkgconfig).")
|
|
endif()
|
|
|
|
separate_arguments(GTK4_CFLAGS WINDOWS_COMMAND "${GTK4_CFLAGS_RAW}")
|
|
separate_arguments(GTK4_LIBS WINDOWS_COMMAND "${GTK4_LIBS_RAW}")
|
|
else()
|
|
find_package(PkgConfig REQUIRED)
|
|
pkg_check_modules(GTK4 REQUIRED IMPORTED_TARGET gtk4)
|
|
endif()
|
|
|
|
# WIN32 suppresses the console window on Windows; the app still uses main(),
|
|
# so MSVC needs mainCRTStartup as the entry point.
|
|
file(GLOB MATURITA_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.c")
|
|
if(WIN32)
|
|
add_executable(maturita WIN32 ${MATURITA_SOURCES}
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/maturita.rc")
|
|
else()
|
|
add_executable(maturita ${MATURITA_SOURCES})
|
|
endif()
|
|
|
|
# Mirrors VERSION in the Makefile: bakes the release tag in for the updater.
|
|
if(DEFINED APP_VERSION AND NOT APP_VERSION STREQUAL "")
|
|
target_compile_definitions(maturita PRIVATE APP_VERSION="${APP_VERSION}")
|
|
endif()
|
|
|
|
if(MSVC)
|
|
target_compile_options(maturita PRIVATE ${GTK4_CFLAGS})
|
|
target_link_options(maturita PRIVATE ${GTK4_LIBS})
|
|
target_link_options(maturita PRIVATE /ENTRY:mainCRTStartup)
|
|
target_compile_definitions(maturita PRIVATE _CRT_SECURE_NO_WARNINGS)
|
|
else()
|
|
target_link_libraries(maturita PRIVATE PkgConfig::GTK4 m)
|
|
target_compile_options(maturita PRIVATE
|
|
-Wall -Wextra -Wno-deprecated-declarations)
|
|
if(APPLE)
|
|
target_link_libraries(maturita PRIVATE
|
|
"-framework AppKit" "-framework Foundation")
|
|
endif()
|
|
endif()
|
|
|
|
# The GTK stylesheet, window icon and Freedesktop share/ tree are loaded at
|
|
# runtime from the working directory (or next to the binary).
|
|
add_custom_command(TARGET maturita POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_SOURCE_DIR}/style.css
|
|
$<TARGET_FILE_DIR:maturita>/style.css
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory
|
|
$<TARGET_FILE_DIR:maturita>/icons/hicolor/512x512/apps
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_SOURCE_DIR}/assets/app-icon.png
|
|
$<TARGET_FILE_DIR:maturita>/icons/hicolor/512x512/apps/maturita.png
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory
|
|
${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/hicolor/512x512/apps
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_SOURCE_DIR}/assets/app-icon.png
|
|
${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/hicolor/512x512/apps/maturita.png
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
${CMAKE_CURRENT_SOURCE_DIR}/share
|
|
$<TARGET_FILE_DIR:maturita>/share)
|