2018-10-16 09:06:26 +00:00
|
|
|
|
#
|
2019-05-13 13:14:33 +00:00
|
|
|
|
# This CMake project downloads, configures and builds PrusaSlicer dependencies on Unix and Windows.
|
2018-10-16 09:06:26 +00:00
|
|
|
|
#
|
|
|
|
|
# When using this script, it's recommended to perform an out-of-source build using CMake.
|
|
|
|
|
#
|
|
|
|
|
# All the dependencies are installed in a `destdir` directory in the root of the build directory,
|
|
|
|
|
# in a traditional Unix-style prefix structure. The destdir can be used directly by CMake
|
2019-05-13 13:14:33 +00:00
|
|
|
|
# when building PrusaSlicer - to do this, set the CMAKE_PREFIX_PATH to ${destdir}/usr/local.
|
|
|
|
|
# Warning: On UNIX/Linux, you also need to set -DSLIC3R_STATIC=1 when building PrusaSlicer.
|
2018-10-16 09:06:26 +00:00
|
|
|
|
#
|
|
|
|
|
# For better clarity of console output, it's recommended to _not_ use a parallelized build
|
|
|
|
|
# for the top-level command, ie. use `make -j 1` or `ninja -j 1` to force single-threaded top-level
|
|
|
|
|
# build. This doesn't degrade performance as individual dependencies are built in parallel fashion
|
2018-10-23 17:08:26 +00:00
|
|
|
|
# if supported by the dependency.
|
2018-10-16 09:06:26 +00:00
|
|
|
|
#
|
|
|
|
|
# On Windows, architecture (64 vs 32 bits) is judged based on the compiler variant.
|
|
|
|
|
# To build dependencies for either 64 or 32 bit OS, use the respective compiler command line.
|
|
|
|
|
#
|
2018-12-03 09:48:06 +00:00
|
|
|
|
# WARNING: On UNIX platforms wxWidgets hardcode the destdir path into its `wx-conffig` utility,
|
|
|
|
|
# therefore, unfortunatelly, the installation cannot be copied/moved elsewhere without re-installing wxWidgets.
|
|
|
|
|
#
|
2018-10-16 09:06:26 +00:00
|
|
|
|
|
2019-05-13 13:14:33 +00:00
|
|
|
|
project(PrusaSlicer-deps)
|
2018-10-12 12:19:08 +00:00
|
|
|
|
cmake_minimum_required(VERSION 3.2)
|
|
|
|
|
|
|
|
|
|
include(ExternalProject)
|
|
|
|
|
include(ProcessorCount)
|
2018-11-30 19:52:45 +00:00
|
|
|
|
|
2018-10-12 12:19:08 +00:00
|
|
|
|
ProcessorCount(NPROC)
|
|
|
|
|
if (NPROC EQUAL 0)
|
|
|
|
|
set(NPROC 1)
|
|
|
|
|
endif ()
|
|
|
|
|
|
2018-10-23 17:08:26 +00:00
|
|
|
|
set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory")
|
2021-03-23 18:01:18 +00:00
|
|
|
|
set(DEP_DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Path for downloaded source packages.")
|
2019-03-19 14:02:50 +00:00
|
|
|
|
|
2018-11-30 19:52:45 +00:00
|
|
|
|
option(DEP_DEBUG "Build debug variants (only applicable on Windows)" ON)
|
2020-04-28 07:56:54 +00:00
|
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
|
option(DEP_WX_GTK3 "Build wxWidgets against GTK3" OFF)
|
|
|
|
|
endif()
|
2019-06-20 10:54:43 +00:00
|
|
|
|
|
2019-06-26 15:06:41 +00:00
|
|
|
|
# On developer machines, it can be enabled to speed up compilation and suppress warnings coming from IGL.
|
|
|
|
|
# FIXME:
|
|
|
|
|
# Enabling this option is not safe. IGL will compile itself with its own version of Eigen while
|
|
|
|
|
# Slic3r compiles with a different version which will cause runtime errors.
|
|
|
|
|
# option(DEP_BUILD_IGL_STATIC "Build IGL as a static library. Might cause link errors and increase binary size." OFF)
|
2018-10-23 17:08:26 +00:00
|
|
|
|
|
2019-05-13 13:14:33 +00:00
|
|
|
|
message(STATUS "PrusaSlicer deps DESTDIR: ${DESTDIR}")
|
2021-03-23 18:01:18 +00:00
|
|
|
|
message(STATUS "PrusaSlicer dowload dir for source packages: ${DEP_DOWNLOAD_DIR}")
|
2019-05-13 13:14:33 +00:00
|
|
|
|
message(STATUS "PrusaSlicer deps debug build: ${DEP_DEBUG}")
|
2018-10-16 07:20:56 +00:00
|
|
|
|
|
2019-12-11 12:59:17 +00:00
|
|
|
|
find_package(Git REQUIRED)
|
|
|
|
|
|
2021-03-24 14:40:41 +00:00
|
|
|
|
# The default command line for patching. Only works for newer
|
|
|
|
|
set(PATCH_CMD ${GIT_EXECUTABLE} apply --verbose --ignore-space-change --whitespace=fix)
|
|
|
|
|
|
2019-12-17 15:50:00 +00:00
|
|
|
|
get_property(_is_multi GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
2019-12-11 12:59:17 +00:00
|
|
|
|
|
2021-08-26 08:38:42 +00:00
|
|
|
|
if (NOT _is_multi AND NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
|
message(STATUS "Forcing CMAKE_BUILD_TYPE to Release as it was not specified.")
|
|
|
|
|
endif ()
|
|
|
|
|
|
2019-12-10 10:08:54 +00:00
|
|
|
|
function(prusaslicer_add_cmake_project projectname)
|
2019-12-11 11:24:21 +00:00
|
|
|
|
cmake_parse_arguments(P_ARGS "" "INSTALL_DIR;BUILD_COMMAND;INSTALL_COMMAND" "CMAKE_ARGS" ${ARGN})
|
2019-12-10 10:08:54 +00:00
|
|
|
|
|
|
|
|
|
set(_configs_line -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE})
|
2019-12-11 11:24:21 +00:00
|
|
|
|
if (_is_multi OR MSVC)
|
2019-12-10 10:08:54 +00:00
|
|
|
|
set(_configs_line "")
|
|
|
|
|
endif ()
|
|
|
|
|
|
2019-12-11 11:24:21 +00:00
|
|
|
|
set(_gen "")
|
|
|
|
|
set(_build_j "-j${NPROC}")
|
|
|
|
|
if (MSVC)
|
2019-12-12 12:09:57 +00:00
|
|
|
|
set(_gen CMAKE_GENERATOR "${DEP_MSVC_GEN}" CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}")
|
2019-12-11 11:24:21 +00:00
|
|
|
|
set(_build_j "/m")
|
|
|
|
|
endif ()
|
|
|
|
|
|
2019-12-10 10:08:54 +00:00
|
|
|
|
ExternalProject_Add(
|
|
|
|
|
dep_${projectname}
|
|
|
|
|
EXCLUDE_FROM_ALL ON
|
|
|
|
|
INSTALL_DIR ${DESTDIR}/usr/local
|
2021-03-23 18:01:18 +00:00
|
|
|
|
DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/${projectname}
|
2019-12-11 11:24:21 +00:00
|
|
|
|
${_gen}
|
|
|
|
|
CMAKE_ARGS
|
2019-12-10 10:08:54 +00:00
|
|
|
|
-DCMAKE_INSTALL_PREFIX:STRING=${DESTDIR}/usr/local
|
2019-12-11 12:51:16 +00:00
|
|
|
|
-DCMAKE_MODULE_PATH:STRING=${PROJECT_SOURCE_DIR}/../cmake/modules
|
2019-12-10 10:08:54 +00:00
|
|
|
|
-DCMAKE_PREFIX_PATH:STRING=${DESTDIR}/usr/local
|
2019-12-10 11:50:52 +00:00
|
|
|
|
-DCMAKE_DEBUG_POSTFIX:STRING=d
|
2019-12-10 10:08:54 +00:00
|
|
|
|
-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
|
|
|
|
|
-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
|
2021-03-19 18:03:31 +00:00
|
|
|
|
-DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
|
2019-12-10 10:08:54 +00:00
|
|
|
|
-DBUILD_SHARED_LIBS:BOOL=OFF
|
2019-12-11 11:24:21 +00:00
|
|
|
|
"${_configs_line}"
|
2019-12-10 11:50:52 +00:00
|
|
|
|
${DEP_CMAKE_OPTS}
|
2019-12-10 10:08:54 +00:00
|
|
|
|
${P_ARGS_CMAKE_ARGS}
|
|
|
|
|
${P_ARGS_UNPARSED_ARGUMENTS}
|
2019-12-11 11:24:21 +00:00
|
|
|
|
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release -- ${_build_j}
|
|
|
|
|
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config Release
|
2019-12-10 10:08:54 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
endfunction(prusaslicer_add_cmake_project)
|
|
|
|
|
|
|
|
|
|
|
2018-10-16 09:06:26 +00:00
|
|
|
|
if (MSVC)
|
|
|
|
|
if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
|
|
|
|
|
message(STATUS "\nDetected 64-bit compiler => building 64-bit deps bundle\n")
|
|
|
|
|
set(DEPS_BITS 64)
|
|
|
|
|
include("deps-windows.cmake")
|
|
|
|
|
elseif ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
|
|
|
|
|
message(STATUS "\nDetected 32-bit compiler => building 32-bit deps bundle\n")
|
|
|
|
|
set(DEPS_BITS 32)
|
|
|
|
|
include("deps-windows.cmake")
|
|
|
|
|
else ()
|
|
|
|
|
message(FATAL_ERROR "Unable to detect architecture")
|
|
|
|
|
endif ()
|
2018-11-30 19:52:45 +00:00
|
|
|
|
elseif (APPLE)
|
2019-01-10 12:49:06 +00:00
|
|
|
|
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=<version>")
|
|
|
|
|
endif ()
|
|
|
|
|
|
2019-10-14 14:23:03 +00:00
|
|
|
|
message("OS X Deployment Target (inferred from SDK): ${DEP_OSX_TARGET}")
|
2019-01-10 12:49:06 +00:00
|
|
|
|
endif ()
|
2018-11-30 19:52:45 +00:00
|
|
|
|
|
|
|
|
|
include("deps-macos.cmake")
|
2019-08-16 14:17:37 +00:00
|
|
|
|
elseif (MINGW)
|
|
|
|
|
message(STATUS "Building for MinGW...")
|
|
|
|
|
include("deps-mingw.cmake")
|
|
|
|
|
else()
|
2018-11-30 19:52:45 +00:00
|
|
|
|
include("deps-linux.cmake")
|
2018-10-12 12:19:08 +00:00
|
|
|
|
endif()
|
2018-10-15 15:28:05 +00:00
|
|
|
|
|
2020-04-28 07:56:54 +00:00
|
|
|
|
set(ZLIB_PKG "")
|
|
|
|
|
if (NOT ZLIB_FOUND)
|
|
|
|
|
include(ZLIB/ZLIB.cmake)
|
|
|
|
|
set(ZLIB_PKG dep_ZLIB)
|
|
|
|
|
endif ()
|
|
|
|
|
set(PNG_PKG "")
|
|
|
|
|
if (NOT PNG_FOUND)
|
|
|
|
|
include(PNG/PNG.cmake)
|
|
|
|
|
set(PNG_PKG dep_PNG)
|
|
|
|
|
endif ()
|
|
|
|
|
set(EXPAT_PKG "")
|
|
|
|
|
if (NOT EXPAT_FOUND)
|
|
|
|
|
include(EXPAT/EXPAT.cmake)
|
|
|
|
|
set(EXPAT_PKG dep_EXPAT)
|
|
|
|
|
endif ()
|
|
|
|
|
|
2021-03-22 13:35:49 +00:00
|
|
|
|
set(DEP_Boost_COMPONENTS system iostreams filesystem thread log locale regex date_time)
|
|
|
|
|
include(Boost/Boost.cmake)
|
|
|
|
|
|
2021-03-22 12:36:42 +00:00
|
|
|
|
# The order of includes respects the dependencies between libraries
|
2021-03-22 12:00:14 +00:00
|
|
|
|
include(Cereal/Cereal.cmake)
|
2021-03-22 12:07:08 +00:00
|
|
|
|
include(Qhull/Qhull.cmake)
|
2019-12-10 12:51:53 +00:00
|
|
|
|
include(GLEW/GLEW.cmake)
|
|
|
|
|
include(OpenCSG/OpenCSG.cmake)
|
2021-03-22 12:36:42 +00:00
|
|
|
|
|
|
|
|
|
include(TBB/TBB.cmake)
|
|
|
|
|
|
|
|
|
|
include(Blosc/Blosc.cmake)
|
|
|
|
|
include(OpenEXR/OpenEXR.cmake)
|
|
|
|
|
include(OpenVDB/OpenVDB.cmake)
|
|
|
|
|
|
2019-12-10 11:50:52 +00:00
|
|
|
|
include(GMP/GMP.cmake)
|
|
|
|
|
include(MPFR/MPFR.cmake)
|
|
|
|
|
include(CGAL/CGAL.cmake)
|
2021-03-22 12:36:42 +00:00
|
|
|
|
|
2021-03-19 18:03:31 +00:00
|
|
|
|
include(NLopt/NLopt.cmake)
|
2021-03-22 12:36:42 +00:00
|
|
|
|
|
2021-03-20 15:16:50 +00:00
|
|
|
|
include(OpenSSL/OpenSSL.cmake)
|
2022-05-16 12:02:46 +00:00
|
|
|
|
|
|
|
|
|
set(CURL_PKG "")
|
|
|
|
|
if (NOT CURL_FOUND)
|
|
|
|
|
include(CURL/CURL.cmake)
|
|
|
|
|
set(CURL_PKG dep_CURL)
|
|
|
|
|
endif ()
|
2019-12-10 11:50:52 +00:00
|
|
|
|
|
2021-03-23 18:29:48 +00:00
|
|
|
|
include(JPEG/JPEG.cmake)
|
|
|
|
|
include(TIFF/TIFF.cmake)
|
2021-03-22 12:36:42 +00:00
|
|
|
|
include(wxWidgets/wxWidgets.cmake)
|
2020-05-07 07:13:20 +00:00
|
|
|
|
|
2020-06-27 06:44:13 +00:00
|
|
|
|
set(_dep_list
|
2021-03-22 13:35:49 +00:00
|
|
|
|
dep_Boost
|
2021-03-20 15:15:28 +00:00
|
|
|
|
dep_TBB
|
2022-05-16 12:02:46 +00:00
|
|
|
|
${CURL_PKG}
|
2020-06-27 06:44:13 +00:00
|
|
|
|
dep_wxWidgets
|
2021-03-22 12:00:14 +00:00
|
|
|
|
dep_Cereal
|
2021-03-19 18:03:31 +00:00
|
|
|
|
dep_NLopt
|
2021-03-22 12:36:42 +00:00
|
|
|
|
dep_OpenVDB
|
2020-06-27 06:44:13 +00:00
|
|
|
|
dep_OpenCSG
|
|
|
|
|
dep_CGAL
|
2022-01-19 13:18:17 +00:00
|
|
|
|
dep_Qhull
|
2020-06-27 06:44:13 +00:00
|
|
|
|
${PNG_PKG}
|
|
|
|
|
${ZLIB_PKG}
|
|
|
|
|
${EXPAT_PKG}
|
2019-03-25 13:06:28 +00:00
|
|
|
|
)
|
|
|
|
|
|
2022-01-19 13:18:17 +00:00
|
|
|
|
# if (NOT MSVC)
|
2020-06-27 06:44:13 +00:00
|
|
|
|
# Not working, static build has different Eigen
|
|
|
|
|
#list(APPEND _dep_list "dep_libigl")
|
2022-01-19 13:18:17 +00:00
|
|
|
|
# endif()
|
2018-10-16 09:06:26 +00:00
|
|
|
|
|
2020-06-27 06:44:13 +00:00
|
|
|
|
add_custom_target(deps ALL DEPENDS ${_dep_list})
|
|
|
|
|
|
2018-10-15 15:28:05 +00:00
|
|
|
|
# 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).
|