mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-27 15:14:35 +00:00
Releases and version numbers are gone. CI now rebuilds all three platforms on every change to main and commits the packages to the `builds` branch, so what anyone downloads is the current state of the repository. The branch is rewritten from scratch each time rather than added to, so the repository keeps one copy of the packages instead of a ~70 MB set per commit. Without tags there is no version to compare, so a build carries the commit it was made from and the branch carries a VERSION file naming the same commit. The updater fetches those few bytes and treats any difference as being behind; commits are not ordered, and the branch only ever holds the current build. The installers fetch from the branch over raw.githubusercontent.com for the same reason. 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 COMMIT in the Makefile: bakes the source commit in for the updater.
|
|
if(DEFINED APP_COMMIT AND NOT APP_COMMIT STREQUAL "")
|
|
target_compile_definitions(maturita PRIVATE APP_COMMIT="${APP_COMMIT}")
|
|
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)
|