Skip to content

Commit

Permalink
Allow the user to always enable or disable exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tusooa committed Jul 6, 2024
1 parent 503ea6a commit ac9850f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ option(lager_BUILD_DEBUGGER_EXAMPLES "Build examples that showcase the web based
option(lager_BUILD_DOCS "Build docs" ON)
option(lager_EMBED_RESOURCES_PATH "Embed installation paths for easier, non-portable resource location" ON)
option(lager_DISABLE_STORE_DEPENDENCY_CHECKS "Disable compile-time checks for store dependencies" OFF)
option(lager_ENABLE_EXCEPTIONS "Always enable exceptions regardless of detected compiler support" OFF)
option(lager_DISABLE_EXCEPTIONS "Always disable exceptions regardless of detected compiler support" OFF)

if (lager_ENABLE_EXCEPTIONS AND lager_DISABLE_EXCEPTIONS)
message(FATAL_ERROR "Cannot both enable and disable exceptions")
endif()

if (NOT lager_EMBED_RESOURCES_PATH AND lager_BUILD_EXAMPLES)
message(FATAL_ERROR "Examples require embedded resources path")
Expand Down Expand Up @@ -67,6 +73,16 @@ if(lager_DISABLE_STORE_DEPENDENCY_CHECKS)
target_compile_definitions(lager INTERFACE LAGER_DISABLE_STORE_DEPENDENCY_CHECKS)
endif()

if(lager_ENABLE_EXCEPTIONS)
message(STATUS "Explicitly enabling exceptions")
target_compile_definitions(lager INTERFACE LAGER_USE_EXCEPTIONS)
endif()

if(lager_DISABLE_EXCEPTIONS)
message(STATUS "Explicitly disabling exceptions")
target_compile_definitions(lager INTERFACE LAGER_NO_EXCEPTIONS)
endif()

install(TARGETS lager EXPORT LagerConfig)

# requirements for tests and examples
Expand Down
2 changes: 2 additions & 0 deletions lager/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
#define LAGER_DISABLE_STORE_DEPENDENCY_CHECKS
#endif

#if !defined(LAGER_USE_EXCEPTIONS) && !defined(LAGER_NO_EXCEPTIONS)
#ifdef __has_feature
#if !__has_feature(cxx_exceptions)
#define LAGER_NO_EXCEPTIONS
#endif
#endif
#endif

#ifdef LAGER_NO_EXCEPTIONS
#define LAGER_TRY if (true)
Expand Down

0 comments on commit ac9850f

Please sign in to comment.