From b6aeffb618b2f09be1b655492934407302bdcb4e Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 6 Mar 2020 15:16:46 +0100 Subject: [PATCH] Link libcurl and wxWidgets to libslic3r_gui Also enhance and remove duplicate CURL search in cmake --- CMakeLists.txt | 15 ++++++++++++--- src/CMakeLists.txt | 28 +--------------------------- src/slic3r/CMakeLists.txt | 2 +- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c69052c8..8d1d93c5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -328,13 +328,21 @@ find_package(TBB REQUIRED) # add_definitions(-DTBB_USE_CAPTURED_EXCEPTION=0) 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 (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. - add_definitions(-DCURL_STATICLIB) + 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, @@ -342,7 +350,8 @@ if (SLIC3R_STATIC) find_package(OpenSSL REQUIRED) message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}") 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() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 11996af1a..b0eab9bcc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -104,33 +104,7 @@ endif () # Add the Slic3r GUI library, libcurl, OpenGL and GLU libraries. if (SLIC3R_GUI) # target_link_libraries(PrusaSlicer ws2_32 uxtheme setupapi libslic3r_gui ${wxWidgets_LIBRARIES}) -target_link_libraries(PrusaSlicer libslic3r_gui ${wxWidgets_LIBRARIES}) - - # 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() - +target_link_libraries(PrusaSlicer libslic3r_gui) if (MSVC) # Generate debug symbols even in release mode. target_link_options(PrusaSlicer PUBLIC "$<$:/DEBUG>") diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index c8589903e..5e0c34da0 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -191,7 +191,7 @@ add_library(libslic3r_gui STATIC ${SLIC3R_GUI_SOURCES}) 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) target_link_libraries(libslic3r_gui ${DISKARBITRATION_LIBRARY})