2020-10-05 09:44:50 +00:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
2019-05-13 13:14:33 +00:00
|
|
|
project(PrusaSlicer-native)
|
2018-09-19 09:02:24 +00:00
|
|
|
|
2019-08-19 10:25:18 +00:00
|
|
|
add_subdirectory(build-utils)
|
2018-09-19 09:02:24 +00:00
|
|
|
add_subdirectory(admesh)
|
|
|
|
add_subdirectory(avrdude)
|
|
|
|
# boost/nowide
|
|
|
|
add_subdirectory(boost)
|
|
|
|
add_subdirectory(clipper)
|
|
|
|
add_subdirectory(miniz)
|
2019-02-05 17:14:07 +00:00
|
|
|
add_subdirectory(glu-libtess)
|
2018-09-19 09:02:24 +00:00
|
|
|
add_subdirectory(polypartition)
|
|
|
|
add_subdirectory(poly2tri)
|
|
|
|
add_subdirectory(qhull)
|
|
|
|
add_subdirectory(Shiny)
|
|
|
|
add_subdirectory(semver)
|
2019-06-19 12:52:55 +00:00
|
|
|
add_subdirectory(libigl)
|
2018-09-19 09:02:24 +00:00
|
|
|
|
|
|
|
# Adding libnest2d project for bin packing...
|
|
|
|
add_subdirectory(libnest2d)
|
|
|
|
|
|
|
|
add_subdirectory(libslic3r)
|
2018-09-19 16:05:58 +00:00
|
|
|
|
|
|
|
if (SLIC3R_GUI)
|
2019-04-23 12:56:53 +00:00
|
|
|
add_subdirectory(imgui)
|
2019-09-30 13:20:23 +00:00
|
|
|
add_subdirectory(hidapi)
|
|
|
|
include_directories(hidapi/include)
|
2019-04-23 12:56:53 +00:00
|
|
|
|
2018-12-14 12:45:58 +00:00
|
|
|
if(WIN32)
|
|
|
|
message(STATUS "WXWIN environment set to: $ENV{WXWIN}")
|
|
|
|
elseif(UNIX)
|
|
|
|
set(wxWidgets_USE_UNICODE ON)
|
|
|
|
if(SLIC3R_STATIC)
|
|
|
|
set(wxWidgets_USE_STATIC ON)
|
|
|
|
else()
|
|
|
|
set(wxWidgets_USE_STATIC OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-01-07 18:17:10 +00:00
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
2019-03-25 14:50:07 +00:00
|
|
|
set (wxWidgets_CONFIG_OPTIONS "--toolkit=gtk${SLIC3R_GTK}")
|
2019-01-07 18:17:10 +00:00
|
|
|
if (SLIC3R_WX_STABLE)
|
|
|
|
find_package(wxWidgets 3.0 REQUIRED COMPONENTS base core adv html gl)
|
|
|
|
else ()
|
|
|
|
find_package(wxWidgets 3.1 QUIET COMPONENTS base core adv html gl)
|
2019-03-19 10:26:53 +00:00
|
|
|
|
2019-01-07 18:17:10 +00:00
|
|
|
if (NOT wxWidgets_FOUND)
|
2019-02-06 08:21:13 +00:00
|
|
|
message(FATAL_ERROR "\nCould not find wxWidgets 3.1.\n"
|
|
|
|
"Hint: On Linux you can set -DSLIC3R_WX_STABLE=1 to use wxWidgets 3.0\n")
|
2019-01-07 18:17:10 +00:00
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
else ()
|
2019-08-16 14:17:37 +00:00
|
|
|
find_package(wxWidgets 3.1 REQUIRED COMPONENTS html adv gl core base)
|
2019-01-07 18:17:10 +00:00
|
|
|
endif ()
|
|
|
|
|
2019-01-24 18:58:34 +00:00
|
|
|
if(UNIX)
|
|
|
|
message(STATUS "wx-config path: ${wxWidgets_CONFIG_EXECUTABLE}")
|
|
|
|
endif()
|
|
|
|
|
2018-09-19 16:05:58 +00:00
|
|
|
include(${wxWidgets_USE_FILE})
|
2019-04-23 12:18:07 +00:00
|
|
|
|
2020-04-28 18:39:47 +00:00
|
|
|
string(REGEX MATCH "wxpng" WX_PNG_BUILTIN ${wxWidgets_LIBRARIES})
|
|
|
|
if (PNG_FOUND AND NOT WX_PNG_BUILTIN)
|
|
|
|
list(FILTER wxWidgets_LIBRARIES EXCLUDE REGEX png)
|
|
|
|
list(APPEND wxWidgets_LIBRARIES ${PNG_LIBRARIES})
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
string(REGEX MATCH "wxexpat" WX_EXPAT_BUILTIN ${wxWidgets_LIBRARIES})
|
|
|
|
if (EXPAT_FOUND AND NOT WX_EXPAT_BUILTIN)
|
|
|
|
list(FILTER wxWidgets_LIBRARIES EXCLUDE REGEX expat)
|
|
|
|
list(APPEND wxWidgets_LIBRARIES ${EXPAT_LIBRARIES})
|
|
|
|
endif ()
|
2020-04-28 07:56:54 +00:00
|
|
|
|
2020-04-28 19:01:09 +00:00
|
|
|
# This is an issue in the new wxWidgets cmake build, doesn't deal with librt
|
|
|
|
find_library(LIBRT rt)
|
|
|
|
if(LIBRT)
|
|
|
|
list(APPEND wxWidgets_LIBRARIES ${LIBRT})
|
|
|
|
endif()
|
|
|
|
|
2020-04-29 10:32:00 +00:00
|
|
|
# This fixes a OpenGL linking issue on OSX. wxWidgets cmake build includes
|
|
|
|
# wrong libs for opengl in the link line and it does not link to it by himself.
|
|
|
|
# libslic3r_gui will link to opengl anyway, so lets override wx
|
|
|
|
list(FILTER wxWidgets_LIBRARIES EXCLUDE REGEX OpenGL)
|
|
|
|
|
2019-08-16 14:17:37 +00:00
|
|
|
# list(REMOVE_ITEM wxWidgets_LIBRARIES oleacc)
|
|
|
|
message(STATUS "wx libs: ${wxWidgets_LIBRARIES}")
|
|
|
|
|
2019-04-23 12:18:07 +00:00
|
|
|
add_subdirectory(slic3r)
|
2018-09-19 16:05:58 +00:00
|
|
|
endif()
|
|
|
|
|
2018-09-19 09:02:24 +00:00
|
|
|
|
|
|
|
# Create a slic3r executable
|
2018-09-24 09:53:05 +00:00
|
|
|
# Process mainfests for various platforms.
|
2019-05-13 13:14:33 +00:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/msw/PrusaSlicer.rc.in ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer.rc @ONLY)
|
2020-09-01 14:56:12 +00:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/msw/PrusaSlicer-gcodeviewer.rc.in ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer-gcodeviewer.rc @ONLY)
|
2019-05-13 13:14:33 +00:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/msw/PrusaSlicer.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer.manifest @ONLY)
|
2018-09-24 09:53:05 +00:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/osx/Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist @ONLY)
|
2019-08-16 14:17:37 +00:00
|
|
|
if (WIN32)
|
2019-05-13 13:14:33 +00:00
|
|
|
add_library(PrusaSlicer SHARED PrusaSlicer.cpp PrusaSlicer.hpp)
|
2018-10-26 09:57:52 +00:00
|
|
|
else ()
|
2019-05-13 13:14:33 +00:00
|
|
|
add_executable(PrusaSlicer PrusaSlicer.cpp PrusaSlicer.hpp)
|
2018-10-26 09:57:52 +00:00
|
|
|
endif ()
|
2019-08-16 14:17:37 +00:00
|
|
|
|
|
|
|
if (MINGW)
|
|
|
|
target_link_options(PrusaSlicer PUBLIC "-Wl,-allow-multiple-definition")
|
|
|
|
set_target_properties(PrusaSlicer PROPERTIES PREFIX "")
|
|
|
|
endif (MINGW)
|
|
|
|
|
2020-09-08 11:33:43 +00:00
|
|
|
if (NOT WIN32 AND NOT APPLE)
|
|
|
|
# Binary name on unix like systems (Linux, Unix)
|
|
|
|
set_target_properties(PrusaSlicer PROPERTIES OUTPUT_NAME "prusa-slicer")
|
2018-10-26 09:57:52 +00:00
|
|
|
endif ()
|
2018-10-12 12:19:08 +00:00
|
|
|
|
2019-07-04 20:52:33 +00:00
|
|
|
target_link_libraries(PrusaSlicer libslic3r cereal)
|
2018-09-19 11:12:57 +00:00
|
|
|
if (APPLE)
|
|
|
|
# add_compile_options(-stdlib=libc++)
|
|
|
|
# add_definitions(-DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE)
|
2018-09-19 13:47:32 +00:00
|
|
|
# -liconv: boost links to libiconv by default
|
2019-05-13 13:14:33 +00:00
|
|
|
target_link_libraries(PrusaSlicer "-liconv -framework IOKit" "-framework CoreFoundation" -lc++)
|
2018-09-24 09:53:05 +00:00
|
|
|
elseif (MSVC)
|
2019-05-13 13:14:33 +00:00
|
|
|
# Manifest is provided through PrusaSlicer.rc, don't generate your own.
|
2018-11-07 14:23:00 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
|
2018-09-24 09:53:05 +00:00
|
|
|
else ()
|
2019-04-23 09:02:57 +00:00
|
|
|
# Boost on Raspberry-Pi does not link to pthreads explicitely.
|
2019-05-13 13:14:33 +00:00
|
|
|
target_link_libraries(PrusaSlicer ${CMAKE_DL_LIBS} -lstdc++ Threads::Threads)
|
2018-09-19 11:12:57 +00:00
|
|
|
endif ()
|
2018-09-19 13:47:32 +00:00
|
|
|
|
|
|
|
# Add the Slic3r GUI library, libcurl, OpenGL and GLU libraries.
|
2018-09-19 09:02:24 +00:00
|
|
|
if (SLIC3R_GUI)
|
2019-08-16 14:17:37 +00:00
|
|
|
# target_link_libraries(PrusaSlicer ws2_32 uxtheme setupapi libslic3r_gui ${wxWidgets_LIBRARIES})
|
2020-03-06 14:16:46 +00:00
|
|
|
target_link_libraries(PrusaSlicer libslic3r_gui)
|
2018-09-19 09:02:24 +00:00
|
|
|
if (MSVC)
|
2019-05-13 17:31:20 +00:00
|
|
|
# Generate debug symbols even in release mode.
|
|
|
|
target_link_options(PrusaSlicer PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>")
|
2019-12-11 11:24:21 +00:00
|
|
|
target_link_libraries(PrusaSlicer user32.lib Setupapi.lib)
|
2018-09-19 09:02:24 +00:00
|
|
|
elseif (MINGW)
|
2019-12-11 11:24:21 +00:00
|
|
|
target_link_libraries(PrusaSlicer ws2_32 uxtheme setupapi)
|
2018-09-19 09:02:24 +00:00
|
|
|
elseif (APPLE)
|
2019-05-13 13:14:33 +00:00
|
|
|
target_link_libraries(PrusaSlicer "-framework OpenGL")
|
2018-09-19 09:02:24 +00:00
|
|
|
else ()
|
2019-12-11 11:24:21 +00:00
|
|
|
target_link_libraries(PrusaSlicer -ldl)
|
2018-09-19 09:02:24 +00:00
|
|
|
endif ()
|
|
|
|
endif ()
|
2018-10-12 12:19:08 +00:00
|
|
|
|
2018-10-26 09:57:52 +00:00
|
|
|
# On Windows, a shim application is required to produce a console / non console version of the Slic3r application.
|
|
|
|
# Also the shim may load the Mesa software OpenGL renderer if the default renderer does not support OpenGL 2.0 and higher.
|
2019-08-16 14:17:37 +00:00
|
|
|
if (WIN32)
|
|
|
|
if (MINGW)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode")
|
|
|
|
endif()
|
|
|
|
|
2019-05-13 13:14:33 +00:00
|
|
|
add_executable(PrusaSlicer_app_gui WIN32 PrusaSlicer_app_msvc.cpp ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer.rc)
|
2019-05-13 17:31:20 +00:00
|
|
|
# Generate debug symbols even in release mode.
|
2019-08-16 14:17:37 +00:00
|
|
|
if(MSVC)
|
|
|
|
target_link_options(PrusaSlicer_app_gui PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>")
|
|
|
|
endif()
|
2019-05-13 13:14:33 +00:00
|
|
|
target_compile_definitions(PrusaSlicer_app_gui PRIVATE -DSLIC3R_WRAPPER_NOCONSOLE)
|
|
|
|
add_dependencies(PrusaSlicer_app_gui PrusaSlicer)
|
2019-05-13 13:47:33 +00:00
|
|
|
set_target_properties(PrusaSlicer_app_gui PROPERTIES OUTPUT_NAME "prusa-slicer")
|
2019-06-13 11:15:10 +00:00
|
|
|
target_link_libraries(PrusaSlicer_app_gui PRIVATE boost_headeronly)
|
2019-05-13 13:14:33 +00:00
|
|
|
|
|
|
|
add_executable(PrusaSlicer_app_console PrusaSlicer_app_msvc.cpp ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer.rc)
|
2019-05-13 17:31:20 +00:00
|
|
|
# Generate debug symbols even in release mode.
|
2019-08-16 14:17:37 +00:00
|
|
|
if (MSVC)
|
2020-09-01 14:56:12 +00:00
|
|
|
target_link_options(PrusaSlicer_app_console PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>")
|
2019-08-16 14:17:37 +00:00
|
|
|
endif ()
|
2019-05-13 13:14:33 +00:00
|
|
|
target_compile_definitions(PrusaSlicer_app_console PRIVATE -DSLIC3R_WRAPPER_CONSOLE)
|
|
|
|
add_dependencies(PrusaSlicer_app_console PrusaSlicer)
|
2019-05-13 13:47:33 +00:00
|
|
|
set_target_properties(PrusaSlicer_app_console PROPERTIES OUTPUT_NAME "prusa-slicer-console")
|
2019-06-13 11:15:10 +00:00
|
|
|
target_link_libraries(PrusaSlicer_app_console PRIVATE boost_headeronly)
|
2020-09-01 14:56:12 +00:00
|
|
|
|
|
|
|
add_executable(PrusaSlicer_app_gcodeviewer WIN32 PrusaSlicer_app_msvc.cpp ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer-gcodeviewer.rc)
|
|
|
|
# Generate debug symbols even in release mode.
|
|
|
|
if (MSVC)
|
|
|
|
target_link_options(PrusaSlicer_app_gcodeviewer PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>")
|
|
|
|
endif ()
|
|
|
|
target_compile_definitions(PrusaSlicer_app_gcodeviewer PRIVATE -DSLIC3R_WRAPPER_NOCONSOLE -DSLIC3R_WRAPPER_GCODEVIEWER)
|
|
|
|
add_dependencies(PrusaSlicer_app_gcodeviewer PrusaSlicer)
|
|
|
|
set_target_properties(PrusaSlicer_app_gcodeviewer PROPERTIES OUTPUT_NAME "prusa-gcodeviewer")
|
|
|
|
target_link_libraries(PrusaSlicer_app_gcodeviewer PRIVATE boost_headeronly)
|
2018-10-26 09:57:52 +00:00
|
|
|
endif ()
|
|
|
|
|
2018-10-12 12:19:08 +00:00
|
|
|
# Link the resources dir to where Slic3r GUI expects it
|
2019-08-16 14:17:37 +00:00
|
|
|
if (WIN32)
|
2018-10-12 12:19:08 +00:00
|
|
|
if (CMAKE_CONFIGURATION_TYPES)
|
|
|
|
foreach (CONF ${CMAKE_CONFIGURATION_TYPES})
|
|
|
|
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${CONF}" WIN_CONF_OUTPUT_DIR)
|
|
|
|
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${CONF}/resources" WIN_RESOURCES_SYMLINK)
|
2019-05-13 13:14:33 +00:00
|
|
|
add_custom_command(TARGET PrusaSlicer POST_BUILD
|
2018-10-12 12:19:08 +00:00
|
|
|
COMMAND if exist "${WIN_CONF_OUTPUT_DIR}" "("
|
2018-10-17 12:01:10 +00:00
|
|
|
if not exist "${WIN_RESOURCES_SYMLINK}" "("
|
|
|
|
mklink /J "${WIN_RESOURCES_SYMLINK}" "${SLIC3R_RESOURCES_DIR_WIN}"
|
2018-10-12 12:19:08 +00:00
|
|
|
")"
|
|
|
|
")"
|
2018-10-22 09:50:05 +00:00
|
|
|
COMMENT "Symlinking the resources directory into the build tree"
|
2018-10-12 12:19:08 +00:00
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
endforeach ()
|
2018-10-17 12:01:10 +00:00
|
|
|
else ()
|
2018-10-17 13:22:45 +00:00
|
|
|
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/resources" WIN_RESOURCES_SYMLINK)
|
2019-05-13 13:14:33 +00:00
|
|
|
add_custom_command(TARGET PrusaSlicer POST_BUILD
|
2018-10-12 12:19:08 +00:00
|
|
|
COMMAND if not exist "${WIN_RESOURCES_SYMLINK}" "(" mklink /J "${WIN_RESOURCES_SYMLINK}" "${SLIC3R_RESOURCES_DIR_WIN}" ")"
|
2018-10-22 09:50:05 +00:00
|
|
|
COMMENT "Symlinking the resources directory into the build tree"
|
2018-10-12 12:19:08 +00:00
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
endif ()
|
2020-10-16 12:04:10 +00:00
|
|
|
|
2019-12-10 16:42:25 +00:00
|
|
|
# This has to be a separate target due to the windows command line lenght limits
|
|
|
|
add_custom_target(PrusaSlicerDllsCopy ALL DEPENDS PrusaSlicer)
|
|
|
|
prusaslicer_copy_dlls(PrusaSlicerDllsCopy)
|
2020-10-16 12:04:10 +00:00
|
|
|
|
2018-10-12 12:19:08 +00:00
|
|
|
else ()
|
2020-09-08 11:33:43 +00:00
|
|
|
if (APPLE)
|
|
|
|
# On OSX, the name of the binary matches the name of the Application.
|
|
|
|
add_custom_command(TARGET PrusaSlicer POST_BUILD
|
|
|
|
COMMAND ln -sf PrusaSlicer prusa-slicer
|
|
|
|
COMMAND ln -sf PrusaSlicer prusa-gcodeviewer
|
|
|
|
COMMAND ln -sf PrusaSlicer PrusaGCodeViewer
|
|
|
|
WORKING_DIRECTORY "$<TARGET_FILE_DIR:PrusaSlicer>"
|
|
|
|
COMMENT "Symlinking the G-code viewer to PrusaSlicer, symlinking to prusa-slicer and prusa-gcodeviewer"
|
|
|
|
VERBATIM)
|
|
|
|
else ()
|
|
|
|
add_custom_command(TARGET PrusaSlicer POST_BUILD
|
|
|
|
COMMAND ln -sf prusa-slicer prusa-gcodeviewer
|
|
|
|
WORKING_DIRECTORY "$<TARGET_FILE_DIR:PrusaSlicer>"
|
|
|
|
COMMENT "Symlinking the G-code viewer to PrusaSlicer"
|
|
|
|
VERBATIM)
|
|
|
|
endif ()
|
|
|
|
if (XCODE)
|
|
|
|
# Because of Debug/Release/etc. configurations (similar to MSVC) the slic3r binary is located in an extra level
|
|
|
|
set(BIN_RESOURCES_DIR "${CMAKE_CURRENT_BINARY_DIR}/resources")
|
|
|
|
else ()
|
|
|
|
set(BIN_RESOURCES_DIR "${CMAKE_CURRENT_BINARY_DIR}/../resources")
|
|
|
|
endif ()
|
2019-05-13 13:14:33 +00:00
|
|
|
add_custom_command(TARGET PrusaSlicer POST_BUILD
|
2020-09-08 11:33:43 +00:00
|
|
|
COMMAND ln -sfn "${SLIC3R_RESOURCES_DIR}" "${BIN_RESOURCES_DIR}"
|
2018-10-22 09:50:05 +00:00
|
|
|
COMMENT "Symlinking the resources directory into the build tree"
|
2020-09-08 11:33:43 +00:00
|
|
|
VERBATIM)
|
|
|
|
endif ()
|
2019-01-04 11:06:25 +00:00
|
|
|
|
|
|
|
# Slic3r binary install target
|
|
|
|
if (WIN32)
|
2019-05-13 13:14:33 +00:00
|
|
|
install(TARGETS PrusaSlicer RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
2019-01-04 11:06:25 +00:00
|
|
|
if (MSVC)
|
2019-05-13 13:14:33 +00:00
|
|
|
install(TARGETS PrusaSlicer_app_gui RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
install(TARGETS PrusaSlicer_app_console RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
2019-01-04 11:06:25 +00:00
|
|
|
endif ()
|
|
|
|
else ()
|
2019-05-13 13:14:33 +00:00
|
|
|
install(TARGETS PrusaSlicer RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
2020-10-16 09:06:25 +00:00
|
|
|
|
|
|
|
# Install the symlink for gcodeviewer
|
|
|
|
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink prusa-slicer prusa-gcodeviewer WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})")
|
2019-01-04 11:06:25 +00:00
|
|
|
endif ()
|