Skip to content

Commit 590da88

Browse files
authored
Merge pull request #205 from tusooa/tusooa/explicit-exceptions
Allow the user to always enable or disable exceptions
2 parents 6aa0de7 + ac9850f commit 590da88

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ option(lager_BUILD_DEBUGGER_EXAMPLES "Build examples that showcase the web based
2828
option(lager_BUILD_DOCS "Build docs" ON)
2929
option(lager_EMBED_RESOURCES_PATH "Embed installation paths for easier, non-portable resource location" ON)
3030
option(lager_DISABLE_STORE_DEPENDENCY_CHECKS "Disable compile-time checks for store dependencies" OFF)
31+
option(lager_ENABLE_EXCEPTIONS "Always enable exceptions regardless of detected compiler support" OFF)
32+
option(lager_DISABLE_EXCEPTIONS "Always disable exceptions regardless of detected compiler support" OFF)
33+
34+
if (lager_ENABLE_EXCEPTIONS AND lager_DISABLE_EXCEPTIONS)
35+
message(FATAL_ERROR "Cannot both enable and disable exceptions")
36+
endif()
3137

3238
if (NOT lager_EMBED_RESOURCES_PATH AND lager_BUILD_EXAMPLES)
3339
message(FATAL_ERROR "Examples require embedded resources path")
@@ -67,6 +73,16 @@ if(lager_DISABLE_STORE_DEPENDENCY_CHECKS)
6773
target_compile_definitions(lager INTERFACE LAGER_DISABLE_STORE_DEPENDENCY_CHECKS)
6874
endif()
6975

76+
if(lager_ENABLE_EXCEPTIONS)
77+
message(STATUS "Explicitly enabling exceptions")
78+
target_compile_definitions(lager INTERFACE LAGER_USE_EXCEPTIONS)
79+
endif()
80+
81+
if(lager_DISABLE_EXCEPTIONS)
82+
message(STATUS "Explicitly disabling exceptions")
83+
target_compile_definitions(lager INTERFACE LAGER_NO_EXCEPTIONS)
84+
endif()
85+
7086
install(TARGETS lager EXPORT LagerConfig)
7187

7288
# requirements for tests and examples

lager/config.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
#define LAGER_DISABLE_STORE_DEPENDENCY_CHECKS
2121
#endif
2222

23+
#if !defined(LAGER_USE_EXCEPTIONS) && !defined(LAGER_NO_EXCEPTIONS)
2324
#ifdef __has_feature
2425
#if !__has_feature(cxx_exceptions)
2526
#define LAGER_NO_EXCEPTIONS
2627
#endif
2728
#endif
29+
#endif
2830

2931
#ifdef LAGER_NO_EXCEPTIONS
3032
#define LAGER_TRY if (true)

0 commit comments

Comments
 (0)