Skip to content

Commit 2ac5797

Browse files
Add cmake option to disable the stacktrace functionality. (#3777)
Setting the cmake option OIIO_DISABLE_BOOST_STACKTRACE to ON disables the use of Boost stacktrace at compile time. This avoids dependencies on helper libraries like dbgeng.dll.
1 parent a58e145 commit 2ac5797

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/cmake/externalpackages.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ endif ()
7878
include_directories (SYSTEM "${Boost_INCLUDE_DIRS}")
7979
link_directories ("${Boost_LIBRARY_DIRS}")
8080

81+
option (OIIO_DISABLE_BOOST_STACKTRACE "Disable use of Boost stacktrace." OFF)
82+
8183
# end Boost setup
8284
###########################################################################
8385

src/libutil/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ if (NOT BUILD_SHARED_LIBS)
3939
target_compile_definitions (OpenImageIO_Util PUBLIC OIIO_STATIC_DEFINE=1)
4040
endif ()
4141

42+
if (OIIO_DISABLE_BOOST_STACKTRACE)
43+
target_compile_definitions (OpenImageIO_Util PRIVATE OIIO_DISABLE_BOOST_STACKTRACE)
44+
endif ()
45+
4246
# Propagate C++ minimum to downstream consumers
4347
target_compile_features (OpenImageIO_Util
4448
INTERFACE cxx_std_${DOWNSTREAM_CXX_STANDARD})

src/libutil/sysutil.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@
7474
# ifndef _GNU_SOURCE
7575
# define _GNU_SOURCE
7676
# endif
77-
# include <boost/stacktrace.hpp>
77+
# if !defined(OIIO_DISABLE_BOOST_STACKTRACE)
78+
# include <boost/stacktrace.hpp>
79+
# endif
7880
#endif
7981

8082
// clang 7.0 (rc2) has errors when including boost thread!
@@ -662,7 +664,7 @@ aligned_free(void* ptr)
662664
std::string
663665
Sysutil::stacktrace()
664666
{
665-
#if BOOST_VERSION >= 106500
667+
#if BOOST_VERSION >= 106500 && !defined(OIIO_DISABLE_BOOST_STACKTRACE)
666668
std::stringstream out;
667669
out << boost::stacktrace::stacktrace();
668670
return out.str();
@@ -673,7 +675,7 @@ Sysutil::stacktrace()
673675

674676

675677

676-
#if BOOST_VERSION >= 106500
678+
#if BOOST_VERSION >= 106500 && !defined(OIIO_DISABLE_BOOST_STACKTRACE)
677679

678680
static std::string stacktrace_filename;
679681
static std::mutex stacktrace_filename_mutex;
@@ -688,7 +690,7 @@ stacktrace_signal_handler(int signum)
688690
else if (stacktrace_filename == "stderr")
689691
std::cerr << Sysutil::stacktrace();
690692
else {
691-
# if BOOST_VERSION >= 106500
693+
# if BOOST_VERSION >= 106500 && !defined(OIIO_DISABLE_BOOST_STACKTRACE)
692694
boost::stacktrace::safe_dump_to(stacktrace_filename.c_str());
693695
# endif
694696
}
@@ -703,7 +705,7 @@ stacktrace_signal_handler(int signum)
703705
bool
704706
Sysutil::setup_crash_stacktrace(string_view filename)
705707
{
706-
#if BOOST_VERSION >= 106500
708+
#if BOOST_VERSION >= 106500 && !defined(OIIO_DISABLE_BOOST_STACKTRACE)
707709
std::lock_guard<std::mutex> lock(stacktrace_filename_mutex);
708710
stacktrace_filename = filename;
709711
::signal(SIGSEGV, &stacktrace_signal_handler);

0 commit comments

Comments
 (0)