Link libcurl and wxWidgets to libslic3r_gui

Also enhance and remove duplicate CURL search in cmake
This commit is contained in:
tamasmeszaros 2020-03-06 15:16:46 +01:00
parent 3baea9b458
commit b6aeffb618
3 changed files with 14 additions and 31 deletions

View File

@ -328,13 +328,21 @@ find_package(TBB REQUIRED)
# add_definitions(-DTBB_USE_CAPTURED_EXCEPTION=0) # add_definitions(-DTBB_USE_CAPTURED_EXCEPTION=0)
find_package(CURL REQUIRED) find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIRS})
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 (SLIC3R_STATIC)
if (NOT APPLE) if (NOT APPLE)
# libcurl is always linked dynamically to the system libcurl on OSX. # libcurl is always linked dynamically to the system libcurl on OSX.
# On other systems, libcurl is linked statically if SLIC3R_STATIC is set. # On other systems, libcurl is linked statically if SLIC3R_STATIC is set.
add_definitions(-DCURL_STATICLIB) target_compile_definitions(libcurl INTERFACE CURL_STATICLIB)
endif() endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Linux") if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# As of now, our build system produces a statically linked libcurl, # As of now, our build system produces a statically linked libcurl,
@ -342,7 +350,8 @@ if (SLIC3R_STATIC)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}") message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
message("OpenSSL libraries: ${OPENSSL_LIBRARIES}") message("OpenSSL libraries: ${OPENSSL_LIBRARIES}")
include_directories(${OPENSSL_INCLUDE_DIR}) target_include_directories(libcurl INTERFACE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(libcurl INTERFACE ${OPENSSL_LIBRARIES})
endif() endif()
endif() endif()

View File

@ -104,33 +104,7 @@ endif ()
# Add the Slic3r GUI library, libcurl, OpenGL and GLU libraries. # Add the Slic3r GUI library, libcurl, OpenGL and GLU libraries.
if (SLIC3R_GUI) if (SLIC3R_GUI)
# target_link_libraries(PrusaSlicer ws2_32 uxtheme setupapi libslic3r_gui ${wxWidgets_LIBRARIES}) # target_link_libraries(PrusaSlicer ws2_32 uxtheme setupapi libslic3r_gui ${wxWidgets_LIBRARIES})
target_link_libraries(PrusaSlicer libslic3r_gui ${wxWidgets_LIBRARIES}) target_link_libraries(PrusaSlicer libslic3r_gui)
# Configure libcurl and its dependencies OpenSSL & zlib
find_package(CURL REQUIRED)
if (NOT WIN32)
# Required by libcurl
find_package(ZLIB REQUIRED)
endif()
target_include_directories(PrusaSlicer PRIVATE ${CURL_INCLUDE_DIRS})
target_link_libraries(PrusaSlicer ${CURL_LIBRARIES} ${ZLIB_LIBRARIES})
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(PrusaSlicer PRIVATE 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(PrusaSlicer PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(PrusaSlicer ${OPENSSL_LIBRARIES})
endif()
endif()
if (MSVC) if (MSVC)
# Generate debug symbols even in release mode. # Generate debug symbols even in release mode.
target_link_options(PrusaSlicer PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>") target_link_options(PrusaSlicer PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>")

View File

@ -191,7 +191,7 @@ add_library(libslic3r_gui STATIC ${SLIC3R_GUI_SOURCES})
encoding_check(libslic3r_gui) encoding_check(libslic3r_gui)
target_link_libraries(libslic3r_gui libslic3r avrdude cereal imgui GLEW::GLEW OpenGL::GL OpenGL::GLU hidapi) target_link_libraries(libslic3r_gui libslic3r avrdude cereal imgui GLEW::GLEW OpenGL::GL OpenGL::GLU hidapi libcurl ${wxWidgets_LIBRARIES})
if(APPLE) if(APPLE)
target_link_libraries(libslic3r_gui ${DISKARBITRATION_LIBRARY}) target_link_libraries(libslic3r_gui ${DISKARBITRATION_LIBRARY})