Skip to content

Commit

Permalink
build(cmake): check ZEAL_RELEASE_BUILD environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
trollixx committed Sep 18, 2023
1 parent e977deb commit 24e2ce4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
11 changes: 4 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ project(Zeal

# Set to TRUE for a tagged release.
# NOTE: Don't forget to add a new release entry in the AppStream metadata!
set(ZEAL_RELEASE_BUILD FALSE)
if(NOT ZEAL_RELEASE_BUILD AND DEFINED ENV{ZEAL_RELEASE_BUILD})
set(ZEAL_RELEASE_BUILD $ENV{ZEAL_RELEASE_BUILD})
endif()

# Project information.
set(PROJECT_COMPANY_NAME "Oleg Shparber")
Expand All @@ -36,7 +38,7 @@ if(NOT ZEAL_RELEASE_BUILD)
if(Zeal_GIT_VERSION_SHA)
# Extra check in case we forgot to bump version in project() directive.
if(NOT PROJECT_VERSION_PATCH EQUAL Zeal_GIT_VERSION_PATCH_NEXT)
message(FATAL_ERROR "Incorrect patch version! Forgot to bump?")
message(WARNING "Incorrect patch version! Forgot to bump?")
endif()

set(ZEAL_VERSION_SUFFIX "-dev.${Zeal_GIT_VERSION_AHEAD}+${Zeal_GIT_VERSION_SHA}")
Expand All @@ -50,11 +52,6 @@ message(NOTICE "Calculated Zeal version: ${ZEAL_VERSION_FULL}")

file(WRITE "${CMAKE_BINARY_DIR}/zeal_version" ${ZEAL_VERSION_FULL})

# For development builds insert an extra release in the AppStream metadata.
if(NOT ZEAL_RELEASE_BUILD)
string(TIMESTAMP ZEAL_APPSTREAM_DEV_RELEASE "\n <release date=\"%Y-%m-%d\" version=\"${ZEAL_VERSION_FULL}\" type=\"development\" />")
endif()

# A custom target to print the full version.
# Usage: cmake --build build --preset ninja-multi-vcpkg-release --target zeal_version
add_custom_target(zeal_version
Expand Down
10 changes: 10 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@
"value": "ON"
}
}
},
{
"name": "config-release",
"hidden": true,
"cacheVariables": {
"ZEAL_RELEASE_BUILD": {
"type": "BOOL",
"value": "ON"
}
}
}
],
"buildPresets": [
Expand Down
5 changes: 5 additions & 0 deletions assets/freedesktop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ if(UNIX AND NOT APPLE)
DESTINATION ${KDE_INSTALL_ICONDIR}
)

# For development builds insert an extra release in the AppStream metadata.
if(NOT ZEAL_RELEASE_BUILD)
string(TIMESTAMP ZEAL_APPSTREAM_DEV_RELEASE "\n <release date=\"%Y-%m-%d\" version=\"${ZEAL_VERSION_FULL}\" type=\"development\" />")
endif()

configure_file(
org.zealdocs.zeal.appdata.xml.in
org.zealdocs.zeal.appdata.xml
Expand Down

0 comments on commit 24e2ce4

Please sign in to comment.