build(cmake): check ZEAL_RELEASE_BUILD environment variable

This commit is contained in:
Oleg Shparber 2023-09-18 01:51:59 -04:00
parent e977debce9
commit 24e2ce4e09
3 changed files with 19 additions and 7 deletions

View File

@ -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")
@ -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}")
@ -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

View File

@ -58,6 +58,16 @@
"value": "ON"
}
}
},
{
"name": "config-release",
"hidden": true,
"cacheVariables": {
"ZEAL_RELEASE_BUILD": {
"type": "BOOL",
"value": "ON"
}
}
}
],
"buildPresets": [

View File

@ -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