CMakeLists.txt 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. option(DEP_WX_STABLE "Build against wxWidgets stable 3.0 as opposed to default 3.1 (Linux only)" OFF)
  33. message(STATUS "Slic3r deps DESTDIR: ${DESTDIR}")
  34. message(STATUS "Slic3r deps debug build: ${DEP_DEBUG}")
  35. if (MSVC)
  36. if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
  37. message(STATUS "\nDetected 64-bit compiler => building 64-bit deps bundle\n")
  38. set(DEPS_BITS 64)
  39. include("deps-windows.cmake")
  40. elseif ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
  41. message(STATUS "\nDetected 32-bit compiler => building 32-bit deps bundle\n")
  42. set(DEPS_BITS 32)
  43. include("deps-windows.cmake")
  44. else ()
  45. message(FATAL_ERROR "Unable to detect architecture")
  46. endif ()
  47. elseif (APPLE)
  48. message("OS X SDK Path: ${CMAKE_OSX_SYSROOT}")
  49. if (CMAKE_OSX_DEPLOYMENT_TARGET)
  50. set(DEP_OSX_TARGET "${CMAKE_OSX_DEPLOYMENT_TARGET}")
  51. message("OS X Deployment Target: ${DEP_OSX_TARGET}")
  52. else ()
  53. # Attempt to infer the SDK version from the CMAKE_OSX_SYSROOT,
  54. # this is done because wxWidgets need the min version explicitly set
  55. string(REGEX MATCH "[0-9]+[.][0-9]+[.]sdk$" DEP_OSX_TARGET "${CMAKE_OSX_SYSROOT}")
  56. string(REGEX MATCH "^[0-9]+[.][0-9]+" DEP_OSX_TARGET "${DEP_OSX_TARGET}")
  57. if (NOT DEP_OSX_TARGET)
  58. message(FATAL_ERROR "Could not determine OS X SDK version. Please use -DCMAKE_OSX_DEPLOYMENT_TARGET=<version>")
  59. endif ()
  60. message("OS X Deployment Target (inferred from default): ${DEP_OSX_TARGET}")
  61. endif ()
  62. include("deps-macos.cmake")
  63. else ()
  64. include("deps-linux.cmake")
  65. endif()
  66. add_custom_target(deps ALL
  67. DEPENDS
  68. dep_boost
  69. dep_tbb
  70. dep_libcurl
  71. dep_wxwidgets
  72. dep_gtest
  73. dep_nlopt
  74. dep_libpng
  75. )
  76. # Note: I'm not using any of the LOG_xxx options in ExternalProject_Add() commands
  77. # because they seem to generate bogus build files (possibly a bug in ExternalProject).