2018-09-19 09:02:24 +00:00
|
|
|
project(XS)
|
2018-05-21 13:56:35 +00:00
|
|
|
|
2017-08-18 12:34:54 +00:00
|
|
|
# Generate the Slic3r Perl module (XS) typemap file.
|
2017-08-16 17:05:08 +00:00
|
|
|
set(MyTypemap ${CMAKE_CURRENT_BINARY_DIR}/typemap)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${MyTypemap}
|
2017-08-18 09:39:24 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/xsp/my.map
|
2018-08-16 14:34:59 +00:00
|
|
|
COMMAND ${PERL5LIB_ENV_CMD} ${PERL_EXECUTABLE} -MExtUtils::Typemaps -MExtUtils::Typemaps::Basic -e "$typemap = ExtUtils::Typemaps->new(file => \"${CMAKE_CURRENT_LIST_DIR}/xsp/my.map\"); $typemap->merge(typemap => ExtUtils::Typemaps::Basic->new); $typemap->write(file => \"${MyTypemap}\")"
|
2017-08-16 17:05:08 +00:00
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
|
2017-08-17 11:30:46 +00:00
|
|
|
# Generate the Slic3r Perl module (XS) main.xs file.
|
2017-08-18 09:39:24 +00:00
|
|
|
set(XS_MAIN_XS ${CMAKE_CURRENT_BINARY_DIR}/main.xs)
|
2017-08-18 19:09:53 +00:00
|
|
|
set(XSP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/xsp)
|
2017-08-17 11:30:46 +00:00
|
|
|
#FIXME list the dependecies explicitely, add dependency on the typemap.
|
2017-08-18 19:09:53 +00:00
|
|
|
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}/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
|
2017-08-18 09:39:24 +00:00
|
|
|
)
|
|
|
|
foreach (file ${XS_XSP_FILES})
|
2017-08-16 17:05:08 +00:00
|
|
|
if (MSVC)
|
|
|
|
# Visual Studio C compiler has issues with FILE pragmas containing quotes.
|
|
|
|
set(INCLUDE_COMMANDS "${INCLUDE_COMMANDS}INCLUDE_COMMAND: $^X -MExtUtils::XSpp::Cmd -e xspp -- -t ${CMAKE_CURRENT_LIST_DIR}/xsp/typemap.xspt ${file}\n")
|
|
|
|
else ()
|
|
|
|
set(INCLUDE_COMMANDS "${INCLUDE_COMMANDS}INCLUDE_COMMAND: $^X -MExtUtils::XSpp::Cmd -e xspp -- -t \"${CMAKE_CURRENT_LIST_DIR}/xsp/typemap.xspt\" \"${file}\"\n")
|
|
|
|
endif ()
|
|
|
|
endforeach ()
|
2017-08-18 09:39:24 +00:00
|
|
|
configure_file(main.xs.in ${XS_MAIN_XS} @ONLY) # Insert INCLUDE_COMMANDS into main.xs
|
2017-08-16 17:05:08 +00:00
|
|
|
|
2017-08-17 11:30:46 +00:00
|
|
|
# Generate the Slic3r Perl module (XS) XS.cpp file.
|
|
|
|
#FIXME add the dependency on main.xs and typemap.
|
2017-08-18 09:39:24 +00:00
|
|
|
set(XS_MAIN_CPP ${CMAKE_CURRENT_BINARY_DIR}/XS.cpp)
|
2017-08-16 17:05:08 +00:00
|
|
|
add_custom_command(
|
2017-08-18 09:39:24 +00:00
|
|
|
OUTPUT ${XS_MAIN_CPP}
|
2017-08-18 19:09:53 +00:00
|
|
|
DEPENDS ${MyTypemap} ${XS_XSP_FILES} ${CMAKE_CURRENT_LIST_DIR}/xsp/typemap.xspt
|
2018-08-16 14:34:59 +00:00
|
|
|
COMMAND ${PERL5LIB_ENV_CMD} xsubpp -typemap typemap -output ${XS_MAIN_CPP} -hiertype ${XS_MAIN_XS}
|
|
|
|
VERBATIM
|
2017-08-16 17:05:08 +00:00
|
|
|
)
|
|
|
|
|
2017-08-18 09:39:24 +00:00
|
|
|
# Define the Perl XS shared library.
|
2017-08-18 20:06:10 +00:00
|
|
|
if(APPLE)
|
|
|
|
set(XS_SHARED_LIBRARY_TYPE MODULE)
|
|
|
|
else()
|
|
|
|
set(XS_SHARED_LIBRARY_TYPE SHARED)
|
|
|
|
endif()
|
|
|
|
add_library(XS ${XS_SHARED_LIBRARY_TYPE}
|
2017-08-18 09:39:24 +00:00
|
|
|
${XS_MAIN_CPP}
|
2018-09-19 09:02:24 +00:00
|
|
|
# ${LIBDIR}/libslic3r/utils.cpp
|
|
|
|
# ${LIBDIR}/slic3r/GUI/wxPerlIface.cpp
|
|
|
|
src/perlglue.cpp
|
|
|
|
# src/callback.cpp
|
|
|
|
# src/callback.hpp
|
|
|
|
src/ppport.h
|
|
|
|
src/xsinit.h
|
|
|
|
xsp/my.map
|
2017-08-18 11:32:35 +00:00
|
|
|
# mytype.map is empty. Is it required by Build.PL or the Perl xspp module?
|
2018-09-19 09:02:24 +00:00
|
|
|
xsp/mytype.map
|
2017-08-18 11:32:35 +00:00
|
|
|
# Used by Perl xsubpp to generate XS.cpp
|
2018-09-19 09:02:24 +00:00
|
|
|
xsp/typemap.xspt
|
2017-08-18 09:39:24 +00:00
|
|
|
)
|
2017-08-18 20:06:10 +00:00
|
|
|
if(APPLE)
|
|
|
|
set_target_properties(XS PROPERTIES BUNDLE TRUE)
|
|
|
|
# Ignore undefined symbols of the perl interpreter, they will be found in the caller image.
|
|
|
|
target_link_libraries(XS "-undefined dynamic_lookup")
|
|
|
|
endif()
|
2018-09-19 09:02:24 +00:00
|
|
|
target_link_libraries(XS libslic3r admesh miniz clipper nowide polypartition poly2tri semver avrdude qhull)
|
2018-01-03 16:29:49 +00:00
|
|
|
if(SLIC3R_PROFILE)
|
|
|
|
target_link_libraries(XS Shiny)
|
2017-08-18 09:39:24 +00:00
|
|
|
endif()
|
2017-08-16 17:05:08 +00:00
|
|
|
|
2018-09-19 11:12:57 +00:00
|
|
|
target_include_directories(XS PRIVATE src)
|
2017-08-16 17:05:08 +00:00
|
|
|
target_compile_definitions(XS PRIVATE -DSLIC3RXS)
|
|
|
|
set_target_properties(XS PROPERTIES PREFIX "") # Prevent cmake from generating libXS.so instead of XS.so
|
|
|
|
|
2018-09-19 09:02:24 +00:00
|
|
|
target_link_libraries(XS ${Boost_LIBRARIES})
|
|
|
|
# target_link_libraries(XS ${wxWidgets_LIBRARIES})
|
|
|
|
# target_link_libraries(XS ${CURL_LIBRARIES})
|
|
|
|
# target_link_libraries(XS ${OPENSSL_LIBRARIES})
|
|
|
|
|
2017-08-16 17:05:08 +00:00
|
|
|
if (APPLE)
|
2017-08-17 16:27:51 +00:00
|
|
|
# add_compile_options(-stdlib=libc++)
|
|
|
|
# add_definitions(-DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE)
|
2017-08-18 14:59:36 +00:00
|
|
|
target_link_libraries(XS "-framework IOKit" "-framework CoreFoundation" -lc++)
|
2017-08-16 17:05:08 +00:00
|
|
|
elseif (MSVC)
|
|
|
|
target_link_libraries(XS )
|
|
|
|
else ()
|
2017-08-17 16:27:51 +00:00
|
|
|
target_link_libraries(XS -lstdc++)
|
2017-08-16 17:05:08 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
# Windows specific stuff
|
|
|
|
if (WIN32)
|
2017-08-18 09:39:24 +00:00
|
|
|
target_compile_definitions(XS PRIVATE -DNOGDI -DNOMINMAX -DHAS_BOOL)
|
2017-08-16 17:05:08 +00:00
|
|
|
endif ()
|
|
|
|
|
2018-08-17 10:38:33 +00:00
|
|
|
# SLIC3R_MSVC_PDB
|
2018-09-17 13:12:13 +00:00
|
|
|
if (MSVC AND SLIC3R_MSVC_PDB AND "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
2018-08-17 10:38:33 +00:00
|
|
|
set_target_properties(XS PROPERTIES
|
|
|
|
COMPILE_FLAGS "/Zi"
|
|
|
|
LINK_FLAGS "/DEBUG /OPT:REF /OPT:ICF"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2017-08-16 17:05:08 +00:00
|
|
|
if (CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|
|
|
target_compile_definitions(XS PRIVATE -DSLIC3R_DEBUG -DDEBUG -D_DEBUG)
|
|
|
|
else ()
|
|
|
|
target_compile_definitions(XS PRIVATE -DNDEBUG)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
target_include_directories(XS PRIVATE ${PERL_INCLUDE_PATH})
|
2017-08-17 16:27:51 +00:00
|
|
|
target_compile_options(XS PRIVATE ${PerlEmbed_CCFLAGS})
|
2018-09-19 09:02:24 +00:00
|
|
|
|
2017-08-29 10:41:59 +00:00
|
|
|
if (WIN32)
|
2017-08-18 20:06:10 +00:00
|
|
|
target_link_libraries(XS ${PERL_LIBRARY})
|
|
|
|
endif()
|
2017-08-16 17:05:08 +00:00
|
|
|
|
|
|
|
# Find and configure boost
|
2017-08-18 19:09:53 +00:00
|
|
|
if(SLIC3R_STATIC)
|
2017-08-16 17:05:08 +00:00
|
|
|
# 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)
|
2017-08-18 19:09:53 +00:00
|
|
|
endif()
|
2017-08-16 17:05:08 +00:00
|
|
|
|
2018-09-19 09:02:24 +00:00
|
|
|
target_link_libraries(XS ${Boost_LIBRARIES})
|
2017-08-17 16:27:51 +00:00
|
|
|
target_link_libraries(XS ${TBB_LIBRARIES})
|
2018-09-19 09:02:24 +00:00
|
|
|
# target_link_libraries(XS ${wxWidgets_LIBRARIES})
|
2017-08-16 17:05:08 +00:00
|
|
|
target_link_libraries(XS ${EXPAT_LIBRARIES})
|
2018-09-19 09:02:24 +00:00
|
|
|
# target_link_libraries(XS ${GLEW_LIBRARIES})
|
2017-08-16 17:05:08 +00:00
|
|
|
|
2017-08-28 17:11:16 +00:00
|
|
|
# Install the XS.pm and XS.{so,dll,bundle} into the local-lib directory.
|
2018-09-19 11:12:57 +00:00
|
|
|
set(PERL_LOCAL_LIB_DIR "../../local-lib/lib/perl5/${PerlEmbed_ARCHNAME}")
|
2017-08-28 17:11:16 +00:00
|
|
|
add_custom_command(
|
|
|
|
TARGET XS
|
|
|
|
POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${PERL_LOCAL_LIB_DIR}/auto/Slic3r/XS/"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:XS>" "${PERL_LOCAL_LIB_DIR}/auto/Slic3r/XS/"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${PERL_LOCAL_LIB_DIR}/Slic3r/"
|
2018-09-19 09:02:24 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/lib/Slic3r/XS.pm" "${PERL_LOCAL_LIB_DIR}/Slic3r/"
|
2018-04-30 12:31:57 +00:00
|
|
|
COMMENT "Installing XS.pm and XS.{so,dll,bundle} into the local-lib directory ..."
|
2017-08-28 17:11:16 +00:00
|
|
|
)
|
2017-08-29 14:37:46 +00:00
|
|
|
if(APPLE)
|
|
|
|
add_custom_command(
|
|
|
|
TARGET XS
|
|
|
|
POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E rename "${PERL_LOCAL_LIB_DIR}/auto/Slic3r/XS/XS" "${PERL_LOCAL_LIB_DIR}/auto/Slic3r/XS/XS.bundle"
|
|
|
|
)
|
|
|
|
endif()
|
2017-08-18 11:32:35 +00:00
|
|
|
|
2018-01-03 16:29:49 +00:00
|
|
|
if(SLIC3R_PROFILE)
|
2017-08-18 11:32:35 +00:00
|
|
|
target_link_libraries(Shiny)
|
|
|
|
endif()
|
|
|
|
|
2018-02-23 15:48:11 +00:00
|
|
|
if (MSVC)
|
2018-03-12 08:39:32 +00:00
|
|
|
# Here we associate some additional properties with the MSVC project to enable compilation and debugging out of the box.
|
2018-05-02 10:27:46 +00:00
|
|
|
get_filename_component(PROPS_PERL_BIN_PATH "${PERL_EXECUTABLE}" DIRECTORY)
|
|
|
|
string(REPLACE "/" "\\" PROPS_PERL_BIN_PATH "${PROPS_PERL_BIN_PATH}")
|
|
|
|
string(REPLACE "/" "\\" PROPS_PERL_EXECUTABLE "${PERL_EXECUTABLE}")
|
|
|
|
string(REPLACE "/" "\\" PROPS_CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}")
|
2018-09-19 09:02:24 +00:00
|
|
|
configure_file("../cmake/msvc/xs.wperl.props.in" "${CMAKE_BINARY_DIR}/xs.wperl.props" NEWLINE_STYLE CRLF)
|
2018-05-02 11:03:04 +00:00
|
|
|
set_target_properties(XS PROPERTIES VS_USER_PROPS "${CMAKE_BINARY_DIR}/xs.wperl.props")
|
2018-03-12 08:39:32 +00:00
|
|
|
endif()
|
2018-02-23 15:48:11 +00:00
|
|
|
|
2017-08-16 17:05:08 +00:00
|
|
|
# Installation
|
2018-03-05 17:32:09 +00:00
|
|
|
install(TARGETS XS DESTINATION ${PERL_VENDORARCH}/auto/Slic3r/XS)
|
|
|
|
install(FILES lib/Slic3r/XS.pm DESTINATION ${PERL_VENDORLIB}/Slic3r)
|