Set project name + version from git/GIT_DESC
This commit is contained in:
@@ -282,6 +282,20 @@ FetchContent_Declare(monado
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
add_custom_target(wivrn-version ALL
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D GIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||
-D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/common/version.cpp.in
|
||||
-D OUTPUT_FILE=${CMAKE_BINARY_DIR}/version.cpp
|
||||
-D INPUT_FILE_1=${CMAKE_CURRENT_SOURCE_DIR}/server/u_git_tag.cpp.in
|
||||
-D OUTPUT_FILE_1=${CMAKE_BINARY_DIR}/u_git_tag.cpp
|
||||
-D GIT_DESC="${GIT_DESC}"
|
||||
-D GIT_COMMIT="${GIT_COMMIT}"
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/GitVersion.cmake
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/version.cpp ${CMAKE_BINARY_DIR}/u_git_tag.cpp
|
||||
SOURCES common/version.cpp.in server/u_git_tag.cpp.in
|
||||
)
|
||||
|
||||
add_subdirectory(external)
|
||||
if (NEED_COMMON)
|
||||
add_subdirectory(common)
|
||||
|
||||
@@ -30,3 +30,4 @@ else()
|
||||
endif()
|
||||
|
||||
configure_file(${INPUT_FILE} ${OUTPUT_FILE})
|
||||
configure_file(${INPUT_FILE_1} ${OUTPUT_FILE_1})
|
||||
|
||||
+1
-14
@@ -5,25 +5,12 @@ else()
|
||||
FetchContent_MakeAvailable(boost)
|
||||
endif()
|
||||
|
||||
add_custom_target(wivrn-version ALL
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D GIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||
-D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/version.cpp.in
|
||||
-D OUTPUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
-D CMAKE_PROJECT_VERSION=${CMAKE_PROJECT_VERSION}
|
||||
-D GIT_DESC="${GIT_DESC}"
|
||||
-D GIT_COMMIT="${GIT_COMMIT}"
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/GitVersion.cmake
|
||||
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp.in
|
||||
)
|
||||
|
||||
configure_file(wivrn_config.h.in wivrn_config.h)
|
||||
|
||||
add_library(wivrn-common-base STATIC EXCLUDE_FROM_ALL
|
||||
utils/strings.cpp
|
||||
utils/xdg_base_directory.cpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
${CMAKE_BINARY_DIR}/version.cpp
|
||||
)
|
||||
|
||||
add_library(wivrn-common STATIC EXCLUDE_FROM_ALL
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
From a9ac675eab72a6ce96adb38215e83f7b3e9b51e7 Mon Sep 17 00:00:00 2001
|
||||
From: no name <git-am@invalid>
|
||||
Date: Fri, 20 Mar 2026 16:51:18 +0100
|
||||
Subject: [PATCH] configure u_git_tag in WiVRn
|
||||
|
||||
---
|
||||
src/xrt/auxiliary/util/CMakeLists.txt | 7 +------
|
||||
1 file changed, 1 insertion(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/auxiliary/util/CMakeLists.txt b/src/xrt/auxiliary/util/CMakeLists.txt
|
||||
index d45cd60c9..ec0d45434 100644
|
||||
--- a/src/xrt/auxiliary/util/CMakeLists.txt
|
||||
+++ b/src/xrt/auxiliary/util/CMakeLists.txt
|
||||
@@ -10,11 +10,6 @@
|
||||
# by applications like the OpenXR runtime library.
|
||||
#
|
||||
|
||||
-configure_file(
|
||||
- "${CMAKE_CURRENT_SOURCE_DIR}/u_git_tag.c.in" "${CMAKE_CURRENT_BINARY_DIR}/u_git_tag.c"
|
||||
- @ONLY
|
||||
- )
|
||||
-
|
||||
add_library(
|
||||
aux_util STATIC
|
||||
u_autoexpgain.c
|
||||
@@ -118,7 +113,7 @@ add_library(
|
||||
u_worker.cpp
|
||||
u_worker.h
|
||||
u_worker.hpp
|
||||
- "${CMAKE_CURRENT_BINARY_DIR}/u_git_tag.c"
|
||||
+ "${U_GIT_TAG_CPP}"
|
||||
)
|
||||
target_link_libraries(
|
||||
aux_util
|
||||
--
|
||||
2.53.0
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
set(U_GIT_TAG_CPP "${CMAKE_BINARY_DIR}/u_git_tag.cpp")
|
||||
|
||||
set(XRT_BUILD_DRIVER_ARDUINO OFF)
|
||||
set(XRT_BUILD_DRIVER_BLUBUR_S1 OFF)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include <cctype>
|
||||
#include <charconv>
|
||||
#include <stdint.h>
|
||||
#include <string_view>
|
||||
|
||||
namespace
|
||||
{
|
||||
uint16_t version(int digit)
|
||||
{
|
||||
std::string_view tag = "@GIT_DESC@";
|
||||
if (not tag.empty() and tag[0] == 'v')
|
||||
tag = tag.substr(1);
|
||||
for (; digit > 0; --digit)
|
||||
{
|
||||
while (not tag.empty() and std::isdigit(tag[0]))
|
||||
tag = tag.substr(1);
|
||||
if (not tag.empty() and tag[0] == '.')
|
||||
tag = tag.substr(1);
|
||||
}
|
||||
tag = tag.substr(0, tag.find('.'));
|
||||
|
||||
uint16_t val = 0;
|
||||
// We don't care if parsing fail, return 0
|
||||
std::from_chars(tag.begin(), tag.end(), val);
|
||||
return val;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern const char u_git_tag[] = "@GIT_DESC@";
|
||||
extern const uint16_t u_version_major = version(0);
|
||||
extern const uint16_t u_version_minor = version(1);
|
||||
extern const uint16_t u_version_patch = version(2);
|
||||
extern const char u_runtime_description[] = "WiVRn";
|
||||
}
|
||||
Reference in New Issue
Block a user