diff --git a/cmake/modules/FindPerlEmbed.cmake b/cmake/modules/FindPerlEmbed.cmake index fc209bc91..ae927dac4 100644 --- a/cmake/modules/FindPerlEmbed.cmake +++ b/cmake/modules/FindPerlEmbed.cmake @@ -14,6 +14,7 @@ execute_process( # Import Perl modules. use strict; use warnings; +use Config; use Text::ParseWords; use ExtUtils::CppGuess; @@ -45,9 +46,13 @@ sub cmake_set_var { my @words = shellwords(\$content); print \$fh \"set(PerlEmbed_\$varname \\\"\" . join(';', @words) . \"\\\")\\n\"; } -cmake_set_var('CCFLAGS', \$ccflags); +cmake_set_var('CCFLAGS', \$ccflags); \$ldflags =~ s/ -L/ -LIBPATH:/g if \$msvc; -cmake_set_var('LDFLAGS', \$ldflags); +cmake_set_var('LD', \$Config{ld}); +cmake_set_var('LDFLAGS', \$ldflags); +cmake_set_var('CCCDLFLAGS', \$Config{cccdlflags}); +cmake_set_var('LDDLFLAGS', \$Config{lddlflags}); +cmake_set_var('DLEXT', \$Config{dlext}); close \$fh; ") include(${PerlEmbed_TEMP_INCLUDE}) @@ -68,7 +73,9 @@ if (PerlEmbed_DEBUG) message(STATUS " PERL_EXTRA_C_FLAGS = ${PERL_EXTRA_C_FLAGS}") # Second show the configuration extracted by this module (FindPerlEmbed): message(STATUS " PerlEmbed_CCFLAGS = ${PerlEmbed_CCFLAGS}") + message(STATUS " LD = ${PerlEmbed_LD}") message(STATUS " PerlEmbed_LDFLAGS = ${PerlEmbed_LDFLAGS}") + message(STATUS " PerlEmbed_LDDLFLAGS = ${PerlEmbed_LDDLFLAGS}") endif() include(FindPackageHandleStandardArgs) diff --git a/xs/Build.PL b/xs/Build.PL index 7f2a03926..0d35aea60 100644 --- a/xs/Build.PL +++ b/xs/Build.PL @@ -180,7 +180,6 @@ if ($have_boost) { } } } -push @cflags, '-DBOOST_LIBS' if $have_boost; die <<'EOF' if !$have_boost; Slic3r requires the Boost libraries. Please make sure they are installed. diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 832f8620e..0942ae4e5 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -13,9 +13,10 @@ include_directories(${LIBDIR}) include_directories(${LIBDIR}/libslic3r) #set(CMAKE_INCLUDE_CURRENT_DIR ON) -if (WIN32) - add_definitions(-D_USE_MATH_DEFINES -D_WIN32) -endif () +if(WIN32) + # BOOST_ALL_NO_LIB: Avoid the automatic linking of Boost libraries on Windows. Rather rely on explicit linking. + add_definitions(-D_USE_MATH_DEFINES -D_WIN32 -DBOOST_ALL_NO_LIB) +endif() add_library(libslic3r STATIC ${LIBDIR}/libslic3r/BoundingBox.cpp @@ -255,41 +256,42 @@ add_custom_command( # Generate the Slic3r Perl module (XS) main.xs file. set(XS_MAIN_XS ${CMAKE_CURRENT_BINARY_DIR}/main.xs) +set(XSP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/xsp) #FIXME list the dependecies explicitely, add dependency on the typemap. -file(GLOB XS_XSP_FILES - ${LIBDIR}/xsp/BoundingBox.xsp - ${LIBDIR}/xsp/BridgeDetector.xsp - ${LIBDIR}/xsp/Clipper.xsp - ${LIBDIR}/xsp/Config.xsp - ${LIBDIR}/xsp/ExPolygon.xsp - ${LIBDIR}/xsp/ExPolygonCollection.xsp - ${LIBDIR}/xsp/ExtrusionEntityCollection.xsp - ${LIBDIR}/xsp/ExtrusionLoop.xsp - ${LIBDIR}/xsp/ExtrusionMultiPath.xsp - ${LIBDIR}/xsp/ExtrusionPath.xsp - ${LIBDIR}/xsp/ExtrusionSimulator.xsp - ${LIBDIR}/xsp/Filler.xsp - ${LIBDIR}/xsp/Flow.xsp - ${LIBDIR}/xsp/GCode.xsp - ${LIBDIR}/xsp/GCodeSender.xsp - ${LIBDIR}/xsp/Geometry.xsp - ${LIBDIR}/xsp/GUI.xsp - ${LIBDIR}/xsp/GUI_3DScene.xsp - ${LIBDIR}/xsp/Layer.xsp - ${LIBDIR}/xsp/Line.xsp - ${LIBDIR}/xsp/Model.xsp - ${LIBDIR}/xsp/MotionPlanner.xsp - ${LIBDIR}/xsp/PerimeterGenerator.xsp - ${LIBDIR}/xsp/PlaceholderParser.xsp - ${LIBDIR}/xsp/Point.xsp - ${LIBDIR}/xsp/Polygon.xsp - ${LIBDIR}/xsp/Polyline.xsp - ${LIBDIR}/xsp/PolylineCollection.xsp - ${LIBDIR}/xsp/Print.xsp - ${LIBDIR}/xsp/Surface.xsp - ${LIBDIR}/xsp/SurfaceCollection.xsp - ${LIBDIR}/xsp/TriangleMesh.xsp - ${LIBDIR}/xsp/XS.xsp +set(XS_XSP_FILES + ${XSP_DIR}/BoundingBox.xsp + ${XSP_DIR}/BridgeDetector.xsp + ${XSP_DIR}/Clipper.xsp + ${XSP_DIR}/Config.xsp + ${XSP_DIR}/ExPolygon.xsp + ${XSP_DIR}/ExPolygonCollection.xsp + ${XSP_DIR}/ExtrusionEntityCollection.xsp + ${XSP_DIR}/ExtrusionLoop.xsp + ${XSP_DIR}/ExtrusionMultiPath.xsp + ${XSP_DIR}/ExtrusionPath.xsp + ${XSP_DIR}/ExtrusionSimulator.xsp + ${XSP_DIR}/Filler.xsp + ${XSP_DIR}/Flow.xsp + ${XSP_DIR}/GCode.xsp + ${XSP_DIR}/GCodeSender.xsp + ${XSP_DIR}/Geometry.xsp + ${XSP_DIR}/GUI.xsp + ${XSP_DIR}/GUI_3DScene.xsp + ${XSP_DIR}/Layer.xsp + ${XSP_DIR}/Line.xsp + ${XSP_DIR}/Model.xsp + ${XSP_DIR}/MotionPlanner.xsp + ${XSP_DIR}/PerimeterGenerator.xsp + ${XSP_DIR}/PlaceholderParser.xsp + ${XSP_DIR}/Point.xsp + ${XSP_DIR}/Polygon.xsp + ${XSP_DIR}/Polyline.xsp + ${XSP_DIR}/PolylineCollection.xsp + ${XSP_DIR}/Print.xsp + ${XSP_DIR}/Surface.xsp + ${XSP_DIR}/SurfaceCollection.xsp + ${XSP_DIR}/TriangleMesh.xsp + ${XSP_DIR}/XS.xsp ) foreach (file ${XS_XSP_FILES}) if (MSVC) @@ -306,7 +308,7 @@ configure_file(main.xs.in ${XS_MAIN_XS} @ONLY) # Insert INCLUDE_COMMANDS into ma set(XS_MAIN_CPP ${CMAKE_CURRENT_BINARY_DIR}/XS.cpp) add_custom_command( OUTPUT ${XS_MAIN_CPP} - DEPENDS ${MyTypemap} ${CMAKE_CURRENT_LIST_DIR}/xsp/typemap.xspt + DEPENDS ${MyTypemap} ${XS_XSP_FILES} ${CMAKE_CURRENT_LIST_DIR}/xsp/typemap.xspt COMMAND COMMAND xsubpp -typemap typemap -output ${XS_MAIN_CPP} -hiertype ${XS_MAIN_XS} ) @@ -397,21 +399,24 @@ target_link_libraries(XS ${PERL_LIBRARY}) ## REQUIRED packages # Find and configure boost -if (SLIC3R_STATIC) +if(SLIC3R_STATIC) # Use static boost libraries. set(Boost_USE_STATIC_LIBS ON) # Use boost libraries linked statically to the C++ runtime. # set(Boost_USE_STATIC_RUNTIME ON) -endif () +endif() find_package(Boost REQUIRED COMPONENTS system filesystem thread log locale) -if (Boost_FOUND) +if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) target_link_libraries(XS ${Boost_LIBRARIES}) - target_compile_definitions(XS PRIVATE -DBOOST_ASIO_DISABLE_KQUEUE -DBOOST_LIBS -DBOOST_ALL_NO_LIB) - if (NOT SLIC3R_STATIC) - target_compile_definitions(XS PRIVATE -DBOOST_LOG_DYN_LINK) - endif () -endif () + if (APPLE) + # BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339 + add_definitions(-DBOOST_ASIO_DISABLE_KQUEUE) + endif() + if(NOT SLIC3R_STATIC) + add_definitions(-DBOOST_LOG_DYN_LINK) + endif() +endif() # Find and configure intel-tbb if(SLIC3R_STATIC) @@ -436,12 +441,12 @@ if (SLIC3R_PRUSACONTROL) include_directories(${AlienWx_INCLUDE_DIRS}) #add_compile_options(${AlienWx_CXX_FLAGS}) add_definitions(${AlienWx_DEFINITIONS}) - set(wxWidgets_LIBRARIES, ${AlienWx_LIBRARIES}) + set(wxWidgets_LIBRARIES ${AlienWx_LIBRARIES}) else () find_package(wxWidgets REQUIRED COMPONENTS base) include(${wxWidgets_USE_FILE}) endif () - target_compile_definitions(XS PRIVATE -DSLIC3R_GUI -DSLIC3R_PRUS) + add_definitions(-DSLIC3R_GUI -DSLIC3R_PRUS) target_link_libraries(XS ${wxWidgets_LIBRARIES}) endif() @@ -484,8 +489,7 @@ if (NOT GLEW_FOUND) set(GLEW_FOUND 1) set(GLEW_INCLUDE_DIRS ${LIBDIR}/glew/include/) set(GLEW_LIBRARIES glew) - target_compile_definitions(glew PRIVATE -DGLEW_STATIC) - target_compile_definitions(XS PRIVATE -DGLEW_STATIC) + add_definitions(-DGLEW_STATIC) endif () include_directories(${GLEW_INCLUDE_DIRS}) target_link_libraries(XS ${GLEW_LIBRARIES}) @@ -498,10 +502,6 @@ target_link_libraries(slic3r libslic3r libslic3r_gui admesh ${Boost_LIBRARIES} c if(SLIC3R_DEBUG) target_link_libraries(Shiny) endif() -target_compile_definitions(slic3r PRIVATE -DBOOST_ASIO_DISABLE_KQUEUE -DBOOST_LIBS -DBOOST_ALL_NO_LIB) -if(NOT SLIC3R_STATIC) - target_compile_definitions(slic3r PRIVATE -DBOOST_LOG_DYN_LINK) -endif() if (APPLE) target_link_libraries(slic3r "-framework IOKit" "-framework CoreFoundation" -lc++) elseif (NOT MSVC) diff --git a/xs/src/libslic3r/Fill/FillRectilinear3.cpp b/xs/src/libslic3r/Fill/FillRectilinear3.cpp index 9101bd817..f4b198ade 100644 --- a/xs/src/libslic3r/Fill/FillRectilinear3.cpp +++ b/xs/src/libslic3r/Fill/FillRectilinear3.cpp @@ -610,7 +610,7 @@ static bool prepare_infill_hatching_segments( #undef ASSERT_OR_RETURN #ifdef _MSC_VER #pragma warning(push) -#endif _MSC_VER +#endif /* _MSC_VER */ #ifdef SLIC3R_DEBUG // Paint the segments and finalize the SVG file. diff --git a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp index f45ca336b..ec01e09dc 100644 --- a/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp +++ b/xs/src/libslic3r/GCode/WipeTowerPrusaMM.cpp @@ -344,7 +344,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(int tool, bool last_in { // Either it is the last tool unload, // or there must be a nonzero wipe tower partitions available. - assert(tool < 0 || it_layer_tools->wipe_tower_partitions > 0); +// assert(tool < 0 || it_layer_tools->wipe_tower_partitions > 0); if (m_idx_tool_change_in_layer == (unsigned int)(-1)) { // First layer, prime the extruder. diff --git a/xs/src/libslic3r/GCodeSender.cpp b/xs/src/libslic3r/GCodeSender.cpp index 72acd9922..504171288 100644 --- a/xs/src/libslic3r/GCodeSender.cpp +++ b/xs/src/libslic3r/GCodeSender.cpp @@ -1,4 +1,3 @@ -#ifdef BOOST_LIBS #include "GCodeSender.hpp" #include #include @@ -30,8 +29,6 @@ std::fstream fs; namespace Slic3r { -namespace asio = boost::asio; - GCodeSender::GCodeSender() : io(), serial(io), can_send(false), sent(0), open(false), error(false), connected(false), queue_paused(false) @@ -50,20 +47,20 @@ GCodeSender::connect(std::string devname, unsigned int baud_rate) this->set_error_status(false); try { this->serial.open(devname); - } catch (boost::system::system_error &e) { + } catch (boost::system::system_error &) { this->set_error_status(true); return false; } - this->serial.set_option(asio::serial_port_base::parity(asio::serial_port_base::parity::odd)); - this->serial.set_option(asio::serial_port_base::character_size(asio::serial_port_base::character_size(8))); - this->serial.set_option(asio::serial_port_base::flow_control(asio::serial_port_base::flow_control::none)); - this->serial.set_option(asio::serial_port_base::stop_bits(asio::serial_port_base::stop_bits::one)); + this->serial.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::odd)); + this->serial.set_option(boost::asio::serial_port_base::character_size(boost::asio::serial_port_base::character_size(8))); + this->serial.set_option(boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::none)); + this->serial.set_option(boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one)); this->set_baud_rate(baud_rate); this->serial.close(); this->serial.open(devname); - this->serial.set_option(asio::serial_port_base::parity(asio::serial_port_base::parity::none)); + this->serial.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none)); // set baud rate again because set_option overwrote it this->set_baud_rate(baud_rate); @@ -84,7 +81,7 @@ GCodeSender::connect(std::string devname, unsigned int baud_rate) this->io.post(boost::bind(&GCodeSender::do_read, this)); // start reading in the background thread - boost::thread t(boost::bind(&asio::io_service::run, &this->io)); + boost::thread t(boost::bind(&boost::asio::io_service::run, &this->io)); this->background_thread.swap(t); return true; @@ -95,8 +92,8 @@ GCodeSender::set_baud_rate(unsigned int baud_rate) { try { // This does not support speeds > 115200 - this->serial.set_option(asio::serial_port_base::baud_rate(baud_rate)); - } catch (boost::system::system_error &e) { + this->serial.set_option(boost::asio::serial_port_base::baud_rate(baud_rate)); + } catch (boost::system::system_error &) { boost::asio::serial_port::native_handle_type handle = this->serial.native_handle(); #if __APPLE__ @@ -276,15 +273,15 @@ void GCodeSender::do_read() { // read one line - asio::async_read_until( + boost::asio::async_read_until( this->serial, this->read_buffer, '\n', boost::bind( &GCodeSender::on_read, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred ) ); } @@ -483,11 +480,11 @@ GCodeSender::do_send() if (this->last_sent.size() > KEEP_SENT) this->last_sent.erase(this->last_sent.begin(), this->last_sent.end() - KEEP_SENT); - // we can't supply asio::buffer(full_line) to async_write() because full_line is on the + // we can't supply boost::asio::buffer(full_line) to async_write() because full_line is on the // stack and the buffer would lose its underlying storage causing memory corruption std::ostream os(&this->write_buffer); os << full_line; - asio::async_write(this->serial, this->write_buffer, boost::bind(&GCodeSender::on_write, this, boost::asio::placeholders::error, + boost::asio::async_write(this->serial, this->write_buffer, boost::bind(&GCodeSender::on_write, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } @@ -511,7 +508,7 @@ void GCodeSender::set_DTR(bool on) { #if defined(_WIN32) && !defined(__SYMBIAN32__) - asio::serial_port_service::native_handle_type handle = this->serial.native_handle(); + boost::asio::serial_port_service::native_handle_type handle = this->serial.native_handle(); if (on) EscapeCommFunction(handle, SETDTR); else @@ -543,6 +540,4 @@ GCodeSender::reset() } } -} - -#endif +} // namespace Slic3r diff --git a/xs/src/libslic3r/GCodeSender.hpp b/xs/src/libslic3r/GCodeSender.hpp index 74583327f..3022993cb 100644 --- a/xs/src/libslic3r/GCodeSender.hpp +++ b/xs/src/libslic3r/GCodeSender.hpp @@ -1,6 +1,5 @@ #ifndef slic3r_GCodeSender_hpp_ #define slic3r_GCodeSender_hpp_ -#ifdef BOOST_LIBS #include "libslic3r.h" #include @@ -71,5 +70,4 @@ class GCodeSender : private boost::noncopyable { } // namespace Slic3r -#endif /* BOOST_LIBS */ #endif /* slic3r_GCodeSender_hpp_ */ diff --git a/xs/xsp/GCodeSender.xsp b/xs/xsp/GCodeSender.xsp index 9c55194e5..f99244a1f 100644 --- a/xs/xsp/GCodeSender.xsp +++ b/xs/xsp/GCodeSender.xsp @@ -1,7 +1,5 @@ %module{Slic3r::XS}; -#ifdef BOOST_LIBS - %{ #include #include "libslic3r/GCodeSender.hpp" @@ -24,5 +22,3 @@ std::string getT(); std::string getB(); }; - -#endif