Backwards-compatible Boost 1.73 (#4996)

* Make boost::Placeholders::_1 visible

Fixes https://github.com/slic3r/Slic3r/issues/4967

* Use boost/nowide/cstdlib.hpp instead of boost/nowide/cenv.hpp

* Do not undefine __STRICT_ANSI__

The `__STRICT_ANSI__` macro is defined by the compiler and it's undefined to undefine or redefine it.

Using `-U__STRICT_ANSI__ -std=c++11` is just silly. If you don't want strict mode, don't ask for strict mode. Certainly don't ask for strict mode and then undefined the macro that is defined by strict mode.

The correct solution is `-std=gnu++11` which doesn't define the macro in the first place.

* Help Slic3r::_Log out by adding methods to cover const char* and const wchar_t* (so our tests pass and things don't break when passed string literals).

* calculation of COG in Slic3r (#4970)

Implement center of gravity (COG) calculation and gcode output in Slic3r.

* Comment out cpp travis osx until it's sorted

* Fix misc. typos (#4857)

* Fix misc. typos

Found via `codespell -q 3 -S *.po,./t,./xs/t,./xs/xsp -L ot,uin`

* Follow-up typo fixes

* set progress on deploy script to avoid timeouts

* cpp porting: TransformationMatrix class tests (#4906)

* cpp porting: transformation class testing

* reword some tests

* remove obsolete include

* change equality threshold implementation

* semicolons help in C++

* Stop defining _GLIBCXX_USE_C99 (#4981)

This is an internal macro defined by libstdc++ to record the result of
configure checks done when GCC was built.  Defining (or undefining or
redefining) the macro yourself results in undefined behaviour.

If the system's C library doesn't expose support for C99 or 'long long'
then telling libstdc++ that it does isn't going to work. It will just
mean libstdc++ tries to use features that don't actually exist in the C
library.

In any case, systems that don't support C99 are probably not relevant to
anybody nowadays.

Fixes #4975

* fix-cmake-boost-1-70+ (#4980)

* Use boost/nowide/cstdlib.hpp instead of boost/nowide/cenv.hpp

* Patch build to work on Boost 1.73 and older versions as well.

* Add missing usage of boost::placeholders.

* Add a using for boost versions > 1.73

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Jonathan Wakely <jwakely@fedoraproject.org>
Co-authored-by: Roman Dvořák <romandvorak@mlab.cz>
Co-authored-by: luzpaz <luzpaz@users.noreply.github.com>
Co-authored-by: Michael Kirsch <mkirsch.git@gmail.com>
This commit is contained in:
Joseph Lenox 2021-03-14 18:45:53 -05:00 committed by GitHub
parent 72436abd16
commit 89018b6e02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 81 additions and 13 deletions

View File

@ -115,7 +115,7 @@ endif(NOT GIT_VERSION STREQUAL "")
find_package(Threads REQUIRED)
set(Boost_NO_BOOST_CMAKE ON)
find_package(Boost REQUIRED COMPONENTS system thread filesystem)
find_package(Boost REQUIRED COMPONENTS system thread filesystem OPTIONAL_COMPONENTS nowide)
set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/../xs/src/)
set(GUI_LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/GUI/)
@ -231,6 +231,9 @@ add_library(libslic3r STATIC
target_compile_features(libslic3r PUBLIC cxx_std_11)
target_include_directories(libslic3r SYSTEM PUBLIC ${SLIC3R_INCLUDES})
target_include_directories(libslic3r PUBLIC ${LIBSLIC3R_INCLUDES})
if (BOOST_NOWIDE_FOUND)
target_compile_options(libslic3r -DBOOST_INCLUDE_NOWIDE)
endif()
add_library(BSpline STATIC
${LIBDIR}/BSpline/BSpline.cpp
@ -499,15 +502,17 @@ endif()
# Windows needs a compiled component for Boost.nowide
IF (WIN32)
add_library(boost-nowide STATIC
${LIBDIR}/boost/nowide/iostream.cpp
)
if(MSVC)
# Tell boost pragmas to not rename nowide as we are building it
add_definitions(-DBOOST_NOWIDE_NO_LIB)
endif()
target_link_libraries(slic3r boost-nowide)
target_include_directories(boost-nowide PUBLIC ${COMMON_INCLUDES})
if (NOT BOOST_NOWIDE_FOUND)
add_library(boost-nowide STATIC
${LIBDIR}/boost/nowide/iostream.cpp
)
if(MSVC)
# Tell boost pragmas to not rename nowide as we are building it
add_definitions(-DBOOST_NOWIDE_NO_LIB)
endif()
target_link_libraries(slic3r boost-nowide)
target_include_directories(boost-nowide PUBLIC ${COMMON_INCLUDES})
endif()
# MinGW apparently has some multiple definitions of UUID-related items
# deal with it.

View File

@ -151,18 +151,27 @@ if (defined $ENV{BOOST_LIBRARYPATH}) {
}
# In order to generate the -l switches we need to know how Boost libraries are named
my $have_boost = 0;
my $have_boost_optional = 0;
my @boost_libraries = qw(system thread filesystem); # we need these
my @boost_optional_libraries = qw(nowide); # we need these, but if they aren't present we can deal
# check without explicit lib path (works on Linux)
if (! $mswin) {
$have_boost = 1
if check_lib(
lib => [ map "boost_${_}", @boost_libraries ],
);
$have_boost_optional = 1
if check_lib(
lib => [ map "boost_${_}", @boost_optional_libraries ],
);
}
if (!$ENV{SLIC3R_STATIC} && $have_boost) {
# The boost library was detected by check_lib on Linux.
push @LIBS, map "-lboost_${_}", @boost_libraries;
if (!$ENV{SLIC3R_STATIC} && $have_boost_optional) {
push @LIBS, map "-lboost_${_}", @boost_optional_libraries;
}
} else {
# Either static linking, or check_lib could not be used to find the boost libraries.
my $lib_prefix = 'libboost_';

View File

@ -11710,7 +11710,7 @@ namespace exprtk
{
public:
// Function of N paramters.
// Function of N parameters.
typedef expression_node<T>* expression_ptr;
typedef std::pair<expression_ptr,bool> branch_t;
typedef IFunction ifunction;
@ -21226,7 +21226,7 @@ namespace exprtk
if (index < error_list_.size())
return error_list_[index];
else
throw std::invalid_argument("parser::get_error() - Invalid error index specificed");
throw std::invalid_argument("parser::get_error() - Invalid error index specified");
}
inline std::string error() const

View File

@ -7,6 +7,7 @@
#include <sstream>
#include <exception> // std::runtime_error
#include <set>
#include <boost/version.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/erase.hpp>
@ -16,7 +17,11 @@
#include <boost/config.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#ifdef BOOST_NOWIDE_FOUND
#include <boost/nowide/cstdlib.hpp>
#else
#include <boost/nowide/cenv.hpp>
#endif
#include <boost/nowide/fstream.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/ptree.hpp>

View File

@ -7,7 +7,13 @@
#include <string>
#include <vector>
#include <boost/asio.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION >= 107300
#include <boost/bind/bind.hpp>
#else
#include <boost/bind.hpp>
#endif
#include <boost/thread.hpp>
#include <boost/core/noncopyable.hpp>
@ -15,6 +21,11 @@ namespace Slic3r {
namespace asio = boost::asio;
#if BOOST_VERSION >= 107300
using boost::placeholders::_1;
using boost::placeholders::_2;
#endif
class GCodeSender : private boost::noncopyable {
public:
GCodeSender();

View File

@ -1,9 +1,17 @@
#include "GCodeTimeEstimator.hpp"
#include <boost/bind.hpp>
#include <cmath>
#include <boost/version.hpp>
#if BOOST_VERSION >= 107300
#include <boost/bind/bind.hpp>
#endif
namespace Slic3r {
#if BOOST_VERSION >= 107300
using boost::placeholders::_1;
using boost::placeholders::_2;
#endif
void
GCodeTimeEstimator::parse(const std::string &gcode)
{

View File

@ -4,12 +4,20 @@
#include "Geometry.hpp"
#include "Log.hpp"
#include "TransformationMatrix.hpp"
#include <boost/version.hpp>
#if BOOST_VERSION >= 107300
#include <boost/bind/bind.hpp>
#endif
#include <algorithm>
#include <vector>
#include <limits>
namespace Slic3r {
#if BOOST_VERSION >= 107300
using boost::placeholders::_1;
#endif
PrintObject::PrintObject(Print* print, ModelObject* model_object, const BoundingBoxf3 &modobj_bbox)
: layer_height_spline(model_object->layer_height_spline),
typed_slices(false),

View File

@ -7,9 +7,17 @@
#include <iostream>
#include <complex>
#include <cstdio>
#include <boost/version.hpp>
#if BOOST_VERSION >= 107300
#include <boost/bind/bind.hpp>
#endif
namespace Slic3r {
#if BOOST_VERSION >= 107300
using boost::placeholders::_1;
#endif
void
SLAPrint::slice()
{

View File

@ -1,9 +1,14 @@
#include "SupportMaterial.hpp"
#include "Log.hpp"
namespace Slic3r
{
#if BOOST_VERSION >= 107300
using boost::placeholders::_1;
#endif
PolylineCollection _fill_surface(Fill *fill, Surface *surface)
{
PolylineCollection ps;

View File

@ -13,8 +13,12 @@
#include <math.h>
#include <assert.h>
#include <stdexcept>
#include <boost/version.hpp>
#include <boost/config.hpp>
#include <boost/nowide/convert.hpp>
#if BOOST_VERSION >= 107300
#include <boost/bind/bind.hpp>
#endif
#ifdef SLIC3R_DEBUG
#include "SVG.hpp"
@ -22,6 +26,11 @@
namespace Slic3r {
#if BOOST_VERSION >= 107300
using boost::placeholders::_1;
#endif
TriangleMesh::TriangleMesh()
: repaired(false)
{