Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/prusa/master_250' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Sep 16, 2022
2 parents d81e391 + ec2f533 commit a2efcd3
Show file tree
Hide file tree
Showing 200 changed files with 60,248 additions and 79,221 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "src/ArcWelderLib"]
path = src/ArcWelderLib
url = https://github.com/FormerLurker/ArcWelderLib.git
[submodule "resources/profiles"]
path = resources/profiles
url = https://github.com/slic3r/slic3r-profiles.git
36 changes: 4 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ 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)
option(SLIC3R_ASAN "Enable ASan on Clang and GCC" 0)
option(SLIC3R_ENABLE_FORMAT_STEP "Enable compilation of STEP file support" 1)
# If SLIC3R_FHS is 1 -> SLIC3R_DESKTOP_INTEGRATION is always 0, othrewise variable.
CMAKE_DEPENDENT_OPTION(SLIC3R_DESKTOP_INTEGRATION "Allow perfoming desktop integration during runtime" 1 "NOT SLIC3R_FHS" 0)

Expand Down Expand Up @@ -427,23 +428,6 @@ else()
target_link_libraries(libcurl INTERFACE crypt32)
endif()

if (SLIC3R_STATIC AND NOT SLIC3R_STATIC_EXCLUDE_CURL)
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(libcurl INTERFACE 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(libcurl INTERFACE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(libcurl INTERFACE ${OPENSSL_LIBRARIES})
endif()
endif()

## OPTIONAL packages

# Find eigen3 or use bundled version
Expand All @@ -456,21 +440,9 @@ if (NOT EIGEN3_FOUND)
endif ()
include_directories(BEFORE SYSTEM ${EIGEN3_INCLUDE_DIR})

# Find expat or use bundled version
# Always use the system libexpat on Linux.

find_package(EXPAT)

if (NOT EXPAT_FOUND)
add_library(expat STATIC
${LIBDIR}/expat/xmlparse.c
${LIBDIR}/expat/xmlrole.c
${LIBDIR}/expat/xmltok.c
)
set(EXPAT_FOUND 1)
set(EXPAT_INCLUDE_DIRS ${LIBDIR}/expat/)
set(EXPAT_LIBRARIES expat)
endif ()
# Find expat. We have our overriden FindEXPAT which exports libexpat target
# no matter what.
find_package(EXPAT REQUIRED)

find_package(PNG REQUIRED)

Expand Down
153 changes: 86 additions & 67 deletions cmake/modules/FindCURL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,82 +30,101 @@
# ``CURL_VERSION_STRING``
# The version of curl found.

# Look for the header file.
find_path(CURL_INCLUDE_DIR NAMES curl/curl.h)
mark_as_advanced(CURL_INCLUDE_DIR)
# First, prefer config scripts
set(_q "")
if(CURL_FIND_QUIETLY)
set(_q QUIET)
endif()
find_package(CURL ${CURL_FIND_VERSION} CONFIG ${_q})

if(NOT CURL_LIBRARY)
# Look for the library (sorted from most current/relevant entry to least).
find_library(CURL_LIBRARY_RELEASE NAMES
curl
# Windows MSVC prebuilts:
curllib
libcurl_imp
curllib_static
# Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
libcurl
# Static library on Windows
libcurl_a
)
mark_as_advanced(CURL_LIBRARY_RELEASE)
if(NOT CURL_FIND_QUIETLY)
if (NOT CURL_FOUND)
message(STATUS "Falling back to MODULE search for CURL...")
else()
message(STATUS "CURL found in ${CURL_DIR}")
endif()
endif()

find_library(CURL_LIBRARY_DEBUG NAMES
# Windows MSVC CMake builds in debug configuration on vcpkg:
libcurl-d_imp
libcurl-d
# Static library on Windows, compiled in debug mode
libcurl_a_debug
)
mark_as_advanced(CURL_LIBRARY_DEBUG)
if (NOT CURL_FOUND)

include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations_SLIC3R.cmake)
select_library_configurations_SLIC3R(CURL)
endif()
# Look for the header file.
find_path(CURL_INCLUDE_DIR NAMES curl/curl.h)
mark_as_advanced(CURL_INCLUDE_DIR)

if(CURL_INCLUDE_DIR)
foreach(_curl_version_header curlver.h curl.h)
if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}")
file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"")
if(NOT CURL_LIBRARY)
# Look for the library (sorted from most current/relevant entry to least).
find_library(CURL_LIBRARY_RELEASE NAMES
curl
# Windows MSVC prebuilts:
curllib
libcurl_imp
curllib_static
# Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
libcurl
# Static library on Windows
libcurl_a
)
mark_as_advanced(CURL_LIBRARY_RELEASE)

