diff --git a/CInterface/Core.cpp b/CInterface/Core.cpp index f0e11b6..90c06cb 100644 --- a/CInterface/Core.cpp +++ b/CInterface/Core.cpp @@ -7,7 +7,7 @@ std::string ExceptionHandler::_ArbutilsLastException = ""; /// @brief Returns a null-terminated C string to the last exception found. export const char* Arbutils_C_GetLastException() { return ExceptionHandler::GetLastException(); } -#if !WINDOWS +#if !WINDOWS && SIGNAL_HANDLING static ArbUt::SignalHandling sh; /// @brief Sets a callback to a function to run when a signal occurs. export void Arbutils_C_SetSignalCallback(void (*callback)(const char*)) { sh.SetCallback(callback); } diff --git a/CMakeLists.txt b/CMakeLists.txt index 44a4409..86a3984 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ option(SHARED "Whether we should build a shared library, instead of a static one option(TESTS "Whether the test executable should be build as well." OFF) option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF) option(PRETTYTRACES "Whether full stacktraces should be included. Note that this adds a dependency to libdw." ON) +option(SIGNAL_HANDLING "whether to include signal handling." OFF) # Set whether we want a static or shared library. set(LIBTYPE STATIC) @@ -46,6 +47,10 @@ if (NOT WINDOWS AND PRETTYTRACES) set(LINKS ${LINKS} -ldw) ADD_DEFINITIONS(-DPRETTYTRACES=1) endif() +if (SIGNAL_HANDLING) + ADD_DEFINITIONS(-DSIGNAL_HANDLING=1) +endif() + # If we want to link the C and C++ library statically, link those as well. if (STATICC) set(LINKS ${LINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread) diff --git a/src/SignalHandling.cpp b/src/SignalHandling.cpp index 26518c8..5598a6b 100644 --- a/src/SignalHandling.cpp +++ b/src/SignalHandling.cpp @@ -1,6 +1,6 @@ #include "SignalHandling.hpp" -#if !WINDOWS +#if !WINDOWS && SIGNAL_HANDLING /// \cond SKIP void (*ArbUt::SignalHandling::_callback)(const char*) = nullptr; /// \endcond diff --git a/src/SignalHandling.hpp b/src/SignalHandling.hpp index 1e037c2..89e41af 100644 --- a/src/SignalHandling.hpp +++ b/src/SignalHandling.hpp @@ -1,5 +1,6 @@ #ifndef ARBUTILS_SIGNALHANDLING_HPP #define ARBUTILS_SIGNALHANDLING_HPP +#if SIGNAL_HANDLING #if PRETTYTRACES && !WINDOWS #define BACKWARD_HAS_DW 1 #include "../extern/backward.hpp" @@ -176,4 +177,5 @@ namespace ArbUt { /// @fn ArbUt::SignalHandling::loaded() /// @brief Whether or not the signal handler is loaded +#endif // SIGNAL_HANDLING #endif // ARBUTILS_SIGNALHANDLING_HPP