Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the user to always enable or disable exceptions #205

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading