deps script for Mac OS, XCode support fix

This commit is contained in:
Vojtech Kral 2018-11-30 20:52:45 +01:00
parent 693a4168f8
commit 6693b2102d
6 changed files with 198 additions and 66 deletions

16
deps/CMakeLists.txt vendored
View File

@ -20,16 +20,18 @@ project(Slic3r-deps)
cmake_minimum_required(VERSION 3.2)
include(ExternalProject)
include(ProcessorCount)
ProcessorCount(NPROC)
if (NPROC EQUAL 0)
set(NPROC 1)
endif ()
set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory")
option(DEP_DEBUG "Build debug variants (currently only works on Windows)" ON)
option(DEP_DEBUG "Build debug variants (only applicable on Windows)" ON)
message(STATUS "Slic3r deps DESTDIR: ${DESTDIR}")
message(STATUS "Slic3r deps debug build: ${DEP_DEBUG}")
if (MSVC)
if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
@ -43,8 +45,16 @@ if (MSVC)
else ()
message(FATAL_ERROR "Unable to detect architecture")
endif ()
elseif (APPLE)
set(DEPS_OSX_TARGET "10.9" CACHE STRING "OS X SDK version to build against")
set(DEPS_OSX_SYSROOT
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${DEPS_OSX_TARGET}.sdk"
CACHE PATH "OS X SDK directory"
)
include("deps-macos.cmake")
else ()
include("deps-unix-static.cmake")
include("deps-linux.cmake")
endif()
add_custom_target(deps ALL

View File

@ -1,4 +1,9 @@
set(DEP_CMAKE_OPTS "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
include("deps-unix-common.cmake")
ExternalProject_Add(dep_boost
EXCLUDE_FROM_ALL 1
URL "https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz"
@ -9,74 +14,17 @@ ExternalProject_Add(dep_boost
"--prefix=${DESTDIR}/usr/local"
BUILD_COMMAND ./b2
-j ${NPROC}
--reconfigure
link=static
variant=release
threading=multi
boost.locale.icu=off
cxxflags=-fPIC cflags=-fPIC
cflags=-fPIC
cxxflags=-fPIC
install
INSTALL_COMMAND "" # b2 does that already
)
ExternalProject_Add(dep_tbb
EXCLUDE_FROM_ALL 1
URL "https://github.com/wjakob/tbb/archive/a0dc9bf76d0120f917b641ed095360448cabc85b.tar.gz"
URL_HASH SHA256=0545cb6033bd1873fcae3ea304def720a380a88292726943ae3b9b207f322efe
CMAKE_ARGS -DTBB_BUILD_SHARED=OFF
-DTBB_BUILD_TESTS=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
)
ExternalProject_Add(dep_gtest
EXCLUDE_FROM_ALL 1
URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c
CMAKE_ARGS -DBUILD_GMOCK=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
)
ExternalProject_Add(dep_nlopt
EXCLUDE_FROM_ALL 1
URL "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz"
URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_ARGS
-DNLOPT_PYTHON=OFF
-DNLOPT_OCTAVE=OFF
-DNLOPT_MATLAB=OFF
-DNLOPT_GUILE=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
INSTALL_COMMAND ""
)
ExternalProject_Add(dep_zlib
EXCLUDE_FROM_ALL 1
URL "https://zlib.net/zlib-1.2.11.tar.xz"
URL_HASH SHA256=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_ARGS
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
INSTALL_COMMAND ""
)
ExternalProject_Add(dep_libpng
DEPENDS dep_zlib
EXCLUDE_FROM_ALL 1
URL "http://prdownloads.sourceforge.net/libpng/libpng-1.6.35.tar.xz?download"
URL_HASH SHA256=23912ec8c9584917ed9b09c5023465d71709dce089be503c7867fec68a93bcd7
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_ARGS
-DPNG_SHARED=OFF
-DPNG_TESTS=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
INSTALL_COMMAND ""
)
ExternalProject_Add(dep_libopenssl
EXCLUDE_FROM_ALL 1
URL "https://github.com/openssl/openssl/archive/OpenSSL_1_1_0g.tar.gz"
@ -145,6 +93,7 @@ ExternalProject_Add(dep_wxwidgets
URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2"
URL_HASH SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e
BUILD_IN_SOURCE 1
PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/wxwidgets-pngprefix.h" src/png/pngprefix.h
CONFIGURE_COMMAND ./configure
"--prefix=${DESTDIR}/usr/local"
--disable-shared
@ -162,6 +111,8 @@ ExternalProject_Add(dep_wxwidgets
--disable-precomp-headers
--enable-debug_info
--enable-debug_gdb
--disable-debug
--disable-debug_flag
BUILD_COMMAND make "-j${NPROC}" && make -C locale allmo
INSTALL_COMMAND make install
)

103
deps/deps-macos.cmake vendored Normal file
View File

@ -0,0 +1,103 @@
set(DEP_CMAKE_OPTS
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
"-DCMAKE_OSX_SYSROOT=${DEPS_OSX_SYSROOT}"
"-DCMAKE_OSX_DEPLOYMENT_TARGET=${DEPS_OSX_TARGET}"
)
include("deps-unix-common.cmake")
ExternalProject_Add(dep_boost
EXCLUDE_FROM_ALL 1
URL "https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz"
URL_HASH SHA256=bd0df411efd9a585e5a2212275f8762079fed8842264954675a4fddc46cfcf60
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ./bootstrap.sh
--with-libraries=system,filesystem,thread,log,locale,regex
"--prefix=${DESTDIR}/usr/local"
BUILD_COMMAND ./b2
-j ${NPROC}
--reconfigure
link=static
variant=release
threading=multi
boost.locale.icu=off
"cflags=cflags=-fPIC -mmacosx-version-min=${DEPS_OSX_TARGET}"
"cxxflags=cxxflags=-fPIC -mmacosx-version-min=${DEPS_OSX_TARGET}"
install
INSTALL_COMMAND "" # b2 does that already
)
ExternalProject_Add(dep_libcurl
EXCLUDE_FROM_ALL 1
URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz"
URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ./configure
--enable-static
--disable-shared
"--with-ssl=${DESTDIR}/usr/local"
--with-pic
--enable-ipv6
--enable-versioned-symbols
--enable-threaded-resolver
--with-darwinssl
--without-ssl # disables OpenSSL
--disable-ldap
--disable-ldaps
--disable-manual
--disable-rtsp
--disable-dict
--disable-telnet
--disable-pop3
--disable-imap
--disable-smb
--disable-smtp
--disable-gopher
--disable-crypto-auth
--without-gssapi
--without-libpsl
--without-libidn2
--without-gnutls
--without-polarssl
--without-mbedtls
--without-cyassl
--without-nss
--without-axtls
--without-brotli
--without-libmetalink
--without-libssh
--without-libssh2
--without-librtmp
--without-nghttp2
--without-zsh-functions-dir
BUILD_COMMAND make "-j${NPROC}"
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
)
ExternalProject_Add(dep_wxwidgets
EXCLUDE_FROM_ALL 1
URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2"
URL_HASH SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e
BUILD_IN_SOURCE 1
PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/wxwidgets-pngprefix.h" src/png/pngprefix.h
CONFIGURE_COMMAND ./configure
"--prefix=${DESTDIR}/usr/local"
--disable-shared
--with-osx_cocoa
"--with-macosx-version-min=${DEPS_OSX_TARGET}"
"--with-macosx-sdk=${DEPS_OSX_SYSROOT}"
--with-opengl
--with-regex=builtin
--with-libpng=builtin
--with-libxpm=builtin
--with-libjpeg=builtin
--with-libtiff=builtin
--with-zlib=builtin
--with-expat=builtin
--disable-debug
--disable-debug_flag
BUILD_COMMAND make "-j${NPROC}" && make -C locale allmo
INSTALL_COMMAND make install
)

60
deps/deps-unix-common.cmake vendored Normal file
View File

@ -0,0 +1,60 @@
# The unix common part expects DEP_CMAKE_OPTS to be set
ExternalProject_Add(dep_tbb
EXCLUDE_FROM_ALL 1
URL "https://github.com/wjakob/tbb/archive/a0dc9bf76d0120f917b641ed095360448cabc85b.tar.gz"
URL_HASH SHA256=0545cb6033bd1873fcae3ea304def720a380a88292726943ae3b9b207f322efe
CMAKE_ARGS
-DTBB_BUILD_SHARED=OFF
-DTBB_BUILD_TESTS=OFF
${DEP_CMAKE_OPTS}
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
)
ExternalProject_Add(dep_gtest
EXCLUDE_FROM_ALL 1
URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c
CMAKE_ARGS -DBUILD_GMOCK=OFF ${DEP_CMAKE_OPTS}
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
)
ExternalProject_Add(dep_nlopt
EXCLUDE_FROM_ALL 1
URL "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz"
URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_ARGS
-DNLOPT_PYTHON=OFF
-DNLOPT_OCTAVE=OFF
-DNLOPT_MATLAB=OFF
-DNLOPT_GUILE=OFF
${DEP_CMAKE_OPTS}
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
INSTALL_COMMAND ""
)
ExternalProject_Add(dep_zlib
EXCLUDE_FROM_ALL 1
URL "https://zlib.net/zlib-1.2.11.tar.xz"
URL_HASH SHA256=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_ARGS ${DEP_CMAKE_OPTS}
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
INSTALL_COMMAND ""
)
ExternalProject_Add(dep_libpng
DEPENDS dep_zlib
EXCLUDE_FROM_ALL 1
URL "http://prdownloads.sourceforge.net/libpng/libpng-1.6.35.tar.xz?download"
URL_HASH SHA256=23912ec8c9584917ed9b09c5023465d71709dce089be503c7867fec68a93bcd7
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_ARGS
-DPNG_SHARED=OFF
-DPNG_TESTS=OFF
${DEP_CMAKE_OPTS}
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
INSTALL_COMMAND ""
)

View File

@ -68,7 +68,8 @@ ExternalProject_Add(dep_gtest
URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_ARGS -DBUILD_GMOCK=OFF
CMAKE_ARGS
-DBUILD_GMOCK=OFF
-Dgtest_force_shared_crt=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
"-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"

View File

@ -163,6 +163,13 @@ if (MSVC)
VERBATIM
)
endif ()
elseif (XCODE)
# Because of Debug/Release/etc. configurations (similar to MSVC) the slic3r binary is located in an extra level
add_custom_command(TARGET slic3r POST_BUILD
COMMAND ln -sf "${SLIC3R_RESOURCES_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/resources"
COMMENT "Symlinking the resources directory into the build tree"
VERBATIM
)
else ()
add_custom_command(TARGET slic3r POST_BUILD
COMMAND ln -sf "${SLIC3R_RESOURCES_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/../resources"