CMakeLists.txt 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # Boost 1.63 requires CMake 3.7 or newer
  2. cmake_minimum_required(VERSION 2.8)
  3. project(Slic3r)
  4. if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  5. message(STATUS "No build type selected, default to Release")
  6. set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE)
  7. endif()
  8. if(DEFINED ENV{SLIC3R_STATIC})
  9. set(SLIC3R_STATIC_INITIAL $ENV{SLIC3R_STATIC})
  10. else()
  11. if (MSVC OR MINGW OR APPLE)
  12. set(SLIC3R_STATIC_INITIAL 1)
  13. else()
  14. set(SLIC3R_STATIC_INITIAL 0)
  15. endif()
  16. endif()
  17. option(SLIC3R_STATIC "Compile Slic3r with static libraries (Boost, TBB, glew)" ${SLIC3R_STATIC_INITIAL})
  18. option(SLIC3R_GUI "Compile Slic3r with GUI components (OpenGL, wxWidgets)" 1)
  19. option(SLIC3R_PRUSACONTROL "Compile Slic3r with the PrusaControl prject file format (requires wxWidgets base library)" 1)
  20. option(SLIC3R_PROFILE "Compile Slic3r with an invasive Shiny profiler" 0)
  21. option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1)
  22. if (MSVC AND SLIC3R_MSVC_COMPILE_PARALLEL)
  23. add_compile_options(/MP)
  24. endif ()
  25. # Find the Perl interpreter, add local-lib to PATH and PERL5LIB environment variables,
  26. # so the locally installed modules (mainly the Alien::wxPerl) will be reached.
  27. if (WIN32)
  28. set(ENV_PATH_SEPARATOR ";")
  29. else()
  30. set(ENV_PATH_SEPARATOR ":")
  31. endif()
  32. set(ENV{PATH} "${PROJECT_SOURCE_DIR}/local-lib/bin${ENV_PATH_SEPARATOR}$ENV{PATH}")
  33. set(ENV{PERL5LIB} "${PROJECT_SOURCE_DIR}/local-lib/lib/perl${ENV_PATH_SEPARATOR}$ENV{PERL5LIB}")
  34. message("PATH: $ENV{PATH}")
  35. message("PERL5LIB: $ENV{PERL5LIB}")
  36. find_package(Perl REQUIRED)
  37. # CMAKE_PREFIX_PATH is used to point CMake to the remaining dependencies (Boost, TBB, ...)
  38. # We pick it from environment if it is not defined in another way
  39. if(NOT DEFINED CMAKE_PREFIX_PATH)
  40. if(DEFINED ENV{CMAKE_PREFIX_PATH})
  41. set(CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
  42. endif()
  43. endif()
  44. # WIN10SDK_PATH is used to point CMake to the WIN10 SDK installation directory.
  45. # We pick it from environment if it is not defined in another way
  46. if(WIN32)
  47. if(NOT DEFINED WIN10SDK_PATH)
  48. if(DEFINED ENV{WIN10SDK_PATH})
  49. set(WIN10SDK_PATH "$ENV{WIN10SDK_PATH}")
  50. endif()
  51. endif()
  52. if(DEFINED WIN10SDK_PATH AND NOT EXISTS "${WIN10SDK_PATH}/include/winrt/windows.graphics.printing3d.h")
  53. message("WIN10SDK_PATH is invalid: ${WIN10SDK_PATH}")
  54. message("${WIN10SDK_PATH}/include/winrt/windows.graphics.printing3d.h was not found")
  55. message("STL fixing by the Netfabb service will not be compiled")
  56. unset(WIN10SDK_PATH)
  57. endif()
  58. endif()
  59. add_subdirectory(xs)
  60. get_filename_component(PERL_BIN_PATH "${PERL_EXECUTABLE}" DIRECTORY)
  61. if (MSVC)
  62. # By default the startup project in MSVC is the 'ALL_BUILD' cmake-created project,
  63. # but we want 'slic3r' as the startup one because debugging run command is associated with it.
  64. # (Unfortunatelly it cannot be associated with ALL_BUILD using CMake.)
  65. # Note: For some reason this needs to be set in the top-level CMakeLists.txt
  66. set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT XS)
  67. set(PERL_PROVE "${PERL_BIN_PATH}/prove.bat")
  68. else ()
  69. set(PERL_PROVE "${PERL_BIN_PATH}/prove")
  70. endif ()
  71. enable_testing ()
  72. add_test (NAME xs COMMAND "${PERL_EXECUTABLE}" ${PERL_PROVE} -I ${PROJECT_SOURCE_DIR}/local-lib/lib/perl5 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/xs)
  73. add_test (NAME integration COMMAND "${PERL_EXECUTABLE}" ${PERL_PROVE} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
  74. install(PROGRAMS slic3r.pl DESTINATION bin RENAME slic3r-prusa3d)
  75. file(GLOB MyVar var/*.png)
  76. install(FILES ${MyVar} DESTINATION share/slic3r-prusa3d)
  77. install(FILES lib/Slic3r.pm DESTINATION lib/slic3r-prusa3d)
  78. install(DIRECTORY lib/Slic3r DESTINATION lib/slic3r-prusa3d)