From 2fab642f2c9606eb7b266dec8d79d1a09e461048 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Fri, 11 Aug 2023 13:30:26 -0500 Subject: [PATCH 01/11] feat: install EDM4EICVersion.h with version --- CMakeLists.txt | 8 ++++++++ EDM4EICVersion.h | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 EDM4EICVersion.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e75298..eeb602e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,14 @@ else() message(STATUS "Doxygen not found; no documentation will be built.") endif() +# ------------------------- +# add version files + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/EDM4EICVersion.h + ${CMAKE_CURRENT_BINARY_DIR}/EDM4EICVersion.h ) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EDM4EICVersion.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/edm4eic ) + # ------------------------- # install library config include(CMakePackageConfigHelpers) diff --git a/EDM4EICVersion.h b/EDM4EICVersion.h new file mode 100644 index 0000000..62d7cab --- /dev/null +++ b/EDM4EICVersion.h @@ -0,0 +1,4 @@ +#ifndef EDM4EICVersion_h +#define EDM4EICVersion_h +#define EDM4EIC_VERSION @EDM4EIC_VERSION@ +#endif From 59c69929b6e3c491bfa3173dbf1e58a0c43d3407 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Fri, 11 Aug 2023 13:32:11 -0500 Subject: [PATCH 02/11] fix: set version to most recent release --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eeb602e..7db8593 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,15 @@ # Copyright (C) 2022 Whitney Armstrong, Sylvester Joosten, Wouter Deconinck cmake_minimum_required(VERSION 3.12) + project(EDM4EIC - VERSION 1.1.0 LANGUAGES CXX) +SET( ${PROJECT_NAME}_VERSION_MAJOR 2 ) +SET( ${PROJECT_NAME}_VERSION_MINOR 0 ) +SET( ${PROJECT_NAME}_VERSION_PATCH 0 ) +SET( ${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}" ) + # C++ standard set(CMAKE_CXX_STANDARD 17 CACHE STRING "Set the C++ standard to be used") if(NOT CMAKE_CXX_STANDARD MATCHES "17|20") From 0ec9fce7d9fa932a0214736879d2a802511def04 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Fri, 11 Aug 2023 13:40:55 -0500 Subject: [PATCH 03/11] fix: use new version in write_basic_package_version_file --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7db8593..04ca714 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,7 +132,7 @@ configure_package_config_file( write_basic_package_version_file( ${PROJECT_NAME}ConfigVersion.cmake - VERSION ${VERSION} + VERSION ${${PROJECT_NAME}_VERSION} COMPATIBILITY SameMajorVersion ) From 02e2802594e0222403d1f0cf77a646f2d56a5d93 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Fri, 11 Aug 2023 13:49:19 -0500 Subject: [PATCH 04/11] Update CMakeLists.txt Co-authored-by: Dmitry Kalinkin --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04ca714..1e3d3e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ project(EDM4EIC LANGUAGES CXX) SET( ${PROJECT_NAME}_VERSION_MAJOR 2 ) -SET( ${PROJECT_NAME}_VERSION_MINOR 0 ) +SET( ${PROJECT_NAME}_VERSION_MINOR 1 ) SET( ${PROJECT_NAME}_VERSION_PATCH 0 ) SET( ${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}" ) From 6bef4b9f617d5ab036572572c3d3ada557ae7ff6 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sun, 13 Aug 2023 00:29:25 -0400 Subject: [PATCH 05/11] EDM4EICVersion.h -> EDM4eicVersion.h --- CMakeLists.txt | 6 +++--- EDM4EICVersion.h => EDM4eicVersion.h.in | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename EDM4EICVersion.h => EDM4eicVersion.h.in (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e3d3e6..28bc4d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,9 +105,9 @@ endif() # ------------------------- # add version files -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/EDM4EICVersion.h - ${CMAKE_CURRENT_BINARY_DIR}/EDM4EICVersion.h ) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EDM4EICVersion.h +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/EDM4eicVersion.h.in + ${CMAKE_CURRENT_BINARY_DIR}/EDM4eicVersion.h ) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EDM4eicVersion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/edm4eic ) # ------------------------- diff --git a/EDM4EICVersion.h b/EDM4eicVersion.h.in similarity index 100% rename from EDM4EICVersion.h rename to EDM4eicVersion.h.in From 01fa92930be7633884756914cfd8201ef2719795 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sun, 13 Aug 2023 00:32:45 -0400 Subject: [PATCH 06/11] generate a usable header file `2.1.0` is not a valid literal --- EDM4eicVersion.h.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/EDM4eicVersion.h.in b/EDM4eicVersion.h.in index 62d7cab..abf8753 100644 --- a/EDM4eicVersion.h.in +++ b/EDM4eicVersion.h.in @@ -1,4 +1,8 @@ #ifndef EDM4EICVersion_h #define EDM4EICVersion_h -#define EDM4EIC_VERSION @EDM4EIC_VERSION@ + +#define EDM4EIC_VERSION_MAJOR @EDM4EIC_VERSION_MAJOR@ +#define EDM4EIC_VERSION_MINOR @EDM4EIC_VERSION_MINOR@ +#define EDM4EIC_VERSION_PATCH @EDM4EIC_VERSION_PATCH@ + #endif From 00a42830309b58971d8bde41a7e6a34eabbd1651 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 14 Aug 2023 12:00:02 -0500 Subject: [PATCH 07/11] feat: might as well use EDM4hepVersion.h.in wholesale --- EDM4eicVersion.h.in | 84 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/EDM4eicVersion.h.in b/EDM4eicVersion.h.in index abf8753..2c1f3f9 100644 --- a/EDM4eicVersion.h.in +++ b/EDM4eicVersion.h.in @@ -1,8 +1,88 @@ -#ifndef EDM4EICVersion_h -#define EDM4EICVersion_h +#ifndef EDM4EIC_VERSION_H +#define EDM4EIC_VERSION_H +#include +#include +#include +#if __cplusplus >= 202002L +#include +#endif + +// Some preprocessor constants and macros for the use cases where they might be +// necessary + +/// Define a version to be used in EDM4EIC. +#define EDM4EIC_VERSION(major, minor, patch) ((UINT64_C(major) << 32) | (UINT64_C(minor) << 16) | (UINT64_C(patch))) +/// Get the major version from a preprocessor defined version +#define EDM4EIC_MAJOR_VERSION(v) (((v) & (-1UL >> 16)) >> 32) +/// Get the minor version from a preprocessor defined version +#define EDM4EIC_MINOR_VERSION(v) (((v) & (-1UL >> 32)) >> 16) +/// Get the patch version from a preprocessor defined version +#define EDM4EIC_PATCH_VERSION(v) ((v) & (-1UL >> 48)) + +// Some helper constants that are populated by the cmake configure step #define EDM4EIC_VERSION_MAJOR @EDM4EIC_VERSION_MAJOR@ #define EDM4EIC_VERSION_MINOR @EDM4EIC_VERSION_MINOR@ #define EDM4EIC_VERSION_PATCH @EDM4EIC_VERSION_PATCH@ +#define EDM4EIC_VERSION EDM4EIC_VERSION(EDM4EIC_VERSION_MAJOR, EDM4EIC_VERSION_MINOR, EDM4EIC_VERSION_PATCH) + +/// The encoded version with which EDM4EIC has been built +#define EDM4EIC_BUILD_VERSION EDM4EIC_VERSION(EDM4EIC_VERSION_MAJOR, EDM4EIC_VERSION_MINOR, EDM4EIC_VERSION_PATCH) + +namespace EDM4EIC::version { + + /** + * Version class consisting of 3 16 bit unsigned integers to hold the major, + * minor and patch version. Provides constexpr comparison operators that allow + * to use this class in constexpr-if clauses. + */ + struct Version { + uint16_t major{0}; + uint16_t minor{0}; + uint16_t patch{0}; + +#if __cplusplus >= 202002L + auto operator<=>(const Version&) const = default; +#else +// No spaceship yet in c++17 +#define DEFINE_COMP_OPERATOR(OP) \ + constexpr bool operator OP(const Version& o) const noexcept { \ + return std::tie(major, minor, patch) OP std::tie(o.major, o.minor, o.patch); \ + } + + DEFINE_COMP_OPERATOR(<) + DEFINE_COMP_OPERATOR(<=) + DEFINE_COMP_OPERATOR(>) + DEFINE_COMP_OPERATOR(>=) + DEFINE_COMP_OPERATOR(==) + DEFINE_COMP_OPERATOR(!=) + +#undef DEFINE_COMP_OPERATOR +#endif + + friend std::ostream& operator<<(std::ostream&, const Version& v); + }; + + inline std::ostream& operator<<(std::ostream& os, const Version& v) { + return os << v.major << "." << v.minor << "." << v.patch; + } + + /** + * The current build version + */ + static constexpr Version build_version{EDM4EIC_VERSION_MAJOR, EDM4EIC_VERSION_MINOR, EDM4EIC_VERSION_PATCH}; + + /** + * Decode a version from a 64 bit unsigned + */ + static constexpr Version decode_version(uint64_t version) noexcept { + return Version{ + (uint16_t) EDM4EIC_MAJOR_VERSION(version), + (uint16_t) EDM4EIC_MINOR_VERSION(version), + (uint16_t) EDM4EIC_PATCH_VERSION(version) + }; + } +} + #endif From 2fb8452f8c44e5fa32c8ef689b8c4d6e5e6d1990 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 14 Aug 2023 12:00:42 -0500 Subject: [PATCH 08/11] Update EDM4eicVersion.h.in --- EDM4eicVersion.h.in | 1 + 1 file changed, 1 insertion(+) diff --git a/EDM4eicVersion.h.in b/EDM4eicVersion.h.in index 2c1f3f9..9dcda2b 100644 --- a/EDM4eicVersion.h.in +++ b/EDM4eicVersion.h.in @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 #ifndef EDM4EIC_VERSION_H #define EDM4EIC_VERSION_H From d6d425eee77eb73735f9ae876751e6029d2ad73e Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 14 Aug 2023 12:09:51 -0500 Subject: [PATCH 09/11] fix: #define edm4hep_VERSION --- EDM4eicVersion.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EDM4eicVersion.h.in b/EDM4eicVersion.h.in index 9dcda2b..92aea3a 100644 --- a/EDM4eicVersion.h.in +++ b/EDM4eicVersion.h.in @@ -25,7 +25,7 @@ #define EDM4EIC_VERSION_MAJOR @EDM4EIC_VERSION_MAJOR@ #define EDM4EIC_VERSION_MINOR @EDM4EIC_VERSION_MINOR@ #define EDM4EIC_VERSION_PATCH @EDM4EIC_VERSION_PATCH@ -#define EDM4EIC_VERSION EDM4EIC_VERSION(EDM4EIC_VERSION_MAJOR, EDM4EIC_VERSION_MINOR, EDM4EIC_VERSION_PATCH) +#define edm4hep_VERSION EDM4EIC_VERSION(EDM4EIC_VERSION_MAJOR, EDM4EIC_VERSION_MINOR, EDM4EIC_VERSION_PATCH) /// The encoded version with which EDM4EIC has been built #define EDM4EIC_BUILD_VERSION EDM4EIC_VERSION(EDM4EIC_VERSION_MAJOR, EDM4EIC_VERSION_MINOR, EDM4EIC_VERSION_PATCH) From 39d87330e11b4ed3c02644260c2de4dad8201c10 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 14 Aug 2023 12:11:11 -0500 Subject: [PATCH 10/11] fix: restore lowercase where EDM4hep has lowercase --- EDM4eicVersion.h.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EDM4eicVersion.h.in b/EDM4eicVersion.h.in index 92aea3a..3f55d85 100644 --- a/EDM4eicVersion.h.in +++ b/EDM4eicVersion.h.in @@ -12,7 +12,7 @@ // Some preprocessor constants and macros for the use cases where they might be // necessary -/// Define a version to be used in EDM4EIC. +/// Define a version to be used in edm4eic. #define EDM4EIC_VERSION(major, minor, patch) ((UINT64_C(major) << 32) | (UINT64_C(minor) << 16) | (UINT64_C(patch))) /// Get the major version from a preprocessor defined version #define EDM4EIC_MAJOR_VERSION(v) (((v) & (-1UL >> 16)) >> 32) @@ -30,7 +30,7 @@ /// The encoded version with which EDM4EIC has been built #define EDM4EIC_BUILD_VERSION EDM4EIC_VERSION(EDM4EIC_VERSION_MAJOR, EDM4EIC_VERSION_MINOR, EDM4EIC_VERSION_PATCH) -namespace EDM4EIC::version { +namespace edm4eic::version { /** * Version class consisting of 3 16 bit unsigned integers to hold the major, From 4dc5a1a4350432b0bb7804b5889273ea6667f611 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 15 Aug 2023 08:30:07 -0500 Subject: [PATCH 11/11] fix: EDM4eicVersion.h.in add ref link to edm4hep --- EDM4eicVersion.h.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/EDM4eicVersion.h.in b/EDM4eicVersion.h.in index 3f55d85..afab469 100644 --- a/EDM4eicVersion.h.in +++ b/EDM4eicVersion.h.in @@ -1,4 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 +// Ref: https://github.com/key4hep/EDM4hep/blob/e0762272e0f718df2811fc1bf4590af976bac70d/EDM4hepVersion.h.in + #ifndef EDM4EIC_VERSION_H #define EDM4EIC_VERSION_H