CMakeLists.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. cmake_minimum_required(VERSION 3.2)
  2. project(Slic3r)
  3. if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  4. message(STATUS "No build type selected, default to Release")
  5. set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE)
  6. endif()
  7. if(DEFINED ENV{SLIC3R_STATIC})
  8. set(SLIC3R_STATIC_INITIAL $ENV{SLIC3R_STATIC})
  9. else()
  10. if (MSVC OR MINGW OR APPLE)
  11. set(SLIC3R_STATIC_INITIAL 1)
  12. else()
  13. set(SLIC3R_STATIC_INITIAL 0)
  14. endif()
  15. endif()
  16. option(SLIC3R_STATIC "Compile Slic3r with static libraries (Boost, TBB, glew)" ${SLIC3R_STATIC_INITIAL})
  17. option(SLIC3R_GUI "Compile Slic3r with GUI components (OpenGL, wxWidgets)" 1)
  18. option(SLIC3R_PRUSACONTROL "Compile Slic3r with the PrusaControl prject file format (requires wxWidgets base library)" 1)
  19. option(SLIC3R_PROFILE "Compile Slic3r with an invasive Shiny profiler" 0)
  20. option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1)
  21. option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 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(PERL_INCLUDE "${PROJECT_SOURCE_DIR}/local-lib/lib/perl5${ENV_PATH_SEPARATOR}$ENV{PERL5LIB}")
  34. message("PATH: $ENV{PATH}")
  35. message("PERL_INCLUDE: ${PERL_INCLUDE}")
  36. find_package(Perl REQUIRED)
  37. if (WIN32)
  38. # On Windows passing the PERL5LIB variable causes various problems (such as with MAX_PATH and others),
  39. # basically I've found no good way to do it on Windows.
  40. set(PERL5LIB_ENV_CMD "")
  41. else()
  42. set(PERL5LIB_ENV_CMD ${CMAKE_COMMAND} -E env PERL5LIB=${PERL_INCLUDE})
  43. endif()
  44. # CMAKE_PREFIX_PATH is used to point CMake to the remaining dependencies (Boost, TBB, ...)
  45. # We pick it from environment if it is not defined in another way
  46. if(NOT DEFINED CMAKE_PREFIX_PATH)
  47. if(DEFINED ENV{CMAKE_PREFIX_PATH})
  48. set(CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
  49. endif()
  50. endif()
  51. enable_testing ()
  52. # WIN10SDK_PATH is used to point CMake to the WIN10 SDK installation directory.
  53. # We pick it from environment if it is not defined in another way
  54. if(WIN32)
  55. if(NOT DEFINED WIN10SDK_PATH)
  56. if(DEFINED ENV{WIN10SDK_PATH})
  57. set(WIN10SDK_PATH "$ENV{WIN10SDK_PATH}")
  58. endif()
  59. endif()
  60. if(DEFINED WIN10SDK_PATH AND NOT EXISTS "${WIN10SDK_PATH}/include/winrt/windows.graphics.printing3d.h")
  61. message("WIN10SDK_PATH is invalid: ${WIN10SDK_PATH}")
  62. message("${WIN10SDK_PATH}/include/winrt/windows.graphics.printing3d.h was not found")
  63. message("STL fixing by the Netfabb service will not be compiled")
  64. unset(WIN10SDK_PATH)
  65. endif()
  66. endif()
  67. add_subdirectory(xs)
  68. get_filename_component(PERL_BIN_PATH "${PERL_EXECUTABLE}" DIRECTORY)
  69. if (MSVC)
  70. # By default the startup project in MSVC is the 'ALL_BUILD' cmake-created project,
  71. # but we want 'slic3r' as the startup one because debugging run command is associated with it.
  72. # (Unfortunatelly it cannot be associated with ALL_BUILD using CMake.)
  73. # Note: For some reason this needs to be set in the top-level CMakeLists.txt
  74. set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT XS)
  75. set(PERL_PROVE "${PERL_BIN_PATH}/prove.bat")
  76. else ()
  77. set(PERL_PROVE "${PERL_BIN_PATH}/prove")
  78. endif ()
  79. add_test (NAME xs COMMAND "${PERL_EXECUTABLE}" ${PERL_PROVE} -I ${PROJECT_SOURCE_DIR}/local-lib/lib/perl5 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/xs)
  80. add_test (NAME integration COMMAND "${PERL_EXECUTABLE}" ${PERL_PROVE} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
  81. install(PROGRAMS slic3r.pl DESTINATION bin RENAME slic3r-prusa3d)
  82. file(GLOB MyVar var/*.png)
  83. install(FILES ${MyVar} DESTINATION share/slic3r-prusa3d)
  84. install(FILES lib/Slic3r.pm DESTINATION lib/slic3r-prusa3d)
  85. install(DIRECTORY lib/Slic3r DESTINATION lib/slic3r-prusa3d)