Skip to content

Commit

Permalink
Remove unused boost includes and make boost optional
Browse files Browse the repository at this point in the history
Apparently we dont use boost anymore except for stacktraces,
Make it so lack of boost just leaves builds without stacktraces
  • Loading branch information
IonAgorria committed Dec 29, 2023
1 parent 0139ba7 commit 46c2202
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 56 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ IF(NOT APPLE)
ENDIF()
FIND_PACKAGE(ZLIB REQUIRED)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${PREFER_DYNAMIC_LIBRARY_SUFFIXES})
FIND_PACKAGE(Boost REQUIRED)
IF(MSVC_CL_BUILD)
#Specifics to MSVC+VCPKG
FIND_PACKAGE(SDL2 CONFIG REQUIRED)
Expand Down Expand Up @@ -237,7 +236,6 @@ ENDIF()

# globals
INCLUDE_DIRECTORIES(SYSTEM
${Boost_INCLUDE_DIRS}
${SDL2_INCLUDE_DIR}
${SDL2_IMAGE_INCLUDE_DIR}
${SDL2_MIXER_INCLUDE_DIR}
Expand Down Expand Up @@ -384,9 +382,6 @@ IF(PERIMETER_DEBUG)
ELSE()
ADD_DEFINITIONS(-DNDEBUG)
ENDIF()
IF(OPTION_DISABLE_STACKTRACE)
ADD_DEFINITIONS(-DOPTION_DISABLE_STACKTRACE)
ENDIF()
IF(PERIMETER_EXODUS)
ADD_DEFINITIONS(-DPERIMETER_EXODUS)
ENDIF()
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.eng.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ We have several CI in github which can serve as hint and examples.
- SDL2_net
- SDL2_mixer
- FFmpeg (avcodec / avformat / avfilter / avutils / swscale)
- Boost
- ZLIB
- Boost stacktrace (optional)

### Automatic dependencies

Expand Down
10 changes: 0 additions & 10 deletions Source/Util/SerializationImpl.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
#ifndef __SERIALIZATION_IMPL_H__
#define __SERIALIZATION_IMPL_H__

#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_fundamental.hpp>
#include <boost/mpl/equal_to.hpp>
/*
#include <boost/mpl/apply_if.hpp>
#include <boost/mpl/identity.hpp>
*/
#include "SerializationMacro.h"
#include "SerializationHelpers.h"
#include <boost/mpl/int.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <list>

#include "RangedWrapper.h"
Expand Down
75 changes: 44 additions & 31 deletions Source/XTool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,49 @@ FetchContent_MakeAvailable(gamemath)

SET(XTool_LINK_LIBS gamemath ZLIB::ZLIB)

IF(NOT OPTION_DISABLE_STACKTRACE)
#https://www.boost.org/doc/libs/1_78_0/doc/html/stacktrace/configuration_and_build.html
IF(MSVC_CL_BUILD)
#Use WinDbg for MSVC
MESSAGE("Using WinDbg")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_WINDBG)
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ole32 dbgeng)
ELSEIF(PERIMETER_WINDOWS)
#Use Backtrace if available in Msys/Mingw, else WinDbg
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${PREFER_STATIC_LIBRARY_SUFFIXES})
FIND_PACKAGE(Backtrace)
IF(Backtrace_FOUND)
MESSAGE("Using Backtrace")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_BACKTRACE)
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ${Backtrace_LIBRARIES})
ELSE()
MESSAGE("Using WinDbg")
IF(OPTION_DISABLE_STACKTRACE)
MESSAGE("Stacktrace: Disabled")
ELSE()
find_package(Boost 1.76.0)
IF(NOT Boost_FOUND)
MESSAGE("Stacktrace: No Boost found, unavailable")
SET(OPTION_DISABLE_STACKTRACE ON)
ELSE()
#https://www.boost.org/doc/libs/1_78_0/doc/html/stacktrace/configuration_and_build.html
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})
IF(MSVC_CL_BUILD)
#Use WinDbg for MSVC
MESSAGE("Stacktrace: Using WinDbg")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_WINDBG)
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ole32 dbgeng)
ENDIF()
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${PREFER_DYNAMIC_LIBRARY_SUFFIXES})
ELSE()
#Use ADDR2LINE in POSIX unless Backtrace is wanted
FIND_PACKAGE(Backtrace)
IF(Backtrace_FOUND AND OPTION_USE_BACKTRACE)
MESSAGE("Using Backtrace")
INCLUDE_DIRECTORIES(${Backtrace_INCLUDE_DIR})
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_BACKTRACE)
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ${Backtrace_LIBRARIES})
ELSEIF(PERIMETER_WINDOWS)
#Use Backtrace if available in Msys/Mingw, else WinDbg
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${PREFER_STATIC_LIBRARY_SUFFIXES})
FIND_PACKAGE(Backtrace)
IF(Backtrace_FOUND AND OPTION_USE_BACKTRACE)
MESSAGE("Stacktrace: Using Backtrace")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_BACKTRACE)
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ${Backtrace_LIBRARIES})
ELSE()
MESSAGE("Stacktrace: Using WinDbg")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_WINDBG)
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ole32 dbgeng)
ENDIF()
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${PREFER_DYNAMIC_LIBRARY_SUFFIXES})
ELSE()
MESSAGE("Using Addr2Line")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_ADDR2LINE)
# dl is required for dladdr in stacktrace
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} dl)
#Use ADDR2LINE in POSIX unless Backtrace is wanted
FIND_PACKAGE(Backtrace)
IF(Backtrace_FOUND AND OPTION_USE_BACKTRACE)
MESSAGE("Stacktrace: Using Backtrace")
INCLUDE_DIRECTORIES(${Backtrace_INCLUDE_DIR})
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_BACKTRACE)
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} ${Backtrace_LIBRARIES})
ELSE()
MESSAGE("Stacktrace: Using Addr2Line")
ADD_DEFINITIONS(-DBOOST_STACKTRACE_USE_ADDR2LINE)
# dl is required for dladdr in stacktrace
SET(XTool_LINK_LIBS ${XTool_LINK_LIBS} dl)
ENDIF()
ENDIF()
ENDIF()
ENDIF()
Expand Down Expand Up @@ -78,3 +87,7 @@ target_include_directories(XTool PRIVATE
BEFORE .
"${gamemath_SOURCE_DIR}/include"
)

