2018-09-19 09:02:24 +00:00
|
|
|
|
project(Slic3r-native)
|
|
|
|
|
|
|
|
|
|
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)
|
2018-10-31 08:57:29 +00:00
|
|
|
|
add_subdirectory(imgui)
|
2018-09-19 09:02:24 +00:00
|
|
|
|
|
|
|
|
|
# Adding libnest2d project for bin packing...
|
|
|
|
|
set(LIBNEST2D_UNITTESTS ON CACHE BOOL "Force generating unittests for libnest2d")
|
|
|
|
|
add_subdirectory(libnest2d)
|
|
|
|
|
|
|
|
|
|
include_directories(${LIBDIR}/qhull/src)
|
|
|
|
|
#message(STATUS ${LIBDIR}/qhull/src)
|
|
|
|
|
|
|
|
|
|
# ##############################################################################
|
|
|
|
|
# Configure rasterizer target
|
|
|
|
|
# ##############################################################################
|
|
|
|
|
|
|
|
|
|
find_package(PNG QUIET)
|
|
|
|
|
|
|
|
|
|
option(RASTERIZER_FORCE_BUILTIN_LIBPNG "Force the usage of builting libpng instead of the system version." OFF)
|
|
|
|
|
|
|
|
|
|
if(PNG_FOUND AND NOT RASTERIZER_FORCE_BUILTIN_LIBPNG)
|
|
|
|
|
message(STATUS "Using system libpng.")
|
|
|
|
|
else()
|
|
|
|
|
set(ZLIB_LIBRARY "")
|
|
|
|
|
message(WARNING "Using builtin libpng. This can cause crashes on some platforms.")
|
2019-01-04 11:06:25 +00:00
|
|
|
|
set(SKIP_INSTALL_ALL 1) # Prevent png+zlib from creating install targets
|
2018-09-19 09:02:24 +00:00
|
|
|
|
add_subdirectory(png/zlib)
|
|
|
|
|
set(ZLIB_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/png/zlib ${CMAKE_CURRENT_BINARY_DIR}/png/zlib)
|
|
|
|
|
include_directories(${ZLIB_INCLUDE_DIR})
|
|
|
|
|
add_subdirectory(png/libpng)
|
|
|
|
|
set_target_properties(zlibstatic PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
set_target_properties(png_static PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
set(PNG_LIBRARIES png_static zlibstatic)
|
|
|
|
|
set(PNG_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/png/libpng ${CMAKE_CURRENT_BINARY_DIR}/png/libpng)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
add_subdirectory(libslic3r)
|
2018-09-19 16:05:58 +00:00
|
|
|
|
|
|
|
|
|
if (SLIC3R_GUI)
|
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")
|
|
|
|
|
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)
|
|
|
|
|
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 ()
|
|
|
|
|
find_package(wxWidgets 3.1 REQUIRED COMPONENTS base core adv html gl)
|
|
|
|
|
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})
|
|
|
|
|
endif()
|
|
|
|
|
|
2018-09-19 09:02:24 +00:00
|
|
|
|
add_subdirectory(slic3r)
|
|
|
|
|
|
|
|
|
|
# Create a slic3r executable
|
2018-09-24 09:53:05 +00:00
|
|
|
|
# Process mainfests for various platforms.
|
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/msw/slic3r.rc.in ${CMAKE_CURRENT_BINARY_DIR}/slic3r.rc @ONLY)
|
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/msw/slic3r.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/slic3r.manifest @ONLY)
|
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/platform/osx/Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist @ONLY)
|
2018-10-26 09:57:52 +00:00
|
|
|
|
if (MSVC)
|
2019-03-13 15:06:21 +00:00
|
|
|
|
add_library(slic3r SHARED slic3r.cpp slic3r.hpp)
|
2018-10-26 09:57:52 +00:00
|
|
|
|
else ()
|
2019-03-13 15:06:21 +00:00
|
|
|
|
add_executable(slic3r slic3r.cpp slic3r.hpp)
|
2018-10-26 09:57:52 +00:00
|
|
|
|
endif ()
|
|
|
|
|
if (NOT MSVC)
|
|
|
|
|
if(SLIC3R_GUI)
|
|
|
|
|
set_target_properties(slic3r PROPERTIES OUTPUT_NAME "slic3r-gui")
|
|
|
|
|
else()
|
|
|
|
|
set_target_properties(slic3r PROPERTIES OUTPUT_NAME "slic3r-console")
|
|
|
|
|
endif()
|
|
|
|
|
endif ()
|
2018-10-12 12:19:08 +00:00
|
|
|
|
|
2018-09-19 13:47:32 +00:00
|
|
|
|
target_link_libraries(slic3r libslic3r)
|
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
|
|
|
|
|
target_link_libraries(slic3r "-liconv -framework IOKit" "-framework CoreFoundation" -lc++)
|
2018-09-24 09:53:05 +00:00
|
|
|
|
elseif (MSVC)
|
|
|
|
|
# Manifest is provided through slic3r.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 ()
|
2018-11-19 16:58:08 +00:00
|
|
|
|
target_link_libraries(slic3r ${CMAKE_DL_LIBS} -lstdc++)
|
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)
|
2018-09-21 19:16:09 +00:00
|
|
|
|
target_link_libraries(slic3r libslic3r_gui ${wxWidgets_LIBRARIES})
|
2018-09-19 13:47:32 +00:00
|
|
|
|
|
|
|
|
|
# Configure libcurl & OpenSSL
|
|
|
|
|
find_package(CURL REQUIRED)
|
|
|
|
|
target_include_directories(slic3r PRIVATE ${CURL_INCLUDE_DIRS})
|
2018-10-22 12:53:48 +00:00
|
|
|
|
target_link_libraries(slic3r CURL::libcurl)
|
2018-09-19 13:47:32 +00:00
|
|
|
|
if (SLIC3R_STATIC)
|
|
|
|
|
if (NOT APPLE)
|
|
|
|
|
# libcurl is always linked dynamically to the system libcurl on OSX.
|
|
|
|
|
# On other systems, libcurl is linked statically if SLIC3R_STATIC is set.
|
|
|
|
|
target_compile_definitions(slic3r PRIVATE CURL_STATICLIB)
|
|
|
|
|
endif()
|
|
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
|
# As of now, our build system produces a statically linked libcurl,
|
|
|
|
|
# which links the OpenSSL library dynamically.
|
|
|
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
|
message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
|
|
|
|
|
message("OpenSSL libraries: ${OPENSSL_LIBRARIES}")
|
|
|
|
|
target_include_directories(slic3r PRIVATE ${OPENSSL_INCLUDE_DIR})
|
|
|
|
|
target_link_libraries(slic3r ${OPENSSL_LIBRARIES})
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2018-09-19 09:02:24 +00:00
|
|
|
|
if (MSVC)
|
|
|
|
|
target_link_libraries(slic3r user32.lib Setupapi.lib OpenGL32.Lib GlU32.Lib)
|
|
|
|
|
elseif (MINGW)
|
|
|
|
|
target_link_libraries(slic3r -lopengl32)
|
|
|
|
|
elseif (APPLE)
|
|
|
|
|
target_link_libraries(slic3r "-framework OpenGL")
|
|
|
|
|
else ()
|
2018-09-19 12:43:38 +00:00
|
|
|
|
target_link_libraries(slic3r -ldl -lGL -lGLU)
|
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.
|
|
|
|
|
if (MSVC)
|
|
|
|
|
add_executable(slic3r_app_gui WIN32 slic3r_app_msvc.cpp ${CMAKE_CURRENT_BINARY_DIR}/slic3r.rc)
|
2019-03-13 16:06:45 +00:00
|
|
|
|
target_compile_definitions(slic3r_app_gui PRIVATE -DSLIC3R_WRAPPER_NOCONSOLE)
|
2018-10-26 09:57:52 +00:00
|
|
|
|
add_dependencies(slic3r_app_gui slic3r)
|
|
|
|
|
set_target_properties(slic3r_app_gui PROPERTIES OUTPUT_NAME "slic3r")
|
|
|
|
|
|
|
|
|
|
add_executable(slic3r_app_console slic3r_app_msvc.cpp ${CMAKE_CURRENT_BINARY_DIR}/slic3r.rc)
|
2019-03-13 16:06:45 +00:00
|
|
|
|
target_compile_definitions(slic3r_app_console PRIVATE -DSLIC3R_WRAPPER_CONSOLE)
|
2018-10-26 09:57:52 +00:00
|
|
|
|
add_dependencies(slic3r_app_console slic3r)
|
|
|
|
|
set_target_properties(slic3r_app_console PROPERTIES OUTPUT_NAME "slic3r-console")
|
|
|
|
|
endif ()
|
|
|
|
|
|
2018-10-12 12:19:08 +00:00
|
|
|
|
# Link the resources dir to where Slic3r GUI expects it
|
|
|
|
|
if (MSVC)
|
|
|
|
|
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)
|
2018-10-22 09:50:05 +00:00
|
|
|
|
add_custom_command(TARGET slic3r 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)
|
2018-10-22 09:50:05 +00:00
|
|
|
|
add_custom_command(TARGET slic3r 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 ()
|
2018-11-30 19:52:45 +00:00
|
|
|
|
elseif (XCODE)
|
|
|
|
|
# Because of Debug/Release/etc. configurations (similar to MSVC) the slic3r binary is located in an extra level
|
|
|
|
|
add_custom_command(TARGET slic3r POST_BUILD
|
|
|
|
|
COMMAND ln -sf "${SLIC3R_RESOURCES_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/resources"
|
|
|
|
|
COMMENT "Symlinking the resources directory into the build tree"
|
|
|
|
|
VERBATIM
|
|
|
|
|
)
|
2018-10-12 12:19:08 +00:00
|
|
|
|
else ()
|
2018-10-22 09:50:05 +00:00
|
|
|
|
add_custom_command(TARGET slic3r POST_BUILD
|
2018-10-12 12:19:08 +00:00
|
|
|
|
COMMAND ln -sf "${SLIC3R_RESOURCES_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/../resources"
|
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()
|
2019-01-04 11:06:25 +00:00
|
|
|
|
|
|
|
|
|
# Slic3r binary install target
|
|
|
|
|
if (WIN32)
|
|
|
|
|
install(TARGETS slic3r RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
|
if (MSVC)
|
|
|
|
|
install(TARGETS slic3r_app_gui RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
|
install(TARGETS slic3r_app_console RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
|
endif ()
|
|
|
|
|
else ()
|
|
|
|
|
install(TARGETS slic3r RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
|
|
|
|
endif ()
|