File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,10 +110,10 @@ jobs:
110110 VERSION="${{ needs.validate-version.outputs.version }}"
111111 ARCHIVE="ds_mysql-v${VERSION}.tar.gz"
112112
113- # Merge source headers with the generated version.hpp
113+ # Merge source headers with generated version override header.
114114 mkdir -p _dist/ds_mysql
115115 cp -r lib/include/ds_mysql/. _dist/ds_mysql/
116- cp _ver_build/lib/include/ds_mysql/version .hpp _dist/ds_mysql/version .hpp
116+ cp _ver_build/lib/include/ds_mysql/version_generated .hpp _dist/ds_mysql/version_generated .hpp
117117 rm -f _dist/ds_mysql/version.hpp.in
118118
119119 tar -czf "$ARCHIVE" -C _dist ds_mysql
Original file line number Diff line number Diff line change @@ -152,8 +152,9 @@ target_link_libraries(my_target PRIVATE ds_mysql::ds_mysql)
152152
153153If you are not using CMake, you can consume headers directly from either the
154154release archive or a git checkout: ` ds_mysql/version.hpp ` is checked in as a
155- fallback. In CMake builds, a generated ` version.hpp ` (from ` version.hpp.in ` ) is
156- preferred so ` project(VERSION ...) ` remains the authoritative source.
155+ stable wrapper/fallback. In CMake builds, a generated
156+ ` ds_mysql/version_generated.hpp ` (from ` version.hpp.in ` ) is used so
157+ ` project(VERSION ...) ` remains authoritative without rewriting tracked headers.
157158
158159## Key API
159160
Original file line number Diff line number Diff line change 55# CMakeLists.txt project(VERSION ...) remains the single source of truth.
66configure_file (
77 include /ds_mysql/version.hpp.in
8- include /ds_mysql/version .hpp
8+ include /ds_mysql/version_generated .hpp
99 @ONLY
1010)
1111
@@ -48,7 +48,7 @@ if(DSMYSQL_ENABLE_INSTALL AND NOT CMAKE_SKIP_INSTALL_RULES)
4848 )
4949
5050 install (
51- FILES ${CMAKE_CURRENT_BINARY_DIR } /include/ds_mysql/version .hpp
51+ FILES ${CMAKE_CURRENT_BINARY_DIR } /include/ds_mysql/version_generated .hpp
5252 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /ds_mysql
5353 )
5454
Original file line number Diff line number Diff line change 33#include < cstdint>
44#include < string_view>
55
6+ #if __has_include("ds_mysql/version_generated.hpp")
7+
8+ #include " ds_mysql/version_generated.hpp"
9+
10+ #else
11+
612namespace ds_mysql {
713
814// / Compile-time version information for DSMySQL.
915// /
10- // / This checked-in header is a fallback for non-CMake consumption.
11- // / In CMake builds, `version.hpp.in` is configured into the build tree and
12- // / should be preferred so `project(VERSION ...)` stays authoritative.
16+ // / This checked-in fallback is used only when no build-system generated
17+ // / `version_generated.hpp` is present (e.g. raw-header, non-CMake usage).
1318struct version {
14- static constexpr std::uint32_t major = 1 ;
19+ static constexpr std::uint32_t major = 0 ;
1520 static constexpr std::uint32_t minor = 0 ;
1621 static constexpr std::uint32_t patch = 0 ;
1722
1823 // / Packed integer: major * 10000 + minor * 100 + patch.
1924 static constexpr std::uint32_t value = major * 10'000u + minor * 100u + patch;
2025
21- // / Canonical "major.minor.patch" string.
22- static constexpr std::string_view string = " 1 .0.0" ;
26+ // / Canonical fallback string for non-generated builds .
27+ static constexpr std::string_view string = " 0 .0.0+unknown " ;
2328};
2429
25- } // namespace ds_mysql
30+ } // namespace ds_mysql
31+
32+ #endif
Original file line number Diff line number Diff line change @@ -7,8 +7,9 @@ namespace ds_mysql {
77
88/// Compile-time version information for DSMySQL.
99///
10- /// The values are generated from the CMakeLists.txt project() declaration and
11- /// therefore always match the authoritative version of the library.
10+ /// This header is generated by CMake as `version_generated.hpp` from
11+ /// CMakeLists.txt project(VERSION ...), and included by `version.hpp`.
12+ /// Values therefore always match the authoritative project version.
1213///
1314/// Usage:
1415/// static_assert(ds_mysql::version::major >= 1);
You can’t perform that action at this time.
0 commit comments