summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-07-11 19:52:54 +0800
committerGitHub <noreply@github.com>2024-07-11 19:52:54 +0800
commit45baeb32a7db8930cf3dc4f32cb5fefba742c6b5 (patch)
tree119a2677abee946ac9419c4ec2dbc05062242db7
parent57742cb02b04ea973ff702b42a7e380decd4048f (diff)
populate slang-tag-version with cmake (#4611)
At the moment it is always "unknown"
-rw-r--r--slang-tag-version.h1
-rw-r--r--slang.h21
-rw-r--r--source/slang/CMakeLists.txt6
-rw-r--r--source/slang/slang.cpp4
4 files changed, 17 insertions, 15 deletions
diff --git a/slang-tag-version.h b/slang-tag-version.h
deleted file mode 100644
index 9b241a745..000000000
--- a/slang-tag-version.h
+++ /dev/null
@@ -1 +0,0 @@
-#define SLANG_TAG_VERSION "unknown"
diff --git a/slang.h b/slang.h
index 0f75c4c95..2f8f8d15d 100644
--- a/slang.h
+++ b/slang.h
@@ -1658,15 +1658,18 @@ extern "C"
void* userData);
/*!
- @brief Get the build version 'tag' string. The string is the same as produced via `git describe --tags`
- for the project. If Slang is built separately from the automated build scripts
- the contents will by default be 'unknown'. Any string can be set by changing the
- contents of 'slang-tag-version.h' file and recompiling the project.
-
- This function will return exactly the same result as the method getBuildTag string on IGlobalSession.
-
- An advantage of using this function over the method is that doing so does not require the creation of
- a session, which can be a fairly costly operation.
+ @brief Get the build version 'tag' string. The string is the same as
+ produced via `git describe --tags --match v*` for the project. If such a
+ version could not be determined at build time then the contents will be
+ 0.0.0-unknown. Any string can be set by passing
+ -DSLANG_VERSION_FULL=whatever during the cmake invocation.
+
+ This function will return exactly the same result as the method
+ getBuildTagString on IGlobalSession.
+
+ An advantage of using this function over the method is that doing so does
+ not require the creation of a session, which can be a fairly costly
+ operation.
@return The build tag string
*/
diff --git a/source/slang/CMakeLists.txt b/source/slang/CMakeLists.txt
index 495a05f36..40eca76a9 100644
--- a/source/slang/CMakeLists.txt
+++ b/source/slang/CMakeLists.txt
@@ -249,7 +249,7 @@ target_include_directories(
#
# Slang itself
#
-configure_file(${slang_SOURCE_DIR}/slang-tag-version.h.in slang-tag-version.h)
+configure_file(${slang_SOURCE_DIR}/slang-tag-version.h.in slang-version-header/slang-tag-version.h)
slang_add_target(
.
${SLANG_LIB_TYPE}
@@ -267,10 +267,10 @@ slang_add_target(
# slang.h is in the project root, so include that directory in the interface
# for slang
INCLUDE_DIRECTORIES_PUBLIC ${slang_SOURCE_DIR}
- INCLUDE_DIRECTORIES_PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
+ INCLUDE_DIRECTORIES_PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/slang-version-header
EXPORT_MACRO_PREFIX SLANG
INSTALL
- PUBLIC_HEADERS ${slang_SOURCE_DIR}/slang*.h
+ PUBLIC_HEADERS ${slang_SOURCE_DIR}/slang*.h ${CMAKE_CURRENT_BINARY_DIR}/slang-version-header/*.h
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index d601dcd0e..9827f9c5c 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -47,7 +47,7 @@
#include "slang-check-impl.h"
-#include "../../slang-tag-version.h"
+#include "slang-tag-version.h"
#include <sys/stat.h>
@@ -124,7 +124,7 @@ namespace Slang {
const char* getBuildTagString()
{
- if (UnownedStringSlice(SLANG_TAG_VERSION) == "unknown")
+ if (UnownedStringSlice(SLANG_TAG_VERSION) == "0.0.0-unknown")
{
// If the tag is unknown, then we will try to get the timestamp of the shared library
// and use that as the version string, so that we can at least return something