build: seed APP_VERSION and API_KEY from the environment
Fresh cmake configures pick up APP_VERSION/API_KEY from environment variables (as nix develop and CI provide them); -D still wins on reconfigure. Also normalizes indentation in the sd-bus blocks.
This commit is contained in:
+23
-9
@@ -8,15 +8,29 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
# App version string shown at the top of the Home footer. Defaults to the
|
||||
# project version; override at configure time with:
|
||||
# cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DAPP_VERSION="1.2.3"
|
||||
set(APP_VERSION "${PROJECT_VERSION}" CACHE STRING
|
||||
"Version string shown in the Home footer (override at configure time)")
|
||||
# or by exporting APP_VERSION in the environment (the `nix develop` shell does
|
||||
# this; the env var only seeds a fresh configure, -D wins on reconfigure).
|
||||
if(DEFINED ENV{APP_VERSION})
|
||||
set(APP_VERSION "$ENV{APP_VERSION}" CACHE STRING
|
||||
"Version string shown in the Home footer (override at configure time)")
|
||||
else()
|
||||
set(APP_VERSION "${PROJECT_VERSION}" CACHE STRING
|
||||
"Version string shown in the Home footer (override at configure time)")
|
||||
endif()
|
||||
|
||||
# API bearer key baked into the binary and sent as `Authorization: Bearer <key>`
|
||||
# on every portal request. Leave empty to send no auth header. Never commit the
|
||||
# real value — inject it at CI build time from a secret, e.g.:
|
||||
# cmake ... -DAPI_KEY="${{ secrets.PORTAL_API_KEY }}"
|
||||
set(API_KEY "" CACHE STRING
|
||||
"Portal API key baked into the binary (leave empty to skip auth)")
|
||||
# The `nix develop` shell exports API_KEY from the ambient environment, which
|
||||
# seeds a fresh configure; -D wins on reconfigure.
|
||||
if(DEFINED ENV{API_KEY})
|
||||
set(API_KEY "$ENV{API_KEY}" CACHE STRING
|
||||
"Portal API key baked into the binary (leave empty to skip auth)")
|
||||
else()
|
||||
set(API_KEY "" CACHE STRING
|
||||
"Portal API key baked into the binary (leave empty to skip auth)")
|
||||
endif()
|
||||
|
||||
find_package(SDL3 REQUIRED)
|
||||
find_package(SDL3_ttf REQUIRED)
|
||||
@@ -31,8 +45,8 @@ include(GoogleTest)
|
||||
|
||||
# Network manager dependencies (Linux only)
|
||||
if(UNIX AND NOT APPLE)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SDBUS REQUIRED libsystemd)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SDBUS REQUIRED libsystemd)
|
||||
endif()
|
||||
|
||||
add_executable(radiantwave
|
||||
@@ -92,9 +106,9 @@ target_link_libraries(radiantwave PRIVATE
|
||||
)
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_libraries(radiantwave PRIVATE ${SDBUS_LIBRARIES} resolv)
|
||||
target_include_directories(radiantwave PRIVATE ${SDBUS_INCLUDE_DIRS})
|
||||
target_compile_definitions(radiantwave PRIVATE HAS_DBUS=1)
|
||||
target_link_libraries(radiantwave PRIVATE ${SDBUS_LIBRARIES} resolv)
|
||||
target_include_directories(radiantwave PRIVATE ${SDBUS_INCLUDE_DIRS})
|
||||
target_compile_definitions(radiantwave PRIVATE HAS_DBUS=1)
|
||||
endif()
|
||||
|
||||
install(TARGETS radiantwave RUNTIME DESTINATION bin)
|
||||
|
||||
Reference in New Issue
Block a user