string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}")
unset(curl_version_str)
break()
endif()
endforeach()
endif()
find_library(CURL_LIBRARY_DEBUG NAMES
# Windows MSVC CMake builds in debug configuration on vcpkg:
libcurl-d_imp
libcurl-d
# Static library on Windows, compiled in debug mode
libcurl_a_debug
)
mark_as_advanced(CURL_LIBRARY_DEBUG)

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs_SLIC3R.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS_SLIC3R(CURL
REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
VERSION_VAR CURL_VERSION_STRING)
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations_SLIC3R.cmake)
select_library_configurations_SLIC3R(CURL)
endif()

if(CURL_FOUND)
set(CURL_LIBRARIES ${CURL_LIBRARY})
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
if(CURL_INCLUDE_DIR)
foreach(_curl_version_header curlver.h curl.h)
if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}")
file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"")

if(NOT TARGET CURL::libcurl)
add_library(CURL::libcurl UNKNOWN IMPORTED)
set_target_properties(CURL::libcurl PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}")
string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}")
unset(curl_version_str)
break()
endif()
endforeach()
endif()

if(EXISTS "${CURL_LIBRARY}")
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${CURL_LIBRARY}")
endif()
if(CURL_LIBRARY_RELEASE)
set_property(TARGET CURL::libcurl APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}")
endif()
if(CURL_LIBRARY_DEBUG)
set_property(TARGET CURL::libcurl APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs_SLIC3R.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS_SLIC3R(CURL
REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
VERSION_VAR CURL_VERSION_STRING)

if(CURL_FOUND)
set(CURL_LIBRARIES ${CURL_LIBRARY})
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})

if(NOT TARGET CURL::libcurl)
add_library(CURL::libcurl UNKNOWN IMPORTED)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}")
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}")

if(EXISTS "${CURL_LIBRARY}")
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${CURL_LIBRARY}")
endif()
if(CURL_LIBRARY_RELEASE)
set_property(TARGET CURL::libcurl APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}")
endif()
if(CURL_LIBRARY_DEBUG)
set_property(TARGET CURL::libcurl APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}")
endif()
endif()
endif()
endif()

endif (NOT CURL_FOUND)
36 changes: 36 additions & 0 deletions cmake/modules/FindEXPAT.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
set(_q "")
if(EXPAT_FIND_QUIETLY)
set(_q QUIET)
endif()
find_package(EXPAT ${EXPAT_FIND_VERSION} CONFIG ${_q})

if(NOT EXPAT_FIND_QUIETLY)
if (NOT EXPAT_FOUND)
message(STATUS "Falling back to MODULE search for EXPAT...")
else()
message(STATUS "EXPAT found in ${EXPAT_DIR}")
endif()
endif()

if (NOT EXPAT_FOUND)
set(_modpath ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "")
include(FindEXPAT)
set(CMAKE_MODULE_PATH ${_modpath})

if (NOT TARGET EXPAT::EXPAT)
add_library(EXPAT::EXPAT INTERFACE)
target_link_libraries(EXPAT::EXPAT INTERFACE ${EXPAT_LIBRARIES})
target_include_directories(EXPAT::EXPAT INTERFACE ${EXPAT_INCLUDE_DIRS})
endif ()
endif()

if (EXPAT_FOUND AND NOT TARGET EXPAT::EXPAT)
add_library(libexpat INTERFACE)
add_library(EXPAT::EXPAT ALIAS libexpat)
target_link_libraries(libexpat INTERFACE expat::expat)
if (NOT EXPAT_LIBRARIES)
set(EXPAT_LIBRARIES expat::expat CACHE STRING "")
endif ()
endif ()

30 changes: 18 additions & 12 deletions deps/Boost/Boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ include(ProcessorCount)
ProcessorCount(NPROC)
file(TO_NATIVE_PATH ${DESTDIR}/usr/local/ _prefix)

set(_boost_flags "")
if (UNIX)
set(_boost_flags "cflags=-fPIC;cxxflags=-fPIC")
endif ()

if(APPLE)
set(_boost_flags
"cflags=-fPIC -mmacosx-version-min=${DEP_OSX_TARGET};"
"cxxflags=-fPIC -mmacosx-version-min=${DEP_OSX_TARGET};"
"mflags=-fPIC -mmacosx-version-min=${DEP_OSX_TARGET};"
"mmflags=-fPIC -mmacosx-version-min=${DEP_OSX_TARGET}")
endif()

