Skip to content

Commit c329f87

Browse files
author
Pierre-Luc Gagné
committed
build: add non-cmake version header fallback
1 parent 05415fc commit c329f87

3 files changed

Lines changed: 30 additions & 5 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ find_package(ds_mysql CONFIG REQUIRED)
150150
target_link_libraries(my_target PRIVATE ds_mysql::ds_mysql)
151151
```
152152

153-
If you are not using CMake, prefer the release archive (`ds_mysql-v<version>.tar.gz`):
154-
it already contains generated `ds_mysql/version.hpp`. Cloning the raw repository
155-
and copying headers directly will not provide `version.hpp` unless you run CMake
156-
configure first.
153+
If you are not using CMake, you can consume headers directly from either the
154+
release 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.
157157

158158
## Key API
159159

lib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ option(DSMYSQL_ENABLE_INSTALL "Enable install targets" ${PROJECT_IS_TOP_LEVEL})
1616

1717
target_include_directories(ds_mysql
1818
INTERFACE
19-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
2019
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
20+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
2121
$<INSTALL_INTERFACE:include>
2222
"$<BUILD_INTERFACE:${MYSQL_INCLUDE_DIRS}>"
2323
)

lib/include/ds_mysql/version.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
#include <string_view>
5+
6+
namespace ds_mysql {
7+
8+
/// Compile-time version information for DSMySQL.
9+
///
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.
13+
struct version {
14+
static constexpr std::uint32_t major = 1;
15+
static constexpr std::uint32_t minor = 0;
16+
static constexpr std::uint32_t patch = 0;
17+
18+
/// Packed integer: major * 10000 + minor * 100 + patch.
19+
static constexpr std::uint32_t value = major * 10'000u + minor * 100u + patch;
20+
21+
/// Canonical "major.minor.patch" string.
22+
static constexpr std::string_view string = "1.0.0";
23+
};
24+
25+
} // namespace ds_mysql

0 commit comments

Comments
 (0)