fix(build): Set git version number only when open62541 is the main CMake project

This commit disables reading the version number from git when open62541 is not the main CMake project. This is necessary when including the project via CPM, as the version number would get overwritten by the git tag of the main project.
This commit is contained in:
sbreuss 2025-01-08 11:40:50 +01:00 committed by GitHub
parent 0f945f0e4f
commit b69f612e26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,9 +48,11 @@ set(OPEN62541_VER_PATCH 8)
set(OPEN62541_VER_LABEL "-undefined") # like "-rc1" or "-g4538abcd" or "-g4538abcd-dirty"
set(OPEN62541_VER_COMMIT "unknown-commit")
# Overwrite the version information based on git if available
include(SetGitBasedVersion)
set_open62541_version()
# Overwrite the version information based on git if available and we are the main cmake project.
if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
include(SetGitBasedVersion)
set_open62541_version()
endif()
# Examples for the version string are:
# v1.2