feat: use CMake to generate library version info.

- use CMake to produce YYCC version header when configuring.
This commit is contained in:
yyc12345 2024-11-03 18:52:02 +08:00
parent 831fa130bc
commit 0b7e58c8e8
4 changed files with 15 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
# -------------------- Output --------------------
out/
src/YYCC/YYCCVersion.hpp
CMakeSettings.json
# -------------------- VSCode --------------------

5
cmake/YYCCVersion.hpp.in Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#define YYCC_VER_MAJOR @PROJECT_VERSION_MAJOR@
#define YYCC_VER_MINOR @PROJECT_VERSION_MINOR@
#define YYCC_VER_PATCH @PROJECT_VERSION_PATCH@

View File

@ -1,3 +1,10 @@
# Configure version file
configure_file(
${CMAKE_CURRENT_LIST_DIR}/../cmake/YYCCVersion.hpp.in
${CMAKE_CURRENT_LIST_DIR}/YYCC/YYCCVersion.hpp
@ONLY
)
# Create static library
add_library(YYCCommonplace STATIC "")
# Setup static library sources
@ -42,6 +49,7 @@ FILES
YYCC/WinImportPrefix.hpp
YYCC/WinImportSuffix.hpp
# Internal
YYCC/YYCCVersion.hpp
YYCC/YYCCInternal.hpp
# Exposed
YYCCommonplace.hpp

View File

@ -2,9 +2,7 @@
#pragma region Library Version and Comparison Macros
#define YYCC_VER_MAJOR 1
#define YYCC_VER_MINOR 3
#define YYCC_VER_PATCH 0
#include "YYCCVersion.hpp"
/// @brief Return true if left version number is equal to right version number, otherwise false.
#define YYCC_VERCMP_E(av1, av2, av3, bv1, bv2, bv3) ((av1) == (bv1) && (av2) == (bv2) && (av3) == (bv3))