set(_boost_variants "")
if(CMAKE_BUILD_TYPE)
Expand All @@ -90,6 +102,11 @@ if (NOT _boost_variants)
set(_boost_variants release)
endif()

set(_boost_layout system)
if (MSVC)
set(_boost_layout versioned)
endif ()

if (IS_CROSS_COMPILE AND APPLE)
if (${CMAKE_OSX_ARCHITECTURES} MATCHES "arm")
message(STATUS "Compiling Boost for arm64.")
Expand All @@ -108,23 +125,12 @@ if (IS_CROSS_COMPILE AND APPLE)
set(_boost_linkflags "linkflags=${_arch_flags}")
endif ()

set(_boost_flags "")
if(APPLE)
set(_boost_flags
"cflags=-fPIC ${_arch_flags} -mmacosx-version-min=${DEP_OSX_TARGET};"
"cxxflags=-fPIC ${_arch_flags} -mmacosx-version-min=${DEP_OSX_TARGET};"
"mflags=-fPIC ${_arch_flags} -mmacosx-version-min=${DEP_OSX_TARGET};"
"mmflags=-fPIC ${_arch_flags} -mmacosx-version-min=${DEP_OSX_TARGET}")
elseif (UNIX)
set(_boost_flags "cflags=-fPIC;cxxflags=-fPIC")
endif()

set(_build_cmd ${_build_cmd}
${_boost_flags}
${_boost_linkflags}
-j${NPROC}
${_libs}
--layout=versioned
--layout=${_boost_layout}
--debug-configuration
toolset=${_boost_toolset}
address-model=${_bits}
Expand Down
14 changes: 12 additions & 2 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ function(prusaslicer_add_cmake_project projectname)
if (MSVC)
set(_gen CMAKE_GENERATOR "${DEP_MSVC_GEN}" CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}")
set(_build_j "/m")
if (${projectname} STREQUAL "OCCT")
set(_build_j "/m:1")
endif ()
endif ()

if (NOT IS_CROSS_COMPILE OR NOT APPLE)
Expand Down Expand Up @@ -218,22 +221,29 @@ include(CGAL/CGAL.cmake)
include(NLopt/NLopt.cmake)

include(OpenSSL/OpenSSL.cmake)
include(CURL/CURL.cmake)

set(CURL_PKG "")
if (NOT CURL_FOUND)
include(CURL/CURL.cmake)
set(CURL_PKG dep_CURL)
endif ()

include(JPEG/JPEG.cmake)
include(TIFF/TIFF.cmake)
include(wxWidgets/wxWidgets.cmake)
include(OCCT/OCCT.cmake)

set(_dep_list
dep_Boost
dep_TBB
dep_CURL
${CURL_PKG}
dep_wxWidgets
dep_Cereal
dep_NLopt
dep_OpenVDB
dep_OpenCSG
dep_CGAL
dep_OCCT
${PNG_PKG}
${ZLIB_PKG}
${EXPAT_PKG}
Expand Down
14 changes: 8 additions & 6 deletions deps/CURL/CURL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
)
endif ()

if (BUILD_SHARED_LIBS)
set(_curl_static OFF)
else()
set(_curl_static ON)
endif()
set(_patch_command "")
if (UNIX AND NOT APPLE)
# On non-apple UNIX platforms, finding the location of OpenSSL certificates is necessary at runtime, as there is no standard location usable across platforms.
# The OPENSSL_CERT_OVERRIDE flag is understood by PrusaSlicer and will trigger the search of certificates at initial application launch.
# Then ask the user for consent about the correctness of the found location.
set (_patch_command echo set_target_properties(CURL::libcurl PROPERTIES INTERFACE_COMPILE_DEFINITIONS OPENSSL_CERT_OVERRIDE) >> CMake/curl-config.cmake.in)
endif ()

if (IS_CROSS_COMPILE AND APPLE)
# TODO
Expand All @@ -66,10 +68,10 @@ prusaslicer_add_cmake_project(CURL
DEPENDS ${ZLIB_PKG}
# PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df &&
# ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/curl-mods.patch
PATCH_COMMAND "${_patch_command}"
CMAKE_ARGS
-DBUILD_TESTING:BOOL=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCURL_STATICLIB=${_curl_static}
${_curl_platform_flags}
)

Expand Down
Loading

0 comments on commit a2efcd3

Please sign in to comment.