From 4645393b448c457dde280442e8e0f3a97a09d98d Mon Sep 17 00:00:00 2001 From: Dev-Sams1012 Date: Tue, 28 Jul 2026 22:01:30 -0300 Subject: [PATCH] build: configure BuildInfo generation via CMake - Add BuildInfo.hpp.in template for compile-time version tracking - Update core CMakeLists.txt to configure file and include generated path - Suppress Clangd diagnostics for .in template files --- .clangd | 5 +++++ core/BuildInfo.hpp.in | 16 ++++++++++++++++ core/CMakeLists.txt | 10 ++++++++++ 3 files changed, 31 insertions(+) create mode 100644 core/BuildInfo.hpp.in diff --git a/.clangd b/.clangd index ec0b890..ee4a3f8 100644 --- a/.clangd +++ b/.clangd @@ -1,2 +1,7 @@ CompileFlags: CompilationDatabase: build + +If: + PathMatch: .*\.in$ +Diagnostics: + Suppress: "*" \ No newline at end of file diff --git a/core/BuildInfo.hpp.in b/core/BuildInfo.hpp.in new file mode 100644 index 0000000..8c7634c --- /dev/null +++ b/core/BuildInfo.hpp.in @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace retroforge::core { + +class BuildInfo { + public: + static constexpr int major = @PROJECT_VERSION_MAJOR@; + static constexpr int minor = @PROJECT_VERSION_MINOR@; + static constexpr int patch = @PROJECT_VERSION_PATCH@; + + static constexpr std::string_view version_string() { return "@PROJECT_VERSION@"; } +}; + +} // namespace retroforge::core \ No newline at end of file diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 2a22c06..2e19eea 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -15,4 +15,14 @@ target_include_directories(retroforge_core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/BuildInfo.hpp.in + ${CMAKE_BINARY_DIR}/generated/BuildInfo.hpp + @ONLY +) + +target_include_directories(retroforge_core PUBLIC + ${CMAKE_BINARY_DIR}/generated +) + target_compile_features(retroforge_core PUBLIC cxx_std_20) \ No newline at end of file