Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/prusa/master' into masterPE
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Jan 25, 2019
2 parents 29d2d80 + 4dfcd49 commit 1999974
Show file tree
Hide file tree
Showing 186 changed files with 62,433 additions and 34,266 deletions.
59 changes: 45 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ project(Slic3r)
cmake_minimum_required(VERSION 3.2)

include("version.inc")
include(GNUInstallDirs)

set(SLIC3R_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
file(TO_NATIVE_PATH "${SLIC3R_RESOURCES_DIR}" SLIC3R_RESOURCES_DIR_WIN)

Expand All @@ -22,7 +24,10 @@ endif()

option(SLIC3R_STATIC "Compile Slic3r with static libraries (Boost, TBB, glew)" ${SLIC3R_STATIC_INITIAL})
option(SLIC3R_GUI "Compile Slic3r with GUI components (OpenGL, wxWidgets)" 1)
option(SLIC3R_FHS "Assume Slic3r is to be installed in a FHS directory structure" 0)
option(SLIC3R_WX_STABLE "Build against wxWidgets stable (3.0) as oppsed to dev (3.1) on Linux" 0)
option(SLIC3R_PROFILE "Compile Slic3r with an invasive Shiny profiler" 0)
option(SLIC3R_PCH "Use precompiled headers" 1)
option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1)
option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1)
option(SLIC3R_PERL_XS "Compile XS Perl module and enable Perl unit and integration tests" 0)
Expand All @@ -33,6 +38,15 @@ option(SLIC3R_SYNTAXONLY "Only perform source code correctness checking,
option(SLIC3R_BUILD_SANDBOXES "Build development sandboxes" OFF)
option(SLIC3R_BUILD_TESTS "Build unit tests" OFF)

# Print out the SLIC3R_* cache options
get_cmake_property(_cache_vars CACHE_VARIABLES)
list (SORT _cache_vars)
foreach (_cache_var ${_cache_vars})
if("${_cache_var}" MATCHES "^SLIC3R_")
message(STATUS "${_cache_var}: ${${_cache_var}}")
endif ()
endforeach()

if (MSVC)
if (SLIC3R_MSVC_COMPILE_PARALLEL)
add_compile_options(/MP)
Expand All @@ -42,7 +56,6 @@ if (MSVC)
add_compile_options(-bigobj -Zm316)
endif ()


# Display and check CMAKE_PREFIX_PATH
message(STATUS "SLIC3R_STATIC: ${SLIC3R_STATIC}")
if (NOT "${CMAKE_PREFIX_PATH}" STREQUAL "")
Expand Down Expand Up @@ -100,21 +113,26 @@ if(WIN32)
endif()

if (APPLE)
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "OS X Deployment target (SDK version)" FORCE)
message("OS X SDK Path: ${CMAKE_OSX_SYSROOT}")
if (CMAKE_OSX_DEPLOYMENT_TARGET)
message("OS X Deployment Target: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
else ()
message("OS X Deployment Target: (default)")
endif ()
message(STATUS "Mac OS deployment target (SDK version): ${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif ()

if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# Workaround for an old CMake, which does not understand CMAKE_CXX_STANDARD.
add_compile_options(-std=c++11 -Wall -Wno-reorder)
find_package(PkgConfig REQUIRED)

if (CMAKE_VERSION VERSION_LESS "3.1")
# Workaround for an old CMake, which does not understand CMAKE_CXX_STANDARD.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
endif()

if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
# Adding -fext-numeric-literals to enable GCC extensions on definitions of quad float literals, which are required by Boost.
add_compile_options(-fext-numeric-literals)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals" )

if (SLIC3R_SYNTAXONLY)
set(CMAKE_CXX_ARCHIVE_CREATE "true")
Expand All @@ -131,9 +149,15 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-Wall)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder" )

# On GCC and Clang, no return from a non-void function is a warning only. Here, we make it an error.
add_compile_options(-Werror=return-type)

#removes LOTS of extraneous Eigen warnings
add_compile_options(-Wno-ignored-attributes)

if (SLIC3R_ASAN)
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
Expand All @@ -146,12 +170,14 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STRE
endif()

# Where all the bundled libraries reside?
set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/src/)
set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(LIBDIR_BIN ${CMAKE_CURRENT_BINARY_DIR}/src)
# For the bundled boost libraries (boost::nowide)
include_directories(${LIBDIR})
# For generated header files
include_directories(${LIBDIR_BIN}/platform)
# For libslic3r.h
include_directories(${LIBDIR}/clipper ${LIBDIR}/polypartition)
#set(CMAKE_INCLUDE_CURRENT_DIR ON)

