Skip to content

Commit e191d3b

Browse files
jreichel-nvidialgritz
authored andcommitted
Add cmake option to disable the stacktrace functionality. (AcademySoftwareFoundation#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 b4b4dcd commit e191d3b

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
@@ -70,7 +70,9 @@
7070
# ifndef _GNU_SOURCE
7171
# define _GNU_SOURCE
7272
# endif
73-
# include <boost/stacktrace.hpp>
73+
# if !defined(OIIO_DISABLE_BOOST_STACKTRACE)
74+
# include <boost/stacktrace.hpp>
75+
# endif
7476
#endif
7577

7678
// clang 7.0 (rc2) has errors when including boost thread!
@@ -658,7 +660,7 @@ aligned_free(void* ptr)
658660
std::string
659661
Sysutil::stacktrace()
660662
{
661-
#if BOOST_VERSION >= 106500
663+
#if BOOST_VERSION >= 106500 && !defined(OIIO_DISABLE_BOOST_STACKTRACE)
662664
std::stringstream out;
663665
out << boost::stacktrace::stacktrace();
664666
return out.str();
@@ -669,7 +671,7 @@ Sysutil::stacktrace()
669671

670672

671673

672-
#if BOOST_VERSION >= 106500
674+
#if BOOST_VERSION >= 106500 && !defined(OIIO_DISABLE_BOOST_STACKTRACE)
673675

674676
static std::string stacktrace_filename;
675677
static std::mutex stacktrace_filename_mutex;
@@ -684,7 +686,7 @@ stacktrace_signal_handler(int signum)
684686
else if (stacktrace_filename == "stderr")
685687
std::cerr << Sysutil::stacktrace();
686688
else {
687-
# if BOOST_VERSION >= 106500
689+
# if BOOST_VERSION >= 106500 && !defined(OIIO_DISABLE_BOOST_STACKTRACE)
688690
boost::stacktrace::safe_dump_to(stacktrace_filename.c_str());
689691
# endif
690692
}
@@ -699,7 +701,7 @@ stacktrace_signal_handler(int signum)
699701
bool
700702
Sysutil::setup_crash_stacktrace(string_view filename)
701703
{
702-
#if BOOST_VERSION >= 106500
704+
#if BOOST_VERSION >= 106500 && !defined(OIIO_DISABLE_BOOST_STACKTRACE)
703705
std::lock_guard<std::mutex> lock(stacktrace_filename_mutex);
704706
stacktrace_filename = filename;
705707
::signal(SIGSEGV, &stacktrace_signal_handler);

0 commit comments

Comments
 (0)