IF(OPTION_DISABLE_STACKTRACE)
target_compile_definitions(XTool PUBLIC -DOPTION_DISABLE_STACKTRACE)
ENDIF()
2 changes: 1 addition & 1 deletion Source/XTool/xerrhand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ char convBuf[CONV_BUFFER_LEN + 1];

#ifndef OPTION_DISABLE_STACKTRACE
#define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED 1
#include "boost/stacktrace.hpp"
#include <boost/stacktrace.hpp>

#endif

Expand Down
12 changes: 6 additions & 6 deletions docker/dockcross/dockcross-x64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ RUN add-apt-repository "deb [arch=amd64] http://pkg.mxe.cc/repos/apt buster main
RUN apt-get update

# Download boost, untar, setup install with bootstrap and install
RUN cd /work && wget http://downloads.sourceforge.net/project/boost/boost/1.78.0/boost_1_78_0.tar.gz
RUN cd /work && tar xfvz /work/boost_1_78_0.tar.gz
RUN rm /work/boost_1_78_0.tar.gz
RUN cd /work/boost_1_78_0 && ./bootstrap.sh --prefix=/usr/local || true
RUN cd /work/boost_1_78_0 && ./b2 install || true
RUN rm -rf /work/boost_1_78_0
RUN cd /work && wget http://downloads.sourceforge.net/project/boost/boost/1.84.0/boost_1_84_0.tar.gz
RUN cd /work && tar xfvz /work/boost_1_84_0.tar.gz
RUN rm /work/boost_1_84_0.tar.gz
RUN cd /work/boost_1_84_0 && ./bootstrap.sh --prefix=/usr/local || true
RUN cd /work/boost_1_84_0 && ./b2 install --with-system --with-stacktrace || true
RUN rm -rf /work/boost_1_84_0

RUN cd /work && git clone https://github.com/ianlancetaylor/libbacktrace.git
RUN cd /work/libbacktrace && ./configure --host=$CROSS_TRIPLE --prefix=/usr/local --enable-static --disable-shared
Expand Down
2 changes: 0 additions & 2 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"dependencies": [
"zlib",
"boost-stacktrace",
"boost-iterator",
"boost-type-index",
"libvorbis",
"libvpx",
"sdl2",
Expand Down

0 comments on commit 46c2202

Please sign in to comment.