if(WIN32)
# BOOST_ALL_NO_LIB: Avoid the automatic linking of Boost libraries on Windows. Rather rely on explicit linking.
Expand Down Expand Up @@ -215,7 +241,6 @@ endif()
# The Intel TBB library will use the std::exception_ptr feature of C++11.
add_definitions(-DTBB_USE_CAPTURED_EXCEPTION=0)

#set(CURL_DEBUG 1)
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIRS})

Expand All @@ -239,7 +264,7 @@ endif()

# Find eigen3 or use bundled version
if (NOT SLIC3R_STATIC)
find_package(Eigen3)
find_package(Eigen3 3)
endif ()
if (NOT Eigen3_FOUND)
set(Eigen3_FOUND 1)
Expand Down Expand Up @@ -280,7 +305,6 @@ include_directories(${GLEW_INCLUDE_DIRS})
# l10n
set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/localization")
add_custom_target(pot
# FIXME: file list stale
COMMAND xgettext --keyword=L --from-code=UTF-8 --debug
-f "${L10N_DIR}/list.txt"
-o "${L10N_DIR}/Slic3rPE.pot"
Expand All @@ -307,5 +331,12 @@ if(SLIC3R_BUILD_TESTS)
add_subdirectory(tests)
endif()

file(GLOB MyVar var/*.png)
install(FILES ${MyVar} DESTINATION share/slic3r-prusa3d)

# Resources install target, configure fhs.hpp on UNIX
if (WIN32)
install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/resources")
else ()
set(SLIC3R_FHS_RESOURCES "${CMAKE_INSTALL_FULL_DATAROOTDIR}/slic3r-prusa3d")
install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${SLIC3R_FHS_RESOURCES}")
endif ()
configure_file(${LIBDIR}/platform/unix/fhs.hpp.in ${LIBDIR_BIN}/platform/unix/fhs.hpp)
28 changes: 27 additions & 1 deletion cmake/modules/PrecompiledHeader.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,37 @@ function(export_all_flags _filename)
set(_compile_definitions "$<TARGET_PROPERTY:${_target},COMPILE_DEFINITIONS>")
set(_compile_flags "$<TARGET_PROPERTY:${_target},COMPILE_FLAGS>")
set(_compile_options "$<TARGET_PROPERTY:${_target},COMPILE_OPTIONS>")

#handle config-specific cxx flags
string(TOUPPER ${CMAKE_BUILD_TYPE} _config)
set(_build_cxx_flags ${CMAKE_CXX_FLAGS_${_config}})

#handle fpie option
get_target_property(_fpie ${_target} POSITION_INDEPENDENT_CODE)
if (_fpie AND CMAKE_POSITION_INDEPENDENT_CODE)
list(APPEND _compile_options ${CMAKE_CXX_COMPILE_OPTIONS_PIC})
endif()

#handle compiler standard (GCC only)
if(CMAKE_COMPILER_IS_GNUCXX)
get_target_property(_cxx_standard ${_target} CXX_STANDARD)
if ((NOT "${_cxx_standard}" STREQUAL NOTFOUND) AND (NOT "${_cxx_standard}" STREQUAL ""))
get_target_property(_cxx_extensions ${_target} CXX_EXTENSIONS)
get_property(_exists TARGET ${_target} PROPERTY CXX_EXTENSIONS SET)
if (NOT _exists OR ${_cxx_extensions})
list(APPEND _compile_options "-std=gnu++${_cxx_standard}")
else()
list(APPEND _compile_options "-std=c++${_cxx_standard}")
endif()
endif()
endif()

set(_include_directories "$<$<BOOL:${_include_directories}>:-I$<JOIN:${_include_directories},\n-I>\n>")
set(_compile_definitions "$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions},\n-D>\n>")
set(_compile_flags "$<$<BOOL:${_compile_flags}>:$<JOIN:${_compile_flags},\n>\n>")
set(_compile_options "$<$<BOOL:${_compile_options}>:$<JOIN:${_compile_options},\n>\n>")
file(GENERATE OUTPUT "${_filename}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}\n")
set(_cxx_flags "$<$<BOOL:${CMAKE_CXX_FLAGS}>:${CMAKE_CXX_FLAGS}\n>$<$<BOOL:${_build_cxx_flags}>:${_build_cxx_flags}\n>")
file(GENERATE OUTPUT "${_filename}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}${_cxx_flags}\n")
endfunction()

function(add_precompiled_header _target _input)
Expand Down
23 changes: 18 additions & 5 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# All the dependencies are installed in a `destdir` directory in the root of the build directory,
# in a traditional Unix-style prefix structure. The destdir can be used directly by CMake
# when building Slic3r - to do this, set the CMAKE_PREFIX_PATH to ${destdir}/usr/local.
# Warning: On UNIX/Linux, you also need to set -DSLIC3R_STATIC=1 when building Slic3r.
#
# For better clarity of console output, it's recommended to _not_ use a parallelized build
# for the top-level command, ie. use `make -j 1` or `ninja -j 1` to force single-threaded top-level
Expand All @@ -32,6 +33,7 @@ endif ()

set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory")
option(DEP_DEBUG "Build debug variants (only applicable on Windows)" ON)
option(DEP_WX_STABLE "Build against wxWidgets stable 3.0 as opposed to default 3.1 (Linux only)" OFF)

message(STATUS "Slic3r deps DESTDIR: ${DESTDIR}")
message(STATUS "Slic3r deps debug build: ${DEP_DEBUG}")
Expand All @@ -49,11 +51,22 @@ if (MSVC)
message(FATAL_ERROR "Unable to detect architecture")
endif ()
elseif (APPLE)
set(DEPS_OSX_TARGET "10.9" CACHE STRING "OS X SDK version to build against")
set(DEPS_OSX_SYSROOT
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${DEPS_OSX_TARGET}.sdk"
CACHE PATH "OS X SDK directory"
)
message("OS X SDK Path: ${CMAKE_OSX_SYSROOT}")
if (CMAKE_OSX_DEPLOYMENT_TARGET)
set(DEP_OSX_TARGET "${CMAKE_OSX_DEPLOYMENT_TARGET}")
message("OS X Deployment Target: ${DEP_OSX_TARGET}")
else ()
# Attempt to infer the SDK version from the CMAKE_OSX_SYSROOT,
# this is done because wxWidgets need the min version explicitly set
string(REGEX MATCH "[0-9]+[.][0-9]+[.]sdk$" DEP_OSX_TARGET "${CMAKE_OSX_SYSROOT}")
string(REGEX MATCH "^[0-9]+[.][0-9]+" DEP_OSX_TARGET "${DEP_OSX_TARGET}")

if (NOT DEP_OSX_TARGET)
message(FATAL_ERROR "Could not determine OS X SDK version. Please use -DCMAKE_OSX_DEPLOYMENT_TARGET=<version>")
endif ()

message("OS X Deployment Target (inferred from default): ${DEP_OSX_TARGET}")
endif ()

include("deps-macos.cmake")
else ()
Expand Down
27 changes: 24 additions & 3 deletions deps/deps-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ ExternalProject_Add(dep_boost
INSTALL_COMMAND "" # b2 does that already
)

ExternalProject_Add(dep_libpng
EXCLUDE_FROM_ALL 1
URL "https://github.com/glennrp/libpng/archive/v1.6.36.tar.gz"
URL_HASH SHA256=5bef5a850a9255365a2dc344671b7e9ef810de491bd479c2506ac3c337e2d84f
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_ARGS
-DPNG_SHARED=OFF
-DPNG_TESTS=OFF
${DEP_CMAKE_OPTS}
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
INSTALL_COMMAND ""
)

ExternalProject_Add(dep_libopenssl
EXCLUDE_FROM_ALL 1
URL "https://github.com/openssl/openssl/archive/OpenSSL_1_1_0g.tar.gz"
Expand Down Expand Up @@ -88,16 +101,24 @@ ExternalProject_Add(dep_libcurl
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
)

if (DEP_WX_STABLE)
set(DEP_WX_URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.4/wxWidgets-3.0.4.tar.bz2")
set(DEP_WX_HASH "SHA256=96157f988d261b7368e5340afa1a0cad943768f35929c22841f62c25b17bf7f0")
else ()
set(DEP_WX_URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2")
set(DEP_WX_HASH "SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e")
endif()

ExternalProject_Add(dep_wxwidgets
EXCLUDE_FROM_ALL 1
URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2"
URL_HASH SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e
URL "${DEP_WX_URL}"
URL_HASH "${DEP_WX_HASH}"
BUILD_IN_SOURCE 1
PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/wxwidgets-pngprefix.h" src/png/pngprefix.h
CONFIGURE_COMMAND ./configure
"--prefix=${DESTDIR}/usr/local"
--disable-shared
--with-gtk=2
--with-gtk=2
--with-opengl
--enable-unicode
--enable-graphics_ctx
Expand Down
43 changes: 34 additions & 9 deletions deps/deps-macos.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@

# This ensures dependencies don't use SDK features which are not available in the version specified by Deployment target
# That can happen when one uses a recent SDK but specifies an older Deployment target
set(DEP_WERRORS_SDK "-Werror=partial-availability -Werror=unguarded-availability -Werror=unguarded-availability-new")

set(DEP_CMAKE_OPTS
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
"-DCMAKE_OSX_SYSROOT=${DEPS_OSX_SYSROOT}"
"-DCMAKE_OSX_DEPLOYMENT_TARGET=${DEPS_OSX_TARGET}"
"-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}"
"-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}"
"-DCMAKE_CXX_FLAGS=${DEP_WERRORS_SDK}"
"-DCMAKE_C_FLAGS=${DEP_WERRORS_SDK}"
)

include("deps-unix-common.cmake")


set(DEP_BOOST_OSX_TARGET "")
if (CMAKE_OSX_DEPLOYMENT_TARGET)
set(DEP_BOOST_OSX_TARGET "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif ()

ExternalProject_Add(dep_boost
EXCLUDE_FROM_ALL 1
URL "https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz"
Expand All @@ -23,8 +34,8 @@ ExternalProject_Add(dep_boost
variant=release
threading=multi
boost.locale.icu=off
"cflags=-fPIC -mmacosx-version-min=${DEPS_OSX_TARGET}"
"cxxflags=-fPIC -mmacosx-version-min=${DEPS_OSX_TARGET}"
"cflags=-fPIC ${DEP_BOOST_OSX_TARGET}"
"cxxflags=-fPIC ${DEP_BOOST_OSX_TARGET}"
install
INSTALL_COMMAND "" # b2 does that already
)
Expand Down Expand Up @@ -76,18 +87,32 @@ ExternalProject_Add(dep_libcurl
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
)

ExternalProject_Add(dep_libpng
EXCLUDE_FROM_ALL 1
URL "https://github.com/glennrp/libpng/archive/v1.6.36.tar.gz"
URL_HASH SHA256=5bef5a850a9255365a2dc344671b7e9ef810de491bd479c2506ac3c337e2d84f
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_ARGS
-DPNG_SHARED=OFF
-DPNG_TESTS=OFF
${DEP_CMAKE_OPTS}
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
INSTALL_COMMAND ""
)


ExternalProject_Add(dep_wxwidgets
EXCLUDE_FROM_ALL 1
URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2"
URL_HASH SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e
URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.2/wxWidgets-3.1.2.tar.bz2"
URL_HASH SHA256=4cb8d23d70f9261debf7d6cfeca667fc0a7d2b6565adb8f1c484f9b674f1f27a
BUILD_IN_SOURCE 1
PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/wxwidgets-pngprefix.h" src/png/pngprefix.h
CONFIGURE_COMMAND ./configure
CONFIGURE_COMMAND env "CXXFLAGS=${DEP_WERRORS_SDK}" "CFLAGS=${DEP_WERRORS_SDK}" ./configure
"--prefix=${DESTDIR}/usr/local"
--disable-shared
--with-osx_cocoa
"--with-macosx-version-min=${DEPS_OSX_TARGET}"
"--with-macosx-sdk=${DEPS_OSX_SYSROOT}"
--with-macosx-sdk=${CMAKE_OSX_SYSROOT}
"--with-macosx-version-min=${DEP_OSX_TARGET}"
--with-opengl
--with-regex=builtin
--with-libpng=builtin
Expand Down
13 changes: 0 additions & 13 deletions deps/deps-unix-common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,3 @@ ExternalProject_Add(dep_nlopt
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
INSTALL_COMMAND ""
)

ExternalProject_Add(dep_libpng
EXCLUDE_FROM_ALL 1
URL "http://prdownloads.sourceforge.net/libpng/libpng-1.6.35.tar.xz?download"
URL_HASH SHA256=23912ec8c9584917ed9b09c5023465d71709dce089be503c7867fec68a93bcd7
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_ARGS
-DPNG_SHARED=OFF
-DPNG_TESTS=OFF
${DEP_CMAKE_OPTS}
INSTALL_COMMAND make install "DESTDIR=${DESTDIR}"
INSTALL_COMMAND ""
)
Loading

0 comments on commit 1999974

Please sign in to comment.