From c10f6a622d0a55fe52d794327295132a794d3b6b Mon Sep 17 00:00:00 2001 From: bubnikv Date: Sat, 27 Jun 2020 08:44:13 +0200 Subject: [PATCH] Fixed unit tests on Windows after introduction of GMP to boost::polygon Voronoi diagram generator by Vojtech. Fixed Perl bindings on Windows after some "improvement" of the Windows 10 SDK headers, which fail if included from a C++ code using the extern "C" clause. Namely, the Windows 10 SDK include for sockets introduces C++ macros if a "compiled with C++" symbol is provided even if included through exetrn "C". --- deps/CMakeLists.txt | 94 +++++++++++++++------------------- tests/fff_print/CMakeLists.txt | 4 ++ xs/CMakeLists.txt | 10 ++++ xs/main.xs.in | 4 +- xs/src/xsinit.h | 4 +- 5 files changed, 58 insertions(+), 58 deletions(-) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 4078af3df..718945828 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -129,19 +129,6 @@ else() include("deps-linux.cmake") endif() -# Patch the boost::polygon library with a custom one. -ExternalProject_Add(dep_boost_polygon - EXCLUDE_FROM_ALL ON - GIT_REPOSITORY "https://github.com/prusa3d/polygon" - GIT_TAG prusaslicer_gmp - DEPENDS dep_boost - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory - "${CMAKE_CURRENT_BINARY_DIR}/dep_boost_polygon-prefix/src/dep_boost_polygon/include/boost/polygon" - "${DESTDIR}/usr/local/include/boost/polygon" -) - set(ZLIB_PKG "") if (NOT ZLIB_FOUND) include(ZLIB/ZLIB.cmake) @@ -170,50 +157,49 @@ if (NOT "${ZLIB_PKG}" STREQUAL "") add_dependencies(dep_openexr ${ZLIB_PKG}) endif () +set(_dep_list + dep_boost + dep_tbb + dep_libcurl + dep_wxWidgets + dep_gtest + dep_cereal + dep_nlopt + dep_openvdb + dep_OpenCSG + dep_CGAL + ${PNG_PKG} + ${ZLIB_PKG} + ${EXPAT_PKG} + ) + +if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") + # Patch the boost::polygon library with a custom one. + ExternalProject_Add(dep_boost_polygon + EXCLUDE_FROM_ALL ON + GIT_REPOSITORY "https://github.com/prusa3d/polygon" + GIT_TAG prusaslicer_gmp + DEPENDS dep_boost + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory + "${CMAKE_CURRENT_BINARY_DIR}/dep_boost_polygon-prefix/src/dep_boost_polygon/include/boost/polygon" + "${DESTDIR}/usr/local/include/boost/polygon" + ) + # Only override boost::Polygon Voronoi implementation with Vojtech's GMP hacks on 64bit platforms. + list(APPEND _dep_list "dep_boost_polygon") +endif () + if (MSVC) - - add_custom_target(deps ALL - DEPENDS - dep_boost - dep_boost_polygon - dep_tbb - dep_libcurl - dep_wxWidgets - dep_gtest - dep_cereal - dep_nlopt - # dep_qhull # Experimental - dep_openvdb - dep_OpenCSG - dep_CGAL - ${PNG_PKG} - ${ZLIB_PKG} - ${EXPAT_PKG} - ) - + # Experimental + #list(APPEND _dep_list "dep_qhull") else() - - add_custom_target(deps ALL - DEPENDS - dep_boost - dep_boost_polygon - dep_tbb - dep_libcurl - dep_wxWidgets - dep_gtest - dep_cereal - dep_nlopt - dep_qhull - dep_openvdb - dep_OpenCSG - dep_CGAL - ${PNG_PKG} - ${ZLIB_PKG} - ${EXPAT_PKG} - # dep_libigl # Not working, static build has different Eigen - ) - + list(APPEND _dep_list "dep_qhull") + # Not working, static build has different Eigen + #list(APPEND _dep_list "dep_libigl") endif() +add_custom_target(deps ALL DEPENDS ${_dep_list}) + # Note: I'm not using any of the LOG_xxx options in ExternalProject_Add() commands # because they seem to generate bogus build files (possibly a bug in ExternalProject). diff --git a/tests/fff_print/CMakeLists.txt b/tests/fff_print/CMakeLists.txt index 75a9c3137..c69e722af 100644 --- a/tests/fff_print/CMakeLists.txt +++ b/tests/fff_print/CMakeLists.txt @@ -19,5 +19,9 @@ add_executable(${_TEST_NAME}_tests target_link_libraries(${_TEST_NAME}_tests test_common libslic3r) set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") +if (WIN32) + prusaslicer_copy_dlls(${_TEST_NAME}_tests) +endif() + # catch_discover_tests(${_TEST_NAME}_tests TEST_PREFIX "${_TEST_NAME}: ") add_test(${_TEST_NAME}_tests ${_TEST_NAME}_tests ${CATCH_EXTRA_ARGS}) diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index a59a19936..75d236a54 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -185,6 +185,16 @@ if (MSVC) string(REPLACE "/" "\\" PROPS_CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}") configure_file("../cmake/msvc/xs.wperl.props.in" "${CMAKE_BINARY_DIR}/xs.wperl.props" NEWLINE_STYLE CRLF) set_target_properties(XS PROPERTIES VS_USER_PROPS "${CMAKE_BINARY_DIR}/xs.wperl.props") + + if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") + set(_bits 64) + elseif ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") + set(_bits 32) + endif () + add_custom_command(TARGET XS POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${TOP_LEVEL_PROJECT_DIR}/deps/GMP/gmp/lib/win${_bits}/libgmp-10.dll "${PERL_LOCAL_LIB_ARCH_DIR}/auto/Slic3r/XS/" + COMMENT "Installing gmp runtime into the local-lib directory ..." + VERBATIM) endif() # Installation diff --git a/xs/main.xs.in b/xs/main.xs.in index 3523d569e..c10f432d8 100644 --- a/xs/main.xs.in +++ b/xs/main.xs.in @@ -5,7 +5,7 @@ // #include #ifdef __cplusplus -extern "C" { +/* extern "C" { */ #endif #include "EXTERN.h" #include "perl.h" @@ -14,7 +14,7 @@ extern "C" { #undef do_open #undef do_close #ifdef __cplusplus -} +/* } */ #endif #ifdef _WIN32 diff --git a/xs/src/xsinit.h b/xs/src/xsinit.h index f14e1262d..2082dfb88 100644 --- a/xs/src/xsinit.h +++ b/xs/src/xsinit.h @@ -40,7 +40,7 @@ // #include #ifdef SLIC3RXS -extern "C" { +// extern "C" { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" @@ -88,7 +88,7 @@ extern "C" { #undef Zero #undef Packet #undef _ -} +// } #endif #include