Skip to content

Commit 0b91e2d

Browse files
committed
Add BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS cmake option
1 parent dd1f1ee commit 0b91e2d

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ option(
2727
${PROJECT_IS_TOP_LEVEL}
2828
)
2929

30+
option(
31+
BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS
32+
"Disable exceptions by replacing throw calls with abort. Default: OFF. Values: { ON, OFF }."
33+
OFF
34+
)
35+
36+
configure_file(
37+
"${PROJECT_SOURCE_DIR}/include/beman/inplace_vector/config.hpp.in"
38+
"${PROJECT_BINARY_DIR}/include/beman/inplace_vector/config.hpp"
39+
@ONLY
40+
)
41+
3042
include(FetchContent)
3143
include(GNUInstallDirs)
3244

@@ -38,6 +50,7 @@ target_include_directories(
3850
beman.inplace_vector
3951
INTERFACE
4052
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
53+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
4154
$<INSTALL_INTERFACE:include>
4255
)
4356

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef BEMAN_INPLACE_VECTOR_CONFIG_HPP
2+
#define BEMAN_INPLACE_VECTOR_CONFIG_HPP
3+
4+
#cmakedefine01 BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS()
5+
6+
#endif

include/beman/inplace_vector/inplace_vector.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#ifndef BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP
44
#define BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP
5+
#include <beman/inplace_vector/config.hpp>
56

67
#include <algorithm> // for rotate...
78
#include <array>
@@ -22,7 +23,8 @@
2223
#define IV_EXPECT(EXPR)
2324

2425
#ifndef BEMAN_IV_THROW_OR_ABORT
25-
#if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
26+
#if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L || \
27+
BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS()
2628
#include <cstdlib> // for abort
2729
#define BEMAN_IV_THROW_OR_ABORT(x) abort()
2830
#else

0 commit comments

Comments
 (0)