diff --git a/CMakeLists.txt b/CMakeLists.txt index de435813d..b4e0224f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,17 +240,34 @@ if(NOT WIN32) set(MINIMUM_BOOST_VERSION "1.64.0") endif() find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS system filesystem thread log locale regex) -if(Boost_FOUND) -# message("Boost include dir: ${Boost_INCLUDE_DIRS}") -# message("Boost library dirs: ${Boost_LIBRARY_DIRS}") -# message("Boost libraries: ${Boost_LIBRARIES}") - if (APPLE) - # BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339 - add_definitions(-DBOOST_ASIO_DISABLE_KQUEUE) - endif() - if(NOT SLIC3R_STATIC) - add_definitions(-DBOOST_LOG_DYN_LINK) - 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() + +if(TARGET Boost::system) + message(STATUS "Boost::boost exists") + target_link_libraries(boost_headeronly INTERFACE Boost::boost) + target_link_libraries(boost_libs INTERFACE + boost_headeronly # includes the custom compile definitions as well + Boost::system + Boost::filesystem + Boost::thread + Boost::log + Boost::locale + Boost::regex + ) +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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f2483eca..724063466 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -139,7 +139,7 @@ if (MSVC) target_compile_definitions(PrusaSlicer_app_gui PRIVATE -DSLIC3R_WRAPPER_NOCONSOLE) add_dependencies(PrusaSlicer_app_gui PrusaSlicer) set_target_properties(PrusaSlicer_app_gui PROPERTIES OUTPUT_NAME "prusa-slicer") - target_include_directories(PrusaSlicer_app_gui SYSTEM PUBLIC ${Boost_INCLUDE_DIRS}) + target_link_libraries(PrusaSlicer_app_gui PRIVATE boost_headeronly) add_executable(PrusaSlicer_app_console PrusaSlicer_app_msvc.cpp ${CMAKE_CURRENT_BINARY_DIR}/PrusaSlicer.rc) # Generate debug symbols even in release mode. @@ -147,7 +147,7 @@ if (MSVC) target_compile_definitions(PrusaSlicer_app_console PRIVATE -DSLIC3R_WRAPPER_CONSOLE) add_dependencies(PrusaSlicer_app_console PrusaSlicer) set_target_properties(PrusaSlicer_app_console PROPERTIES OUTPUT_NAME "prusa-slicer-console") - target_include_directories(PrusaSlicer_app_console SYSTEM PUBLIC ${Boost_INCLUDE_DIRS}) + target_link_libraries(PrusaSlicer_app_console PRIVATE boost_headeronly) endif () # Link the resources dir to where Slic3r GUI expects it diff --git a/src/admesh/CMakeLists.txt b/src/admesh/CMakeLists.txt index 941a7eeb5..7d0177782 100644 --- a/src/admesh/CMakeLists.txt +++ b/src/admesh/CMakeLists.txt @@ -11,4 +11,4 @@ add_library(admesh STATIC util.cpp ) -target_include_directories(admesh SYSTEM PRIVATE ${Boost_INCLUDE_DIRS}) +target_link_libraries(admesh PRIVATE boost_headeronly) diff --git a/src/boost/CMakeLists.txt b/src/boost/CMakeLists.txt index aae87340b..12fe6b4e5 100644 --- a/src/boost/CMakeLists.txt +++ b/src/boost/CMakeLists.txt @@ -19,6 +19,6 @@ add_library(nowide STATIC nowide/windows.hpp ) -target_include_directories(nowide SYSTEM PUBLIC ${Boost_INCLUDE_DIRS}) +target_link_libraries(nowide PUBLIC boost_headeronly) diff --git a/src/libnest2d/include/libnest2d/backends/clipper/CMakeLists.txt b/src/libnest2d/include/libnest2d/backends/clipper/CMakeLists.txt index e20cbc70d..cf8a37350 100644 --- a/src/libnest2d/include/libnest2d/backends/clipper/CMakeLists.txt +++ b/src/libnest2d/include/libnest2d/backends/clipper/CMakeLists.txt @@ -56,12 +56,12 @@ endif() # Clipper backend is not enough on its own, it still needs some functions # from Boost geometry -if(NOT Boost_INCLUDE_DIRS_FOUND) +if(NOT Boost_FOUND) find_package(Boost 1.58 REQUIRED) # TODO automatic download of boost geometry headers endif() -target_include_directories(clipperBackend SYSTEM INTERFACE ${Boost_INCLUDE_DIRS} ) +target_link_libraries(clipperBackend INTERFACE Boost::boost ) #target_sources(ClipperBackend INTERFACE # ${CMAKE_CURRENT_SOURCE_DIR}/geometries.hpp # ${CMAKE_CURRENT_SOURCE_DIR}/clipper_polygon.hpp diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index 833b1ae62..312a82c4c 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -182,13 +182,12 @@ if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY) endif () target_compile_definitions(libslic3r PUBLIC -DUSE_TBB) -target_include_directories(libslic3r SYSTEM PUBLIC ${Boost_INCLUDE_DIRS}) target_include_directories(libslic3r PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${LIBNEST2D_INCLUDES} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(libslic3r libnest2d admesh miniz - ${Boost_LIBRARIES} + boost_libs clipper nowide ${EXPAT_LIBRARIES} diff --git a/src/slic3r/GUI/ProgressStatusBar.hpp b/src/slic3r/GUI/ProgressStatusBar.hpp index 225b0331e..8c6596475 100644 --- a/src/slic3r/GUI/ProgressStatusBar.hpp +++ b/src/slic3r/GUI/ProgressStatusBar.hpp @@ -3,6 +3,7 @@ #include #include +#include class wxTimer; class wxGauge; diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 4696badc4..aaf943970 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -119,8 +119,6 @@ target_include_directories(XS PRIVATE src ${LIBDIR}/libslic3r) target_compile_definitions(XS PRIVATE -DSLIC3RXS) set_target_properties(XS PROPERTIES PREFIX "") # Prevent cmake from generating libXS.so instead of XS.so -target_link_libraries(XS ${Boost_LIBRARIES}) - if (APPLE) # -liconv: boost links to libiconv by default target_link_libraries(XS "-liconv -framework IOKit" "-framework CoreFoundation" -lc++) @@ -156,12 +154,6 @@ if (WIN32) target_link_libraries(XS ${PERL_LIBRARY}) endif() -target_link_libraries(XS ${Boost_LIBRARIES}) -target_link_libraries(XS ${TBB_LIBRARIES}) -# target_link_libraries(XS ${wxWidgets_LIBRARIES}) -target_link_libraries(XS ${EXPAT_LIBRARIES}) -# target_link_libraries(XS ${GLEW_LIBRARIES}) - # Install the XS.pm and XS.{so,dll,bundle} into the local-lib directory. set(PERL_LOCAL_LIB_DIR "../../local-lib/lib/perl5/${PerlEmbed_ARCHNAME}") add_custom_command( @@ -181,10 +173,6 @@ if(APPLE) ) endif() -if(SLIC3R_PROFILE) - target_link_libraries(Shiny) -endif() - if (MSVC) # Here we associate some additional properties with the MSVC project to enable compilation and debugging out of the box. get_filename_component(PROPS_PERL_BIN_PATH "${PERL_EXECUTABLE}" DIRECTORY)