123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570 |
- cmake_minimum_required(VERSION 3.13)
- project(Slic3r)
- 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)
- if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
- message(STATUS "No build type selected, default to Release")
- set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE)
- endif()
- if(DEFINED ENV{SLIC3R_STATIC})
- set(SLIC3R_STATIC_INITIAL $ENV{SLIC3R_STATIC})
- else()
- if (MSVC OR MINGW OR APPLE)
- set(SLIC3R_STATIC_INITIAL 1)
- else()
- set(SLIC3R_STATIC_INITIAL 0)
- endif()
- endif()
- if(NOT WIN32)
- # Add DEBUG flags to debug builds.
- # Also add -g to RELWITHDEBINFO on non-win32
- set(_CC_DEBUG_FLAGS $<$<CONFIG:DEBUG>:-DwxDEBUG_LEVEL=1>
- $<$<CONFIG:DEBUG>:-g>
- $<$<CONFIG:RELWITHDEBINFO>:-g>
- )
- 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)
- option(SLIC3R_ASAN "Enable ASan on Clang and GCC" 0)
- option(SLIC3R_ALPHA "Development/Experimental version; use separate profile directory." OFF)
- set(SLIC3R_GTK "2" CACHE STRING "GTK version to use with wxWidgets on Linux")
- if (APPLE)
- set(CMAKE_FIND_FRAMEWORK LAST)
- set(CMAKE_FIND_APPBUNDLE LAST)
- endif ()
- # Proposal for C++ unit tests and sandboxes
- 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 (SLIC3R_GUI)
- add_definitions(-DSLIC3R_GUI)
- endif ()
- if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
- set(IS_CLANG_CL TRUE)
- # clang-cl can interpret SYSTEM header paths if -imsvc is used
- set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-imsvc")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall \
- -Wno-old-style-cast -Wno-reserved-id-macro -Wno-c++98-compat-pedantic")
- else ()
- set(IS_CLANG_CL FALSE)
- endif ()
- if (MSVC)
- if (SLIC3R_MSVC_COMPILE_PARALLEL AND NOT IS_CLANG_CL)
- add_compile_options(/MP)
- endif ()
- # /bigobj (Increase Number of Sections in .Obj file)
- # error C3859: virtual memory range for PCH exceeded; please recompile with a command line option of '-Zm90' or greater
- # Generate symbols at every build target, even for the release.
- add_compile_options(-bigobj -Zm520 /Zi)
- # Disable STL4007: Many result_type typedefs and all argument_type, first_argument_type, and second_argument_type typedefs are deprecated in C++17.
- #FIXME Remove this line after eigen library adapts to the new C++17 adaptor rules.
- add_compile_options(-D_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING)
- endif ()
- if (MINGW)
- add_compile_options(-Wa,-mbig-obj)
- endif ()
- # Display and check CMAKE_PREFIX_PATH
- message(STATUS "SLIC3R_STATIC: ${SLIC3R_STATIC}")
- if (NOT "${CMAKE_PREFIX_PATH}" STREQUAL "")
- message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH} (from cache or command line)")
- set(PREFIX_PATH_CHECK ${CMAKE_PREFIX_PATH})
- elseif (NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
- message(STATUS "CMAKE_PREFIX_PATH: $ENV{CMAKE_PREFIX_PATH} (from environment)")
- set(PREFIX_PATH_CHECK $ENV{CMAKE_PREFIX_PATH})
- else ()
- message(STATUS "CMAKE_PREFIX_PATH: (default)")
- endif ()
- foreach (DIR ${PREFIX_PATH_CHECK})
- if (NOT EXISTS "${DIR}")
- message(WARNING "CMAKE_PREFIX_PATH element doesn't exist: ${DIR}")
- endif ()
- endforeach ()
- # Add our own cmake module path.
- list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/)
- enable_testing ()
- # Enable C++17 language standard.
- set(CMAKE_CXX_STANDARD 17)
- set(CMAKE_CXX_STANDARD_REQUIRED ON)
- # To be able to link libslic3r with the Perl XS module.
- # Once we get rid of Perl and libslic3r is linked statically, we can get rid of -fPIC
- set(CMAKE_POSITION_INDEPENDENT_CODE ON)
- # WIN10SDK_PATH is used to point CMake to the WIN10 SDK installation directory.
- # We pick it from environment if it is not defined in another way
- if(WIN32)
- if(NOT DEFINED WIN10SDK_PATH)
- if(DEFINED ENV{WIN10SDK_PATH})
- set(WIN10SDK_PATH "$ENV{WIN10SDK_PATH}")
- endif()
- endif()
- if(DEFINED WIN10SDK_PATH AND NOT EXISTS "${WIN10SDK_PATH}/include/winrt/windows.graphics.printing3d.h")
- message("WIN10SDK_PATH is invalid: ${WIN10SDK_PATH}")
- message("${WIN10SDK_PATH}/include/winrt/windows.graphics.printing3d.h was not found")
- message("STL fixing by the Netfabb service will not be compiled")
- unset(WIN10SDK_PATH)
- endif()
- if(WIN10SDK_PATH)
- message("Building with Win10 Netfabb STL fixing service support")
- add_definitions(-DHAS_WIN10SDK)
- include_directories("${WIN10SDK_PATH}/Include")
- else()
- message("Building without Win10 Netfabb STL fixing service support")
- endif()
- endif()
- if (APPLE)
- 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 ()
- endif ()
- if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
- 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()
- # Boost on Raspberry-Pi does not link to pthreads.
- set(THREADS_PREFER_PTHREAD_FLAG ON)
- find_package(Threads REQUIRED)
- find_package(DBus REQUIRED)
- include_directories(${DBUS_INCLUDE_DIRS})
- 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.
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals" )
- endif()
- if (NOT MSVC AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
- if (NOT MINGW)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" )
- endif ()
- 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 (GCC only supports it since 6.1)
- # https://eigen.tuxfamily.org/bz/show_bug.cgi?id=1221
- if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0)
- add_compile_options(-Wno-ignored-attributes) # Tamas: Eigen include dirs are marked as SYSTEM
- endif()
- #GCC generates loads of -Wunknown-pragmas when compiling igl. The fix is not easy due to a bug in gcc, see
- # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66943 or
- # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
- # We will turn the warning of for GCC for now:
- if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- add_compile_options(-Wno-unknown-pragmas)
- endif()
- if (SLIC3R_ASAN)
- add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
- set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address")
- if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan")
- endif ()
- endif ()
- endif()
- if (APPLE)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=partial-availability -Werror=unguarded-availability -Werror=unguarded-availability-new")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=partial-availability -Werror=unguarded-availability -Werror=unguarded-availability-new")
- endif ()
- # Where all the bundled libraries reside?
- 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)
- if(WIN32)
- add_definitions(-D_USE_MATH_DEFINES -D_WIN32 -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
- if(MSVC)
- # BOOST_ALL_NO_LIB: Avoid the automatic linking of Boost libraries on Windows. Rather rely on explicit linking.
- add_definitions(-DBOOST_ALL_NO_LIB -DBOOST_USE_WINAPI_VERSION=0x601 -DBOOST_SYSTEM_USE_UTF8 )
- endif(MSVC)
- endif(WIN32)
- add_definitions(-DwxUSE_UNICODE -D_UNICODE -DUNICODE -DWXINTL_NO_GETTEXT_MACRO)
- # Disable unsafe implicit wxString to const char* / std::string and vice versa. This implicit conversion breaks the UTF-8 encoding quite often.
- add_definitions(-DwxNO_UNSAFE_WXSTRING_CONV)
- if (SLIC3R_PROFILE)
- message("Slic3r will be built with a Shiny invasive profiler")
- add_definitions(-DSLIC3R_PROFILE)
- endif ()
- # Disable optimization even with debugging on.
- if (0)
- message(STATUS "Perl compiled without optimization. Disabling optimization for the Slic3r build.")
- message("Old CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
- message("Old CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELEASE}")
- message("Old CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS_RELEASE}")
- set(CMAKE_CXX_FLAGS_RELEASE "/MD /Od /Zi /EHsc /DWIN32 /DTBB_USE_ASSERT")
- set(CMAKE_C_FLAGS_RELEASE "/MD /Od /Zi /DWIN32 /DTBB_USE_ASSERT")
- set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Od /Zi /EHsc /DWIN32 /DTBB_USE_ASSERT")
- set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MD /Od /Zi /DWIN32 /DTBB_USE_ASSERT")
- set(CMAKE_CXX_FLAGS "/MD /Od /Zi /EHsc /DWIN32 /DTBB_USE_ASSERT")
- set(CMAKE_C_FLAGS "/MD /Od /Zi /DWIN32 /DTBB_USE_ASSERT")
- endif()
- # Find and configure boost
- if(SLIC3R_STATIC)
- # Use static boost libraries.
- set(Boost_USE_STATIC_LIBS ON)
- # Use boost libraries linked statically to the C++ runtime.
- # set(Boost_USE_STATIC_RUNTIME ON)
- endif()
- #set(Boost_DEBUG ON)
- # set(Boost_COMPILER "-mgw81")
- if(NOT WIN32)
- # boost::process was introduced first in version 1.64.0
- set(MINIMUM_BOOST_VERSION "1.64.0")
- endif()
- set(_boost_components "system;filesystem;thread;log;locale;regex;chrono;atomic;date_time")
- find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS ${_boost_components})
- # boost compile only in release & debug. We have to force the release version for RELWITHDEBINFO compilation
- if (MSVC)
- set_target_properties(${Boost_LIBRARIES} PROPERTIES MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELEASE)
- endif()
- add_library(boost_libs INTERFACE)
- add_library(boost_headeronly INTERFACE)
- if (APPLE)
- # BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339
- target_compile_definitions(boost_headeronly INTERFACE BOOST_ASIO_DISABLE_KQUEUE)
- endif()
- if(NOT SLIC3R_STATIC)
- target_compile_definitions(boost_headeronly INTERFACE BOOST_LOG_DYN_LINK)
- endif()
- function(slic3r_remap_configs targets from_Cfg to_Cfg)
- if(MSVC)
- string(TOUPPER ${from_Cfg} from_CFG)
-
- foreach(tgt ${targets})
- if(TARGET ${tgt})
- set_target_properties(${tgt} PROPERTIES MAP_IMPORTED_CONFIG_${from_CFG} ${to_Cfg})
- endif()
- endforeach()
- endif()
- endfunction()
- if(TARGET Boost::system)
- message(STATUS "Boost::boost exists")
- target_link_libraries(boost_headeronly INTERFACE Boost::boost)
- # Only from cmake 3.12
- # list(TRANSFORM _boost_components PREPEND Boost:: OUTPUT_VARIABLE _boost_targets)
- set(_boost_targets "")
- foreach(comp ${_boost_components})
- list(APPEND _boost_targets "Boost::${comp}")
- endforeach()
- target_link_libraries(boost_libs INTERFACE
- boost_headeronly # includes the custom compile definitions as well
- ${_boost_targets}
- )
- slic3r_remap_configs("${_boost_targets}" RelWithDebInfo Release)
- else()
- target_include_directories(boost_headeronly INTERFACE ${Boost_INCLUDE_DIRS})
- target_link_libraries(boost_libs INTERFACE boost_headeronly ${Boost_LIBRARIES})
- endif()
- # Find and configure intel-tbb
- if(SLIC3R_STATIC)
- set(TBB_STATIC 1)
- endif()
- set(TBB_DEBUG 1)
- find_package(TBB REQUIRED)
- # include_directories(${TBB_INCLUDE_DIRS})
- # add_definitions(${TBB_DEFINITIONS})
- # if(MSVC)
- # # Suppress implicit linking of the TBB libraries by the Visual Studio compiler.
- # add_definitions(-D__TBB_NO_IMPLICIT_LINKAGE)
- # endif()
- # The Intel TBB library will use the std::exception_ptr feature of C++11.
- # add_definitions(-DTBB_USE_CAPTURED_EXCEPTION=0)
- find_package(CURL REQUIRED)
- add_library(libcurl INTERFACE)
- target_link_libraries(libcurl INTERFACE CURL::libcurl)
- if (NOT WIN32)
- # Required by libcurl
- find_package(ZLIB REQUIRED)
- target_link_libraries(libcurl INTERFACE ZLIB::ZLIB)
- endif()
- 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(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
- if (NOT SLIC3R_STATIC)
- find_package(Eigen3 3.3)
- endif ()
- if (NOT EIGEN3_FOUND)
- set(EIGEN3_FOUND 1)
- set(EIGEN3_INCLUDE_DIR ${LIBDIR}/eigen/)
- 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_package(PNG REQUIRED)
- set(OpenGL_GL_PREFERENCE "LEGACY")
- find_package(OpenGL REQUIRED)
- # Find glew or use bundled version
- if (SLIC3R_STATIC)
- set(GLEW_USE_STATIC_LIBS ON)
- set(GLEW_VERBOSE ON)
- endif()
- find_package(GLEW)
- if (NOT GLEW_FOUND)
- message(STATUS "GLEW not found, using bundled version.")
- add_library(glew STATIC ${LIBDIR}/glew/src/glew.c)
- set(GLEW_FOUND TRUE)
- set(GLEW_INCLUDE_DIRS ${LIBDIR}/glew/include/)
- target_compile_definitions(glew PUBLIC GLEW_STATIC)
- target_include_directories(glew PUBLIC ${GLEW_INCLUDE_DIRS})
- add_library(GLEW::GLEW ALIAS glew)
- endif ()
- # Find the Cereal serialization library
- find_package(cereal REQUIRED)
- # l10n
- set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/localization")
- add_custom_target(gettext_make_pot
- COMMAND xgettext --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --debug
- -f "${L10N_DIR}/list.txt"
- -o "${L10N_DIR}/Slic3r.pot"
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
- COMMENT "Generate pot file from strings in the source tree"
- )
- add_custom_target(gettext_po_to_mo
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
- COMMENT "Generate localization po files (binary) from mo files (texts)"
- )
- file(GLOB L10N_PO_FILES "${L10N_DIR}/*/Slic3r*.po")
- foreach(po_file ${L10N_PO_FILES})
- GET_FILENAME_COMPONENT(po_dir "${po_file}" DIRECTORY)
- SET(mo_file "${po_dir}/Slic3r.mo")
- add_custom_command(
- TARGET gettext_po_to_mo PRE_BUILD
- COMMAND msgfmt ARGS -o ${mo_file} ${po_file}
- DEPENDS ${po_file}
- )
- endforeach()
- find_package(NLopt 1.4 REQUIRED)
- if(SLIC3R_STATIC)
- set(OPENVDB_USE_STATIC_LIBS ON)
- set(USE_BLOSC TRUE)
- endif()
- find_package(OpenVDB 5.0 REQUIRED COMPONENTS openvdb)
- if(OpenVDB_FOUND)
- slic3r_remap_configs(IlmBase::Half RelWithDebInfo Release)
- slic3r_remap_configs(Blosc::blosc RelWithDebInfo Release)
- endif()
- set(TOP_LEVEL_PROJECT_DIR ${PROJECT_SOURCE_DIR})
- function(prusaslicer_copy_dlls target)
- if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
- set(_bits 64)
- elseif ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
- set(_bits 32)
- endif ()
-
- get_property(_is_multi GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
- get_target_property(_alt_out_dir ${target} RUNTIME_OUTPUT_DIRECTORY)
- if (_alt_out_dir)
- set (_out_dir "${_alt_out_dir}")
- elseif (_is_multi)
- set (_out_dir "$<TARGET_PROPERTY:${target},BINARY_DIR>/$<CONFIG>")
- else ()
- set (_out_dir "$<TARGET_PROPERTY:${target},BINARY_DIR>")
- endif ()
-
- # This has to be a separate target due to the windows command line lenght limits
- add_custom_command(TARGET ${target} POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy ${TOP_LEVEL_PROJECT_DIR}/deps/GMP/gmp/lib/win${_bits}/libgmp-10.dll ${_out_dir}
- COMMENT "Copy gmp runtime to build tree"
- VERBATIM)
-
- add_custom_command(TARGET ${target} POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy ${TOP_LEVEL_PROJECT_DIR}/deps/MPFR/mpfr/lib/win${_bits}/libmpfr-4.dll ${_out_dir}
- COMMENT "Copy mpfr runtime to build tree"
- VERBATIM)
- endfunction()
- # libslic3r, Slic3r GUI and the Slic3r executable.
- add_subdirectory(src)
- set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Slic3r_app_console)
- # Perl bindings, currently only used for the unit / integration tests of libslic3r.
- # Also runs the unit / integration tests.
- #FIXME Port the tests into C++ to finally get rid of the Perl!
- if (SLIC3R_PERL_XS)
- add_subdirectory(xs)
- endif ()
- if(SLIC3R_BUILD_SANDBOXES)
- add_subdirectory(sandboxes)
- endif()
- if(SLIC3R_BUILD_TESTS)
- add_subdirectory(tests)
- endif()
- if (NOT WIN32 AND NOT APPLE)
- configure_file(${LIBDIR}/platform/unix/build_appimage.sh.in ${CMAKE_CURRENT_BINARY_DIR}/build_appimage.sh @ONLY)
- endif()
- # Resources install target, configure fhs.hpp on UNIX
- if (WIN32)
- install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/resources")
- elseif (SLIC3R_FHS)
- # CMAKE_INSTALL_FULL_DATAROOTDIR: read-only architecture-independent data root (share)
- set(SLIC3R_FHS_RESOURCES "${CMAKE_INSTALL_FULL_DATAROOTDIR}/${SLIC3R_APP_KEY}")
- install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${SLIC3R_FHS_RESOURCES}")
- configure_file(${LIBDIR}/platform/unix/Slic3r.desktop.in ${LIBDIR_BIN}/${SLIC3R_APP_KEY}.desktop @ONLY)
- configure_file(${LIBDIR}/platform/unix/Gcodeviewer.desktop.in ${LIBDIR_BIN}/${SLIC3R_APP_KEY}-Gcodeviewer.desktop @ONLY)
- install(FILES ${LIBDIR_BIN}/${SLIC3R_APP_KEY}.desktop DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/applications)
- install(FILES ${LIBDIR_BIN}/${SLIC3R_APP_KEY}-Gcodeviewer.desktop DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/applications)
- install(FILES resources/icons/${SLIC3R_APP_KEY}_192px.png DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/pixmaps RENAME ${SLIC3R_APP_KEY}.png)
- install(FILES resources/icons/${SLIC3R_APP_KEY}-gcodeviewer_192px.png DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/pixmaps RENAME ${SLIC3R_APP_KEY}-gcodeviewer.png)
- else ()
- install(FILES ${LIBDIR}/platform/unix/Slic3r.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/resources/applications)
- install(FILES ${LIBDIR}/platform/unix/Gcodeviewer.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/resources/applications)
- install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/resources")
- endif ()
- configure_file(${LIBDIR}/platform/unix/fhs.hpp.in ${LIBDIR_BIN}/platform/unix/fhs.hpp)
- if (WIN32)
- else ()
- set(CPACK_GENERATOR "STGZ;TGZ;TZ")
- set(CPACK_NSIS_DISPLAY_NAME "${SLIC3R_APP_NAME} ${SLIC3R_VERSION}")
- set(CPACK_OUTPUT_CONFIG_FILE "${CMAKE_SOURCE_DIR}/cmake/CPackConfig.cmake")
- set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
- set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CMake is a build tool")
- set(CPACK_PACKAGE_EXECUTABLES "${SLIC3R_APP_CMD}")
- set(CPACK_PACKAGE_FILE_NAME "${SLIC3R_APP_KEY}-${SLIC3R_VERSION}-Linux-x86_64")
- set(CPACK_PACKAGE_INSTALL_DIRECTORY "${SLIC3R_APP_KEY} ${SLIC3R_VERSION}")
- set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${SLIC3R_BUILD_ID}")
- set(CPACK_PACKAGE_NAME "${SLIC3R_APP_KEY}")
- set(CPACK_PACKAGE_VENDOR "${SLIC3R_APP_NAME}")
- set(CPACK_PACKAGE_VERSION "${SLIC3R_VERSION_FULL}")
- set(CPACK_PACKAGE_VERSION_MAJOR "2")
- set(CPACK_PACKAGE_VERSION_MINOR "0")
- set(CPACK_PACKAGE_VERSION_PATCH "0")
- set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
- set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
- set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
- set(CPACK_SOURCE_GENERATOR "TGZ;TZ")
- set(CPACK_SOURCE_PACKAGE_FILE_NAME "${SLIC3R_APP_KEY}-${SLIC3R_VERSION_FULL}")
- set(CPACK_SOURCE_STRIP_FILES "")
- set(CPACK_STRIP_FILES "bin/${SLIC3R_APP_CMD}")
- set(CPACK_SYSTEM_NAME "Linux-x86_64")
- set(CPACK_TOPLEVEL_TAG "Linux-x86_64")
- endif()
- include(CPack)
|