Repository navigation
Closed
Labels
Milestone
Description
Currently the version is hard coded directly in CMakeLists.txt, e.g.:
Line 9 in a8397ba
| project(CpuFeatures VERSION 0.6.0 LANGUAGES C) |
So each time a new release is pushed, using the github release interface, you must do the sync manually with the CMakeLists.txt
We should instead try to generate it from the last git tag (and fallback to 9.9.9 or 9999 like gentoo) IMHO
Proposal
A small proposal (not tested!!!)
CMakeLists.txt:
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(utils)
set_version(VERSION)
project(CpuFeatures VERSION ${VERSION} LANGUAGES C)cmake/utils.cmake:
function(get_version_from_git_tag GIT_VERSION)
find_package(Git QUIET)
if(NOT GIT_FOUND)
message(STATUS "Did not find git package.")
set(VERSION 9.9.9)
else()
# If no tags can be found, it is a git shallow clone
execute_process(COMMAND
${GIT_EXECUTABLE} describe --tags
RESULT_VARIABLE _OUTPUT_VAR
OUTPUT_VARIABLE FULL
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT _OUTPUT_VAR)
set(VERSION "${RESULT_VARIABLE}")
else()
message(STATUS "Did not find any tag.")
set(VERSION "9.9.9")
endif()
endif()
set(${GIT_VERSION} "${VERSION}" PARENT_SCOPE)
endfunction()
function(set_version VERSION)
# Retrieve version from git tag if .git is present otherwise set it to 9.9.9
get_filename_component(GIT_DIR ".git" ABSOLUTE)
if(EXISTS ${GIT_DIR})
get_version_from_git_tag(GIT_VERSION)
else()
# If not a git repo force version to 9.9.9
set(GIT_VERSION "9.9.9")
endif()
set(${VERSION} "${GIT_VERSION}" PARENT_SCOPE)
endfunction()ref: Gentoo 9999 ebuild https://forums.gentoo.org/viewtopic-p-7428490.html
Activity
gchatelet commentedon Oct 15, 2020
Thanks for the proposal! How does this interact with installation? Does it put a burden on package maintainers?
Mizux commentedon Oct 15, 2020
For package maintainers using a git clone with the tag, it should work as expected.
Now the bad news, for archive based build, you'll end up with the version fallback i.e. the wrong version name.
gchatelet commentedon Oct 15, 2020
As per our off line discussion let's create a simple bash script that will take care of the release process (version bump, tag, github release and release notes)
Provides a release script
Provides a release script (#142)