Skip to content

Commit 263f992

Browse files
committed
use 3rdparty git info
1 parent f86d46b commit 263f992

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@
102102
[submodule "3rdparty/imguizmo"]
103103
path = 3rdparty/imguizmo
104104
url = [email protected]:Devsh-Graphics-Programming/ImGuizmo.git
105+
[submodule "3rdparty/git-version-tracking"]
106+
path = 3rdparty/git-version-tracking
107+
url = [email protected]:Devsh-Graphics-Programming/cmake-git-version-tracking.git

3rdparty/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ add_library(spirv_cross OBJECT
275275
)
276276
target_compile_definitions(spirv_cross PUBLIC SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
277277

278+
# cmake-git-version-tracking
279+
add_subdirectory(git-version-tracking EXCLUDE_FROM_ALL)
280+
281+
278282
if(NBL_BUILD_IMGUI)
279283
add_library(imgui STATIC
280284
"imgui/imconfig.h"
@@ -381,6 +385,7 @@ set(NBL_3RDPARTY_TARGETS
381385
shaderc
382386
jpeg-static
383387
bzip2
388+
cmake_git_version_tracking
384389
simdjson
385390
nlohmann_json
386391
glslang

3rdparty/git-version-tracking

Submodule git-version-tracking added at ceb2e1d

include/nabla.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define __NABLA_H_INCLUDED__
1919

2020
// meta info
21-
#include "nbl/git_info.h"
21+
#include "git_info.h"
2222

2323
// core lib
2424
#include "nbl/core/declarations.h"

src/nbl/CMakeLists.txt

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,6 @@ set(NBL_SCENE_SOURCES
284284
${NBL_ROOT_PATH}/src/nbl/scene/ITransformTree.cpp
285285
)
286286

287-
set(NBL_GENERATED_SOURCES
288-
${CMAKE_CURRENT_BINARY_DIR}/src/nbl/git_info.cpp
289-
)
290-
291287
set(NABLA_SRCS_COMMON
292288
${NBL_CORE_SOURCES}
293289
${NBL_SYSTEM_SOURCES}
@@ -658,18 +654,14 @@ glue_source_definitions(Nabla _NBL_SOURCE_DEFINITIONS_)
658654
set(_NBL_DEFINE_FILE_WRAPPER_ ${CMAKE_CURRENT_BINARY_DIR}/include/define.h)
659655
write_source_definitions("${_NBL_DEFINE_FILE_WRAPPER_}" "${_NBL_SOURCE_DEFINITIONS_}")
660656

661-
# generate git info
662-
execute_process( COMMAND ${GIT_EXECUTABLE} log -1 --format=%H
663-
WORKING_DIRECTORY ${NBL_ROOT_PATH}
664-
OUTPUT_VARIABLE NBL_GIT_COMMIT_HASH
665-
OUTPUT_STRIP_TRAILING_WHITESPACE
666-
)
667-
execute_process( COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
668-
WORKING_DIRECTORY ${NBL_ROOT_PATH}
669-
OUTPUT_VARIABLE NBL_GIT_COMMIT_SHORT_HASH
670-
OUTPUT_STRIP_TRAILING_WHITESPACE
657+
# git version tracking
658+
target_link_libraries(Nabla PUBLIC cmake_git_version_tracking)
659+
target_include_directories(cmake_git_version_tracking PUBLIC
660+
${CMAKE_CURRENT_BINARY_DIR}/include
661+
"$<$<CONFIG:DEBUG>:${NABLA_CONF_DIR_DEBUG}>"
662+
"$<$<CONFIG:RELEASE>:${NABLA_CONF_DIR_RELEASE}>"
663+
"$<$<CONFIG:RELWITHDEBINFO>:${NABLA_CONF_DIR_RELWITHDEBINFO}>"
671664
)
672-
configure_file("${NBL_ROOT_PATH}/src/nbl/git_info.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/src/nbl/git_info.cpp")
673665

674666
#on MSVC it won't compile without this option!
675667
if (MSVC)

0 commit comments

Comments
 (0)