CMakeLists.txt 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #
  2. # This CMake project downloads, configures and builds Slic3r PE dependencies on Unix and Windows.
  3. #
  4. # When using this script, it's recommended to perform an out-of-source build using CMake.
  5. #
  6. # All the dependencies are installed in a `destdir` directory in the root of the build directory,
  7. # in a traditional Unix-style prefix structure. The destdir can be used directly by CMake
  8. # when building Slic3r - to do this, set the CMAKE_PREFIX_PATH to ${destdir}/usr/local.
  9. # Warning: On UNIX/Linux, you also need to set -DSLIC3R_STATIC=1 when building Slic3r.
  10. #
  11. # For better clarity of console output, it's recommended to _not_ use a parallelized build
  12. # for the top-level command, ie. use `make -j 1` or `ninja -j 1` to force single-threaded top-level
  13. # build. This doesn't degrade performance as individual dependencies are built in parallel fashion
  14. # if supported by the dependency.
  15. #
  16. # On Windows, architecture (64 vs 32 bits) is judged based on the compiler variant.
  17. # To build dependencies for either 64 or 32 bit OS, use the respective compiler command line.
  18. #
  19. # WARNING: On UNIX platforms wxWidgets hardcode the destdir path into its `wx-conffig` utility,
  20. # therefore, unfortunatelly, the installation cannot be copied/moved elsewhere without re-installing wxWidgets.
  21. #
  22. project(Slic3r-deps)
  23. cmake_minimum_required(VERSION 3.2)
  24. include(ExternalProject)
  25. include(ProcessorCount)
  26. ProcessorCount(NPROC)
  27. if (NPROC EQUAL 0)
  28. set(NPROC 1)
  29. endif ()
  30. set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory")
  31. option(DEP_DEBUG "Build debug variants (only applicable on Windows)" ON)
  32. message(STATUS "Slic3r deps DESTDIR: ${DESTDIR}")
  33. message(STATUS "Slic3r deps debug build: ${DEP_DEBUG}")
  34. if (MSVC)
  35. if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
  36. message(STATUS "\nDetected 64-bit compiler => building 64-bit deps bundle\n")
  37. set(DEPS_BITS 64)
  38. include("deps-windows.cmake")
  39. elseif ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
  40. message(STATUS "\nDetected 32-bit compiler => building 32-bit deps bundle\n")
  41. set(DEPS_BITS 32)
  42. include("deps-windows.cmake")
  43. else ()
  44. message(FATAL_ERROR "Unable to detect architecture")
  45. endif ()
  46. elseif (APPLE)
  47. set(DEPS_OSX_TARGET "10.9" CACHE STRING "OS X SDK version to build against")
  48. set(DEPS_OSX_SYSROOT
  49. "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${DEPS_OSX_TARGET}.sdk"
  50. CACHE PATH "OS X SDK directory"
  51. )
  52. include("deps-macos.cmake")
  53. else ()
  54. include("deps-linux.cmake")
  55. endif()
  56. add_custom_target(deps ALL
  57. DEPENDS
  58. dep_boost
  59. dep_tbb
  60. dep_libcurl
  61. dep_wxwidgets
  62. dep_gtest
  63. dep_nlopt
  64. dep_libpng
  65. )
  66. # Note: I'm not using any of the LOG_xxx options in ExternalProject_Add() commands
  67. # because they seem to generate bogus build files (possibly a bug in ExternalProject).