From 5920d777be95de6c5d6f6586bf2d34977ffd9db7 Mon Sep 17 00:00:00 2001 From: Edward Nolan Date: Sun, 26 Apr 2026 22:39:13 -0400 Subject: [PATCH] Update flag forking approach to use split config.hpp and config_generated.hpp files This commit reflects the new flag forking approach discussed in the most recent Beman weekly sync: - For any configuration option where a compiler flag could cause differences in behavior that lead to ODR issues when linking two artifacts generated with different flags, maintainers generate a compiler definition like BEMAN_EXEMPLAR_FOOBAR into a config_generated.hpp header from a config_generated.hpp.in template. - Separately, a config.hpp file contains defaults for each definition. These defaults are only enabled if __has_include shows that the config_generated.hpp file is not present. --- CMakeLists.txt | 4 ++-- include/beman/inplace_vector/CMakeLists.txt | 5 ++++- include/beman/inplace_vector/config.hpp | 11 +++++++++++ include/beman/inplace_vector/config.hpp.in | 6 ------ include/beman/inplace_vector/config_generated.hpp.in | 6 ++++++ include/beman/inplace_vector/inplace_vector.hpp | 6 ------ 6 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 include/beman/inplace_vector/config.hpp delete mode 100644 include/beman/inplace_vector/config.hpp.in create mode 100644 include/beman/inplace_vector/config_generated.hpp.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 8858de2..7594fa2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,8 +31,8 @@ option( ) configure_file( - "${PROJECT_SOURCE_DIR}/include/beman/inplace_vector/config.hpp.in" - "${PROJECT_BINARY_DIR}/include/beman/inplace_vector/config.hpp" + "${PROJECT_SOURCE_DIR}/include/beman/inplace_vector/config_generated.hpp.in" + "${PROJECT_BINARY_DIR}/include/beman/inplace_vector/config_generated.hpp" @ONLY ) diff --git a/include/beman/inplace_vector/CMakeLists.txt b/include/beman/inplace_vector/CMakeLists.txt index 9a20b6a..10cd0fb 100644 --- a/include/beman/inplace_vector/CMakeLists.txt +++ b/include/beman/inplace_vector/CMakeLists.txt @@ -4,5 +4,8 @@ target_sources( beman.inplace_vector PUBLIC FILE_SET HEADERS - FILES inplace_vector.hpp "${CMAKE_CURRENT_BINARY_DIR}/config.hpp" + FILES + inplace_vector.hpp + config.hpp + "${CMAKE_CURRENT_BINARY_DIR}/config_generated.hpp" ) diff --git a/include/beman/inplace_vector/config.hpp b/include/beman/inplace_vector/config.hpp new file mode 100644 index 0000000..e696fa3 --- /dev/null +++ b/include/beman/inplace_vector/config.hpp @@ -0,0 +1,11 @@ +#ifndef BEMAN_INPLACE_VECTOR_CONFIG_HPP +#define BEMAN_INPLACE_VECTOR_CONFIG_HPP + +#if !defined(__has_include) || \ + __has_include() +#include +#else +#define BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS() 0 +#endif + +#endif diff --git a/include/beman/inplace_vector/config.hpp.in b/include/beman/inplace_vector/config.hpp.in deleted file mode 100644 index b551164..0000000 --- a/include/beman/inplace_vector/config.hpp.in +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef BEMAN_INPLACE_VECTOR_CONFIG_HPP -#define BEMAN_INPLACE_VECTOR_CONFIG_HPP - -#cmakedefine01 BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS() - -#endif diff --git a/include/beman/inplace_vector/config_generated.hpp.in b/include/beman/inplace_vector/config_generated.hpp.in new file mode 100644 index 0000000..b2c8e25 --- /dev/null +++ b/include/beman/inplace_vector/config_generated.hpp.in @@ -0,0 +1,6 @@ +#ifndef BEMAN_INPLACE_VECTOR_CONFIG_GENERATED_HPP +#define BEMAN_INPLACE_VECTOR_CONFIG_GENERATED_HPP + +#cmakedefine01 BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS() + +#endif diff --git a/include/beman/inplace_vector/inplace_vector.hpp b/include/beman/inplace_vector/inplace_vector.hpp index 4395f45..dfd004f 100644 --- a/include/beman/inplace_vector/inplace_vector.hpp +++ b/include/beman/inplace_vector/inplace_vector.hpp @@ -3,9 +3,7 @@ #ifndef BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP #define BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP -#if !defined(__has_include) || __has_include() #include -#endif #include // for rotate... #include @@ -24,10 +22,6 @@ #ifndef BEMAN_IV_THROW_OR_ABORT -#ifndef BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS -#define BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS() 0 -#endif - #if BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS() #include // for abort #define BEMAN_IV_THROW_OR_ABORT(x) abort()