Refactor CMake and improve #includes.
* 1. Remove all global include_directories. * 2. Move 3d party dependencies from src to budled deps if possible. * Unify and enforce one way of including headers: e.g. #include "libslic3r/GCode.hpp" vs #include "GCode.hpp" (always use the "libslic3r/GCode.hpp" option). * Make all dependencies (also header only) a cmake target.
@ -247,7 +247,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
find_package(DBus REQUIRED)
|
find_package(DBus REQUIRED)
|
||||||
include_directories(${DBUS_INCLUDE_DIRS})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
|
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
|
||||||
@ -340,11 +339,7 @@ if (APPLE)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_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 ()
|
endif ()
|
||||||
|
|
||||||
# Where all the bundled libraries reside?
|
|
||||||
set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
||||||
set(LIBDIR_BIN ${CMAKE_CURRENT_BINARY_DIR}/src)
|
set(LIBDIR_BIN ${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||||
# For the bundled boost libraries (boost::nowide)
|
|
||||||
include_directories(${LIBDIR})
|
|
||||||
# For generated header files
|
# For generated header files
|
||||||
include_directories(${LIBDIR_BIN}/platform)
|
include_directories(${LIBDIR_BIN}/platform)
|
||||||
|
|
||||||
@ -379,6 +374,8 @@ set(MINIMUM_BOOST_VERSION "1.66.0")
|
|||||||
set(_boost_components "system;filesystem;thread;log;locale;regex;chrono;atomic;date_time;iostreams;nowide")
|
set(_boost_components "system;filesystem;thread;log;locale;regex;chrono;atomic;date_time;iostreams;nowide")
|
||||||
find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS ${_boost_components})
|
find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS ${_boost_components})
|
||||||
|
|
||||||
|
find_package(Eigen3 3.3.7 REQUIRED)
|
||||||
|
|
||||||
add_library(boost_libs INTERFACE)
|
add_library(boost_libs INTERFACE)
|
||||||
add_library(boost_headeronly INTERFACE)
|
add_library(boost_headeronly INTERFACE)
|
||||||
|
|
||||||
@ -459,16 +456,6 @@ endif()
|
|||||||
|
|
||||||
## OPTIONAL packages
|
## 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. We have our overriden FindEXPAT which exports libexpat target
|
# Find expat. We have our overriden FindEXPAT which exports libexpat target
|
||||||
# no matter what.
|
# no matter what.
|
||||||
find_package(EXPAT REQUIRED)
|
find_package(EXPAT REQUIRED)
|
||||||
@ -623,7 +610,8 @@ function(prusaslicer_copy_dlls target)
|
|||||||
VERBATIM)
|
VERBATIM)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
add_subdirectory(build-utils)
|
||||||
|
add_subdirectory(bundled_deps)
|
||||||
# libslic3r, PrusaSlicer GUI and the PrusaSlicer executable.
|
# libslic3r, PrusaSlicer GUI and the PrusaSlicer executable.
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT PrusaSlicer_app_console)
|
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT PrusaSlicer_app_console)
|
||||||
@ -665,4 +653,4 @@ else ()
|
|||||||
install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/resources")
|
install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/resources")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
configure_file(${LIBDIR}/platform/unix/fhs.hpp.in ${LIBDIR_BIN}/platform/unix/fhs.hpp)
|
configure_file(src/platform/unix/fhs.hpp.in ${LIBDIR_BIN}/platform/unix/fhs.hpp)
|
||||||
|
50
bundled_deps/CMakeLists.txt
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
add_subdirectory(admesh)
|
||||||
|
add_subdirectory(avrdude)
|
||||||
|
add_subdirectory(miniz)
|
||||||
|
add_subdirectory(glu-libtess)
|
||||||
|
add_subdirectory(agg)
|
||||||
|
add_subdirectory(libigl)
|
||||||
|
add_subdirectory(hints)
|
||||||
|
add_subdirectory(libnest2d)
|
||||||
|
|
||||||
|
add_library(semver STATIC
|
||||||
|
semver/semver.c
|
||||||
|
semver/semver.h
|
||||||
|
)
|
||||||
|
target_include_directories(semver PUBLIC semver)
|
||||||
|
encoding_check(semver)
|
||||||
|
|
||||||
|
add_library(qoi STATIC
|
||||||
|
qoi/qoilib.c
|
||||||
|
qoi/qoi.h
|
||||||
|
)
|
||||||
|
target_include_directories(qoi PUBLIC qoi)
|
||||||
|
encoding_check(qoi)
|
||||||
|
|
||||||
|
add_library(fastfloat INTERFACE)
|
||||||
|
target_include_directories(fastfloat INTERFACE fast_float)
|
||||||
|
|
||||||
|
add_library(int128 INTERFACE)
|
||||||
|
target_include_directories(int128 INTERFACE int128)
|
||||||
|
|
||||||
|
add_library(localesutils STATIC
|
||||||
|
localesutils/LocalesUtils.cpp
|
||||||
|
localesutils/LocalesUtils.hpp
|
||||||
|
)
|
||||||
|
target_include_directories(localesutils PUBLIC localesutils)
|
||||||
|
target_link_libraries(localesutils PRIVATE fastfloat)
|
||||||
|
|
||||||
|
add_library(ankerl INTERFACE)
|
||||||
|
target_include_directories(ankerl INTERFACE ankerl)
|
||||||
|
|
||||||
|
add_library(stb_dxt INTERFACE)
|
||||||
|
target_include_directories(stb_dxt INTERFACE stb_dxt)
|
||||||
|
|
||||||
|
add_library(tcbspan INTERFACE)
|
||||||
|
target_include_directories(tcbspan INTERFACE tcbspan)
|
||||||
|
|
||||||
|
if (SLIC3R_GUI)
|
||||||
|
add_subdirectory(imgui)
|
||||||
|
add_subdirectory(libvgcode)
|
||||||
|
add_subdirectory(hidapi)
|
||||||
|
endif ()
|
16
bundled_deps/admesh/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
project(admesh)
|
||||||
|
|
||||||
|
add_library(admesh STATIC
|
||||||
|
admesh/connect.cpp
|
||||||
|
admesh/normals.cpp
|
||||||
|
admesh/shared.cpp
|
||||||
|
admesh/stl.h
|
||||||
|
admesh/stl_io.cpp
|
||||||
|
admesh/stlinit.cpp
|
||||||
|
admesh/util.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(admesh PUBLIC .)
|
||||||
|
target_link_libraries(admesh PRIVATE boost_headeronly localesutils)
|
||||||
|
target_link_libraries(admesh PUBLIC Eigen3::Eigen)
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "stl.h"
|
#include "stl.h"
|
||||||
|
|
||||||
#include "libslic3r/LocalesUtils.hpp"
|
#include <LocalesUtils.hpp>
|
||||||
|
|
||||||
void stl_generate_shared_vertices(stl_file *stl, indexed_triangle_set &its)
|
void stl_generate_shared_vertices(stl_file *stl, indexed_triangle_set &its)
|
||||||
{
|
{
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "stl.h"
|
#include "stl.h"
|
||||||
|
|
||||||
#include "libslic3r/LocalesUtils.hpp"
|
#include <LocalesUtils.hpp>
|
||||||
|
|
||||||
#ifndef SEEK_SET
|
#ifndef SEEK_SET
|
||||||
#error "SEEK_SET not defined"
|
#error "SEEK_SET not defined"
|
5
bundled_deps/agg/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
project(agg)
|
||||||
|
|
||||||
|
add_library(agg INTERFACE)
|
||||||
|
target_include_directories(agg INTERFACE .)
|
107
bundled_deps/avrdude/CMakeLists.txt
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
|
add_definitions(-D_BSD_SOURCE -D_DEFAULT_SOURCE) # To enable various useful macros and functions on Unices
|
||||||
|
remove_definitions(-D_UNICODE -DUNICODE)
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
# Workaround for an old CMake, which does not understand CMAKE_C_STANDARD.
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
set(AVRDUDE_SOURCES
|
||||||
|
avrdude/arduino.c
|
||||||
|
avrdude/avr.c
|
||||||
|
# avrdude/avrftdi.c
|
||||||
|
# avrdude/avrftdi_tpi.c
|
||||||
|
avrdude/avrpart.c
|
||||||
|
avrdude/avr910.c
|
||||||
|
avrdude/bitbang.c
|
||||||
|
avrdude/buspirate.c
|
||||||
|
avrdude/butterfly.c
|
||||||
|
avrdude/config.c
|
||||||
|
avrdude/config_gram.c
|
||||||
|
# avrdude/confwin.c
|
||||||
|
avrdude/crc16.c
|
||||||
|
# avrdude/dfu.c
|
||||||
|
avrdude/fileio.c
|
||||||
|
# avrdude/flip1.c
|
||||||
|
# avrdude/flip2.c
|
||||||
|
# avrdude/ft245r.c
|
||||||
|
# avrdude/jtagmkI.c
|
||||||
|
# avrdude/jtagmkII.c
|
||||||
|
# avrdude/jtag3.c
|
||||||
|
avrdude/lexer.c
|
||||||
|
avrdude/linuxgpio.c
|
||||||
|
avrdude/lists.c
|
||||||
|
# avrdude/par.c
|
||||||
|
avrdude/pgm.c
|
||||||
|
avrdude/pgm_type.c
|
||||||
|
avrdude/pickit2.c
|
||||||
|
avrdude/pindefs.c
|
||||||
|
# avrdude/ppi.c
|
||||||
|
# avrdude/ppiwin.c
|
||||||
|
avrdude/safemode.c
|
||||||
|
avrdude/ser_avrdoper.c
|
||||||
|
avrdude/serbb_posix.c
|
||||||
|
avrdude/serbb_win32.c
|
||||||
|
avrdude/ser_posix.c
|
||||||
|
avrdude/ser_win32.c
|
||||||
|
avrdude/stk500.c
|
||||||
|
avrdude/stk500generic.c
|
||||||
|
avrdude/stk500v2.c
|
||||||
|
avrdude/term.c
|
||||||
|
avrdude/update.c
|
||||||
|
# avrdude/usbasp.c
|
||||||
|
# avrdude/usb_hidapi.c
|
||||||
|
# avrdude/usb_libusb.c
|
||||||
|
# avrdude/usbtiny.c
|
||||||
|
avrdude/wiring.c
|
||||||
|
|
||||||
|
avrdude/main.c
|
||||||
|
avrdude/avrdude-slic3r.hpp
|
||||||
|
avrdude/avrdude-slic3r.cpp
|
||||||
|
)
|
||||||
|
if (MSVC)
|
||||||
|
set(AVRDUDE_SOURCES ${AVRDUDE_SOURCES}
|
||||||
|
avrdude/windows/utf8.c
|
||||||
|
avrdude/windows/unistd.cpp
|
||||||
|
avrdude/windows/getopt.c
|
||||||
|
)
|
||||||
|
elseif (MINGW)
|
||||||
|
set(AVRDUDE_SOURCES ${AVRDUDE_SOURCES}
|
||||||
|
avrdude/windows/utf8.c
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(bin2h)
|
||||||
|
|
||||||
|
bin2h(
|
||||||
|
SOURCE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/avrdude/avrdude-slic3r.conf
|
||||||
|
VARIABLE_NAME avrdude_slic3r_conf
|
||||||
|
HEADER_FILE ${CMAKE_CURRENT_BINARY_DIR}/avrdude-slic3r.conf.h
|
||||||
|
ADD_WARNING_TEXT
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(avrdude STATIC ${AVRDUDE_SOURCES})
|
||||||
|
target_link_libraries(avrdude PRIVATE localesutils)
|
||||||
|
|
||||||
|
add_executable(avrdude-slic3r avrdude/main-standalone.cpp)
|
||||||
|
target_link_libraries(avrdude-slic3r avrdude)
|
||||||
|
|
||||||
|
encoding_check(avrdude)
|
||||||
|
encoding_check(avrdude-slic3r)
|
||||||
|
|
||||||
|
# Make avrdude-slic3r.conf.h includable:
|
||||||
|
target_include_directories(avrdude SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
target_include_directories(avrdude PUBLIC .)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
target_compile_definitions(avrdude PRIVATE WIN32NATIVE=1)
|
||||||
|
if(MSVC)
|
||||||
|
target_include_directories(avrdude SYSTEM PRIVATE avrdude/windows) # So that sources find the getopt.h windows drop-in
|
||||||
|
endif(MSVC)
|
||||||
|
endif()
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 703 B After Width: | Height: | Size: 703 B |
Before Width: | Height: | Size: 583 B After Width: | Height: | Size: 583 B |
Before Width: | Height: | Size: 798 B After Width: | Height: | Size: 798 B |
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 98 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 156 B After Width: | Height: | Size: 156 B |
Before Width: | Height: | Size: 199 B After Width: | Height: | Size: 199 B |
Before Width: | Height: | Size: 164 B After Width: | Height: | Size: 164 B |
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 340 B After Width: | Height: | Size: 340 B |
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 177 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |