From d24edcf5b882ebd60722984e168680a49933642f Mon Sep 17 00:00:00 2001 From: mcb5637 <28106698+mcb5637@users.noreply.github.com> Date: Mon, 22 Jul 2024 15:31:57 +0200 Subject: [PATCH 1/3] introduce with_test_deps option (#50) --- CMakeLists.txt | 6 ++++++ conanfile.py | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b162291..51d6f95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,12 @@ else() MESSAGE(WARNING "Could not verify that your compiler (${CMAKE_CXX_COMPILER}) supports all needed features.") endif() +if (PROJECT_IS_TOP_LEVEL) + if (BUILD_TESTING) + set(CONAN_INSTALL_ARGS "${CONAN_INSTALL_ARGS};-o=&:with_test_deps=True") + endif () +endif () + add_library(${PROJECT_NAME} INTERFACE) add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) diff --git a/conanfile.py b/conanfile.py index e94671e..e5c0ccf 100644 --- a/conanfile.py +++ b/conanfile.py @@ -17,6 +17,12 @@ class DiceHashConan(ConanFile): exports = "LICENSE" exports_sources = "include/*", "CMakeLists.txt", "cmake/*", "LICENSE" no_copy_source = True + options = { + "with_test_deps": [True, False], + } + default_options = { + "with_test_deps": False, + } # No settings/options are necessary, this is header only @@ -34,7 +40,8 @@ def set_version(self): self.description = re.search(r"project\([^)]*DESCRIPTION\s+\"([^\"]+)\"[^)]*\)", cmake_file).group(1) def requirements(self): - self.test_requires("catch2/2.13.9") + if self.options.with_test_deps: + self.test_requires("catch2/2.13.9") def layout(self): cmake_layout(self) From 833194473b8d704b7eff9af7d4b23cf9dc16e0e6 Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:30:35 +0200 Subject: [PATCH 2/3] Feature: version header (#49) --- .github/workflows/detect-pobr-diff.yml | 24 ++++++++++++++++++++++++ .gitignore | 1 + CMakeLists.txt | 3 +++ cmake/version.hpp.in | 13 +++++++++++++ include/dice/hash.hpp | 3 ++- 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/detect-pobr-diff.yml create mode 100644 cmake/version.hpp.in diff --git a/.github/workflows/detect-pobr-diff.yml b/.github/workflows/detect-pobr-diff.yml new file mode 100644 index 0000000..179adeb --- /dev/null +++ b/.github/workflows/detect-pobr-diff.yml @@ -0,0 +1,24 @@ +name: Detect POBR diff + +on: [ pull_request ] + +concurrency: + group: detect-pobr-diff-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + detect-pobr-diff: + uses: dice-group/cpp-conan-release-reusable-workflow/.github/workflows/abi-diff.yml@main + with: + os: ubuntu-22.04 + compiler: clang-16 + cmake-version: 3.24.0 + conan-version: 2.3.1 + base-branch: ${{ github.base_ref }} + search-path: > + include/dice/hash/internal + abi-version-header: include/dice/hash/version.hpp + abi-version-const: dice::hash::pobr_version + secrets: + CONAN_USER: "" + CONAN_PW: "" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9d61c06..6e817e2 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,4 @@ modules.xml test_package/build conan_provider.cmake +include/dice/hash/version.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 51d6f95..c4e54a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ project( VERSION 0.4.5 DESCRIPTION "dice-hash provides a framework to generate stable hashes. It provides state-of-the-art hash functions, supports STL containers out of the box and helps you to defines stable hashes for your own structs and classes." HOMEPAGE_URL "https://dice-group.github.io/dice-hash/") +set(POBR_VERSION 1) # Persisted Object Binary Representation Version # set gcc-10 and clang-10 as minimum versions see # https://stackoverflow.com/questions/14933172/how-can-i-add-a-minimum-compiler-version-requisite#14934542 @@ -24,6 +25,8 @@ else() MESSAGE(WARNING "Could not verify that your compiler (${CMAKE_CXX_COMPILER}) supports all needed features.") endif() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/dice/hash/version.hpp) + if (PROJECT_IS_TOP_LEVEL) if (BUILD_TESTING) set(CONAN_INSTALL_ARGS "${CONAN_INSTALL_ARGS};-o=&:with_test_deps=True") diff --git a/cmake/version.hpp.in b/cmake/version.hpp.in new file mode 100644 index 0000000..bdb1050 --- /dev/null +++ b/cmake/version.hpp.in @@ -0,0 +1,13 @@ +#ifndef DICE_HASH_VERSION_HPP +#define DICE_HASH_VERSION_HPP + +#include + +namespace dice::hash { + inline constexpr char name[] = "@PROJECT_NAME@"; + inline constexpr char version[] = "@PROJECT_VERSION@"; + inline constexpr std::array version_tuple = {@PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@}; + inline constexpr int pobr_version = @POBR_VERSION@; ///< persisted object binary representation version +} // namespace dice::hash + +#endif // DICE_HASH_VERSION_HPP diff --git a/include/dice/hash.hpp b/include/dice/hash.hpp index 0537b2d..77fe008 100644 --- a/include/dice/hash.hpp +++ b/include/dice/hash.hpp @@ -1,4 +1,5 @@ #ifndef DICE_HASH_HASH_HPP #define DICE_HASH_HASH_HPP -#include "dice/hash/DiceHash.hpp" +#include +#include #endif//DICE_HASH_HASH_HPP From 09618be98e5eb220f419cfd166e0feb2bd3dc3ad Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+Clueliss@users.noreply.github.com> Date: Mon, 29 Jul 2024 15:27:12 +0200 Subject: [PATCH 3/3] version bump --- CMakeLists.txt | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4e54a1..ec25119 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.24) project( dice-hash - VERSION 0.4.5 + VERSION 0.4.6 DESCRIPTION "dice-hash provides a framework to generate stable hashes. It provides state-of-the-art hash functions, supports STL containers out of the box and helps you to defines stable hashes for your own structs and classes." HOMEPAGE_URL "https://dice-group.github.io/dice-hash/") set(POBR_VERSION 1) # Persisted Object Binary Representation Version diff --git a/README.md b/README.md index 58fec9d..357afd6 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ To use it with [conan](https://conan.io/) you need to add the repository: conan remote add dice-group https://conan.dice-research.org/artifactory/api/conan/tentris ``` -To use it add `dice-hash/0.4.5` to the `[requires]` section of your conan file. +To use it add `dice-hash/0.4.6` to the `[requires]` section of your conan file. You can now add it to your target with: ```cmake