CMakeLists.txt 2.8 KB

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