Add version macros header

This commit is contained in:
Jeremy Rifkin 2024-12-21 15:41:13 -06:00
parent 27bbe75bd3
commit 43b0ed1b21
No known key found for this signature in database
GPG Key ID: 19AA8270105E8EB4
5 changed files with 21 additions and 1 deletions

View File

@ -161,6 +161,11 @@ target_compile_options(
${warning_options}
)
set(CPPTRACE_VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR})
set(CPPTRACE_VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR})
set(CPPTRACE_VERSION_PATCH ${CMAKE_PROJECT_VERSION_PATCH})
configure_file("${PROJECT_SOURCE_DIR}/cmake/in/version-hpp.in" "${PROJECT_BINARY_DIR}/include/cpptrace/version.hpp")
# ---- Generate Build Info Headers ----
if(build_type STREQUAL "STATIC")

View File

@ -787,8 +787,10 @@ Cpptrace provides a handful of headers to make inclusion more minimal.
| `cpptrace/from_current.hpp` | [Traces From All Exceptions](#traces-from-all-exceptions) |
| `cpptrace/io.hpp` | `operator<<` overloads for `std::ostream` and `std::formatter`s |
| `cpptrace/utils.hpp` | Utility functions, configuration functions, and terminate utilities ([Utilities](#utilities), [Configuration](#configuration), and [Terminate Handling](#terminate-handling)) |
| `cpptrace/version.hpp` | Library version macros |
The main cpptrace header is `cpptrace/cpptrace.hpp` which includes everything other than `from_current.hpp`.
The main cpptrace header is `cpptrace/cpptrace.hpp` which includes everything other than `from_current.hpp` and
`version.hpp`.
# Supported Debug Formats

View File

@ -5,6 +5,7 @@ include(CMakePackageConfigHelpers)
install(
DIRECTORY
"${PROJECT_SOURCE_DIR}/include/" # our header files
"${PROJECT_BINARY_DIR}/include/" # generated header files
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT ${package_name}-development
# PATTERN "**/third_party" EXCLUDE # skip third party directory

11
cmake/in/version-hpp.in Normal file
View File

@ -0,0 +1,11 @@
#ifndef CPPTRACE_VERSION_HPP
#define CPPTRACE_VERSION_HPP
#define CPPTRACE_VERSION_MAJOR @CPPTRACE_VERSION_MAJOR@
#define CPPTRACE_VERSION_MINOR @CPPTRACE_VERSION_MINOR@
#define CPPTRACE_VERSION_PATCH @CPPTRACE_VERSION_PATCH@
#define CPPTRACE_TO_VERSION(MAJOR, MINOR, PATCH) ((MAJOR) * 10000 + (MINOR) * 100 + (PATCH))
#define CPPTRACE_VERSION CPPTRACE_TO_VERSION(CPPTRACE_VERSION_MAJOR, CPPTRACE_VERSION_MINOR, CPPTRACE_VERSION_PATCH)
#endif

View File

@ -1,4 +1,5 @@
#include <cpptrace/cpptrace.hpp>
#include <cpptrace/version.hpp>
#include <algorithm>
#include <cctype>