Skip to content

Commit

Permalink
Add version header
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Dec 21, 2024
1 parent 2a960b1 commit 1f6a059
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ target_compile_options(
${warning_options}
)

set(LIBASSERT_VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR})
set(LIBASSERT_VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR})
set(LIBASSERT_VERSION_PATCH ${CMAKE_PROJECT_VERSION_PATCH})
configure_file("${PROJECT_SOURCE_DIR}/cmake/in/version-hpp.in" "${PROJECT_BINARY_DIR}/include/libassert/version.hpp")

# ---- Generate Build Info Headers ----

# used in export header generated below
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- [Custom Failure Handlers](#custom-failure-handlers-1)
- [Breakpoints](#breakpoints)
- [Other Configurations](#other-configurations)
- [Library Version](#library-version)
- [Integration with Test Libraries](#integration-with-test-libraries)
- [Catch2](#catch2)
- [GoogleTest](#googletest)
Expand Down Expand Up @@ -788,6 +789,10 @@ gcc 10 and the library can surpress that warning for gcc 12. <!-- https://godbol
- `LIBASSERT_USE_EXTERNAL_CPPTRACE`: Use an externam cpptrace instead of aquiring the library with FetchContent
- `LIBASSERT_USE_EXTERNAL_MAGIC_ENUM`: Use an externam magic enum instead of aquiring the library with FetchContent

## Library Version

`<libassert/version.hpp>` provides version macros for the library.

# Integration with Test Libraries

> [!NOTE]
Expand Down
1 change: 1 addition & 0 deletions cmake/InstallRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
10 changes: 10 additions & 0 deletions cmake/in/version-hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef LIBASSERT_VERSION_HPP
#define LIBASSERT_VERSION_HPP

#define LIBASSERT_VERSION_MAJOR @LIBASSERT_VERSION_MAJOR@
#define LIBASSERT_VERSION_MINOR @LIBASSERT_VERSION_MINOR@
#define LIBASSERT_VERSION_PATCH @LIBASSERT_VERSION_PATCH@
#define LIBASSERT_TO_VERSION(MAJOR, MINOR, PATCH) ((MAJOR) * 10000 + (MINOR) * 100 + (PATCH))
#define LIBASSERT_VERSION LIBASSERT_TO_VERSION(LIBASSERT_VERSION_MAJOR, LIBASSERT_VERSION_MINOR, LIBASSERT_VERSION_PATCH)

#endif
1 change: 1 addition & 0 deletions tests/demo/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <vector>

#include <libassert/assert.hpp>
#include <libassert/version.hpp>

#define ESC "\033["
#define RED ESC "1;31m"
Expand Down

0 comments on commit 1f6a059

Please sign in to comment.