Skip to content

Commit 013cf6f

Browse files
committed
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.
1 parent 93aa627 commit 013cf6f

4 files changed

Lines changed: 18 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ if(
4949
endif()
5050

5151
configure_file(
52-
"${PROJECT_SOURCE_DIR}/include/beman/iterator_interface/config.hpp.in"
53-
"${PROJECT_BINARY_DIR}/include/beman/iterator_interface/config.hpp"
52+
"${PROJECT_SOURCE_DIR}/include/beman/iterator_interface/config_generated.hpp.in"
53+
"${PROJECT_BINARY_DIR}/include/beman/iterator_interface/config_generated.hpp"
5454
@ONLY
5555
)
5656

@@ -67,7 +67,7 @@ target_sources(
6767
FILE_SET HEADERS
6868
BASE_DIRS
6969
"${CMAKE_CURRENT_SOURCE_DIR}/include"
70-
"${PROJECT_BINARY_DIR}/include"
70+
"${CMAKE_CURRENT_BINARY_DIR}/include"
7171
)
7272

7373
set_target_properties(

include/beman/iterator_interface/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ target_sources(
55
PUBLIC
66
FILE_SET HEADERS
77
FILES
8+
config.hpp
89
iterator_interface.hpp
910
iterator_interface_access.hpp
1011
detail/stl_interfaces/config.hpp
1112
detail/stl_interfaces/fwd.hpp
1213
detail/stl_interfaces/iterator_interface.hpp
13-
"${PROJECT_BINARY_DIR}/include/beman/iterator_interface/config.hpp"
14+
"${PROJECT_BINARY_DIR}/include/beman/iterator_interface/config_generated.hpp"
1415
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef BEMAN_ITERATOR_INTERFACE_CONFIG_HPP
2+
#define BEMAN_ITERATOR_INTERFACE_CONFIG_HPP
3+
4+
#if !defined(__has_include) || \
5+
__has_include(<beman/iterator_interface/config_generated.hpp>)
6+
#include <beman/iterator_interface/config_generated.hpp>
7+
#else
8+
#define BEMAN_ITERATOR_INTERFACE_USE_DEDUCING_THIS() 1
9+
#endif
10+
11+
#endif

include/beman/iterator_interface/config.hpp.in renamed to include/beman/iterator_interface/config_generated.hpp.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// include/beman/iterator_interface/config.hpp.in -*-C++-*-
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4-
#ifndef BEMAN_ITERATOR_INTERFACE_CONFIG_HPP
5-
#define BEMAN_ITERATOR_INTERFACE_CONFIG_HPP
4+
#ifndef BEMAN_ITERATOR_INTERFACE_CONFIG_GENERATED_HPP
5+
#define BEMAN_ITERATOR_INTERFACE_CONFIG_GENERATED_HPP
66

77
#cmakedefine01 BEMAN_ITERATOR_INTERFACE_USE_DEDUCING_THIS()
88

0 commit comments

Comments
 (0)