diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f8df7be..0d505376 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") @@ -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 diff --git a/lager/config.hpp b/lager/config.hpp index 9c2a88c1..9ad61974 100644 --- a/lager/config.hpp +++ b/lager/config.hpp @@ -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)