From 267712eb32e663873578b589d9383074a25feb3a Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 16 Aug 2018 16:34:59 +0200 Subject: [PATCH] Build: Plumb perl include path Thanks to @kortschak for contributing to this fix Co-authored-by: Dan Kortschak --- Build.PL | 1 - CMakeLists.txt | 15 +++++++++++---- xs/CMakeLists.txt | 5 +++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Build.PL b/Build.PL index 8f882fc4b..16e37986a 100644 --- a/Build.PL +++ b/Build.PL @@ -38,7 +38,6 @@ if ($gui) { %prereqs = qw( Class::Accessor 0 Wx 0.9918 - Socket 2.016 ); %recommends = qw( Wx::GLCanvas 0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 89e6369e0..5d9194d06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ -# Boost 1.63 requires CMake 3.7 or newer -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.2) project(Slic3r) @@ -36,10 +35,18 @@ else() set(ENV_PATH_SEPARATOR ":") endif() set(ENV{PATH} "${PROJECT_SOURCE_DIR}/local-lib/bin${ENV_PATH_SEPARATOR}$ENV{PATH}") -set(ENV{PERL5LIB} "${PROJECT_SOURCE_DIR}/local-lib/lib/perl${ENV_PATH_SEPARATOR}$ENV{PERL5LIB}") +set(PERL_INCLUDE "${PROJECT_SOURCE_DIR}/local-lib/lib/perl5${ENV_PATH_SEPARATOR}$ENV{PERL5LIB}") message("PATH: $ENV{PATH}") -message("PERL5LIB: $ENV{PERL5LIB}") +message("PERL_INCLUDE: ${PERL_INCLUDE}") find_package(Perl REQUIRED) +if (WIN32) + # On Windows passing the PERL5LIB variable causes various problems (such as with MAX_PATH and others), + # basically I've found no good way to do it on Windows. + set(PERL5LIB_ENV_CMD "") +else() + set(PERL5LIB_ENV_CMD ${CMAKE_COMMAND} -E env PERL5LIB=${PERL_INCLUDE}) +endif() + # CMAKE_PREFIX_PATH is used to point CMake to the remaining dependencies (Boost, TBB, ...) # We pick it from environment if it is not defined in another way diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index d41b4c13a..6c2a61685 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -367,7 +367,7 @@ set(MyTypemap ${CMAKE_CURRENT_BINARY_DIR}/typemap) add_custom_command( OUTPUT ${MyTypemap} DEPENDS ${CMAKE_CURRENT_LIST_DIR}/xsp/my.map - COMMAND ${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}\")" + 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}\")" VERBATIM ) @@ -432,7 +432,8 @@ set(XS_MAIN_CPP ${CMAKE_CURRENT_BINARY_DIR}/XS.cpp) add_custom_command( OUTPUT ${XS_MAIN_CPP} 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} + COMMAND ${PERL5LIB_ENV_CMD} xsubpp -typemap typemap -output ${XS_MAIN_CPP} -hiertype ${XS_MAIN_XS} + VERBATIM ) # Define the Perl XS shared library.