diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 386320d81..1e025adac 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -51,11 +51,22 @@ if (MSVC) 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" - ) + message("OS X SDK Path: ${CMAKE_OSX_SYSROOT}") + if (CMAKE_OSX_DEPLOYMENT_TARGET) + set(DEP_OSX_TARGET "${CMAKE_OSX_DEPLOYMENT_TARGET}") + message("OS X Deployment Target: ${DEP_OSX_TARGET}") + else () + # Attempt to infer the SDK version from the CMAKE_OSX_SYSROOT, + # this is done because wxWidgets need the min version explicitly set + string(REGEX MATCH "[0-9]+[.][0-9]+[.]sdk$" DEP_OSX_TARGET "${CMAKE_OSX_SYSROOT}") + string(REGEX MATCH "^[0-9]+[.][0-9]+" DEP_OSX_TARGET "${DEP_OSX_TARGET}") + + if (NOT DEP_OSX_TARGET) + message(FATAL_ERROR "Could not determine OS X SDK version. Please use -DCMAKE_OSX_DEPLOYMENT_TARGET=") + endif () + + message("OS X Deployment Target (inferred from default): ${DEP_OSX_TARGET}") + endif () include("deps-macos.cmake") else () diff --git a/deps/deps-linux.cmake b/deps/deps-linux.cmake index bf39f59e7..125553f77 100644 --- a/deps/deps-linux.cmake +++ b/deps/deps-linux.cmake @@ -25,6 +25,19 @@ ExternalProject_Add(dep_boost INSTALL_COMMAND "" # b2 does that already ) +ExternalProject_Add(dep_libpng + EXCLUDE_FROM_ALL 1 + URL "https://github.com/glennrp/libpng/archive/v1.6.36.tar.gz" + URL_HASH SHA256=5bef5a850a9255365a2dc344671b7e9ef810de491bd479c2506ac3c337e2d84f + CMAKE_GENERATOR "${DEP_MSVC_GEN}" + CMAKE_ARGS + -DPNG_SHARED=OFF + -DPNG_TESTS=OFF + ${DEP_CMAKE_OPTS} + 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" diff --git a/deps/deps-macos.cmake b/deps/deps-macos.cmake index 720ec50d0..4676b14fc 100644 --- a/deps/deps-macos.cmake +++ b/deps/deps-macos.cmake @@ -1,13 +1,24 @@ +# This ensures dependencies don't use SDK features which are not available in the version specified by Deployment target +# That can happen when one uses a recent SDK but specifies an older Deployment target +set(DEP_WERRORS_SDK "-Werror=partial-availability -Werror=unguarded-availability -Werror=unguarded-availability-new") + set(DEP_CMAKE_OPTS "-DCMAKE_POSITION_INDEPENDENT_CODE=ON" - "-DCMAKE_OSX_SYSROOT=${DEPS_OSX_SYSROOT}" - "-DCMAKE_OSX_DEPLOYMENT_TARGET=${DEPS_OSX_TARGET}" + "-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}" + "-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}" + "-DCMAKE_CXX_FLAGS=${DEP_WERRORS_SDK}" + "-DCMAKE_C_FLAGS=${DEP_WERRORS_SDK}" ) include("deps-unix-common.cmake") +set(DEP_BOOST_OSX_TARGET "") +if (CMAKE_OSX_DEPLOYMENT_TARGET) + set(DEP_BOOST_OSX_TARGET "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") +endif () + 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" @@ -23,8 +34,8 @@ ExternalProject_Add(dep_boost variant=release threading=multi boost.locale.icu=off - "cflags=-fPIC -mmacosx-version-min=${DEPS_OSX_TARGET}" - "cxxflags=-fPIC -mmacosx-version-min=${DEPS_OSX_TARGET}" + "cflags=-fPIC ${DEP_BOOST_OSX_TARGET}" + "cxxflags=-fPIC ${DEP_BOOST_OSX_TARGET}" install INSTALL_COMMAND "" # b2 does that already ) @@ -76,18 +87,32 @@ ExternalProject_Add(dep_libcurl INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" ) +ExternalProject_Add(dep_libpng + EXCLUDE_FROM_ALL 1 + URL "https://github.com/glennrp/libpng/archive/v1.6.36.tar.gz" + URL_HASH SHA256=5bef5a850a9255365a2dc344671b7e9ef810de491bd479c2506ac3c337e2d84f + CMAKE_GENERATOR "${DEP_MSVC_GEN}" + CMAKE_ARGS + -DPNG_SHARED=OFF + -DPNG_TESTS=OFF + ${DEP_CMAKE_OPTS} + INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" + INSTALL_COMMAND "" +) + + 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 + URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.2/wxWidgets-3.1.2.tar.bz2" + URL_HASH SHA256=4cb8d23d70f9261debf7d6cfeca667fc0a7d2b6565adb8f1c484f9b674f1f27a BUILD_IN_SOURCE 1 PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/wxwidgets-pngprefix.h" src/png/pngprefix.h - CONFIGURE_COMMAND ./configure + CONFIGURE_COMMAND env "CXXFLAGS=${DEP_WERRORS_SDK}" "CFLAGS=${DEP_WERRORS_SDK}" ./configure "--prefix=${DESTDIR}/usr/local" --disable-shared --with-osx_cocoa - "--with-macosx-version-min=${DEPS_OSX_TARGET}" - "--with-macosx-sdk=${DEPS_OSX_SYSROOT}" + --with-macosx-sdk=${CMAKE_OSX_SYSROOT} + "--with-macosx-version-min=${DEP_OSX_TARGET}" --with-opengl --with-regex=builtin --with-libpng=builtin diff --git a/deps/deps-unix-common.cmake b/deps/deps-unix-common.cmake index e4c718d21..6c0a1b182 100644 --- a/deps/deps-unix-common.cmake +++ b/deps/deps-unix-common.cmake @@ -35,16 +35,3 @@ ExternalProject_Add(dep_nlopt INSTALL_COMMAND make install "DESTDIR=${DESTDIR}" INSTALL_COMMAND "" ) - -ExternalProject_Add(dep_libpng - 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 "" -) diff --git a/deps/deps-windows.cmake b/deps/deps-windows.cmake index 17dfae8bd..ec61cb422 100644 --- a/deps/deps-windows.cmake +++ b/deps/deps-windows.cmake @@ -155,8 +155,8 @@ endif () 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 + URL "https://github.com/glennrp/libpng/archive/v1.6.36.tar.gz" + URL_HASH SHA256=5bef5a850a9255365a2dc344671b7e9ef810de491bd479c2506ac3c337e2d84f CMAKE_GENERATOR "${DEP_MSVC_GEN}" CMAKE_ARGS -DPNG_SHARED=OFF diff --git a/doc/How to build - Mac OS.md b/doc/How to build - Mac OS.md index a2d7cf7fe..a1c8d9049 100644 --- a/doc/How to build - Mac OS.md +++ b/doc/How to build - Mac OS.md @@ -1,26 +1,7 @@ # Building Slic3r PE on Mac OS -To build Slic3r PE on Mac OS, you will need to install XCode and an appropriate SDK. -You will also need [CMake](https://cmake.org/) installed (available on Brew) and possibly git. - -Currently Slic3r PE is built against the Mac OS X SDK version 10.9. -Building against older SDKs is unsupported. Building against newer SDKs might work, -but there may be subtle issues, such as dark mode not working very well on Mojave or other GUI problems. - -You can obtain the SDK 10.9 for example [in this repository](https://github.com/phracker/MacOSX-SDKs). -If you don't already have the 10.9 version as part of your Mac OS installation, please download it -and place it into a reachable location. - -The default location for Mac OS SDKs is: - - /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ - -Wherever the 10.9 SDK is, please note down its location, it will be required to build Slic3r. - -On my system, for example, the path to the SDK is - - /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk +To build Slic3r PE on Mac OS, you will need to install XCode, [CMake](https://cmake.org/) (available on Brew) and possibly git. ### Dependencies @@ -30,11 +11,16 @@ Use the following commands to build the dependencies: mkdir build cd build - cmake .. -DDEPS_OSX_SYSROOT= + cmake .. + make This will create a dependencies bundle inside the `build/destdir` directory. You can also customize the bundle output path using the `-DDESTDIR=` option passed to `cmake`. +**Warning**: Once the dependency bundle is installed in a destdir, the destdir cannot be moved elsewhere. +(This is because wxWidgets hardcode the installation path.) + + ### Building Slic3r If dependencies built without an error, you can proceed to build Slic3r itself. @@ -42,7 +28,7 @@ Go back to top level Slic3r sources directory and use these commands: mkdir build cd build - cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_SYSROOT= + cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" The `CMAKE_PREFIX_PATH` is the path to the dependencies bundle but with `/usr/local` appended - if you set a custom path using the `DESTDIR` option, you will need to change this accordingly. **Warning:** the `CMAKE_PREFIX_PATH` needs to be an absolute path. @@ -56,7 +42,22 @@ where `N` is the number of CPU cores, so, for example `make -j4` for a 4-core ma Alternatively, if you would like to use XCode GUI, modify the `cmake` command to include the `-GXcode` option: - cmake .. -GXcode -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_SYSROOT= + cmake .. -GXcode -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" and then open the `Slic3r.xcodeproj` file. This should open up XCode where you can perform build using the GUI or perform other tasks. + +### Note on Mac OS X SDKs + +By default Slic3r builds against whichever SDK is the default on the current system. + +This can be customized. The `CMAKE_OSX_SYSROOT` option sets the path to the SDK directory location +and the `CMAKE_OSX_DEPLOYMENT_TARGET` option sets the target OS X system version (eg. `10.14` or similar). +Note you can set just one value and the other will be guessed automatically. +In case you set both, the two settings need to agree with each other. (Building with a lower deployment target +is currently unsupported because some of the dependencies don't support this, most notably wxWidgets.) + +Please note that the `CMAKE_OSX_DEPLOYMENT_TARGET` and `CMAKE_OSX_SYSROOT` options need to be set the same +on both the dependencies bundle as well as Slic3r PE itself. + +Official Mac Slic3r builds are currently built against SDK 10.9 to ensure compatibility with older Macs.