Skip to content

Commit

Permalink
Backport PR #3030 to Gazebo9 for CURL fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
j-rivero committed Jul 8, 2021
1 parent 6deb6ef commit 2270bb4
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 40 deletions.
27 changes: 11 additions & 16 deletions cmake/SearchForStuff.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@ endif ()
# Find packages

find_package(CURL)
if (CURL_FOUND)
# FindCURL.cmake distributed with CMake exports
# the CURL_INCLUDE_DIRS variable, while the pkg_check_modules
# function exports the CURL_INCLUDEDIR variable.
# TODO: once the configure.bat VS2013 based script has been removed,
# remove the call pkg_check_modules(CURL libcurl) and all the uses of
# CURL_LIBDIR and CURL_INCLUDEDIR and use directly the variables
# CURL_INCLUDE_DIRS and CURL_LIBRARIES provided by FindCURL.cmake
set(CURL_INCLUDEDIR ${CURL_INCLUDE_DIRS})
if (CURL_FOUND AND NOT TARGET CURL::libcurl AND CURL_LIBRARY)
# Make a target on Bionic because FindCURL.cmake only sets old-style CMake variables
add_library(CURL::libcurl SHARED IMPORTED)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LOCATION "${CURL_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${CURL_LIBRARIES}")
if (WIN32)
set_target_properties(CURL::libcurl PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB")
endif()
endif ()

# In Visual Studio we use configure.bat to trick all path cmake
Expand All @@ -110,13 +112,6 @@ if (MSVC)
endif()

if (PKG_CONFIG_FOUND)
if (NOT CURL_FOUND)
pkg_check_modules(CURL libcurl)
endif ()
if (NOT CURL_FOUND)
BUILD_ERROR ("Missing: libcurl. Required for connection to model database.")
endif()

pkg_check_modules(PROFILER libprofiler)
if (PROFILER_FOUND)
set (CMAKE_LINK_FLAGS_PROFILE "-Wl,--no-as-needed -lprofiler -Wl,--as-needed ${CMAKE_LINK_FLAGS_PROFILE}" CACHE INTERNAL "Link flags for profile")
Expand Down
1 change: 0 additions & 1 deletion gazebo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ link_directories(
${SDFormat_LIBRARY_DIRS}
${PROJECT_BINARY_DIR}/test
${TBB_LIBRARY_DIR}
${CURL_LIBDIR}
${IGNITION-MSGS_LIBRARY_DIRS}
)

Expand Down
8 changes: 0 additions & 8 deletions gazebo/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ if (HAVE_GDAL)
include_directories(${GDAL_INCLUDE_DIR})
endif()

if (CURL_FOUND)
include_directories(${CURL_INCLUDEDIR})
link_directories(${CURL_LIBDIR})
if (WIN32)
add_definitions(-DCURL_STATICLIB)
endif()
endif()

include_directories(${tinyxml_INCLUDE_DIRS})
link_directories(${tinyxml_LIBRARY_DIRS})

Expand Down
7 changes: 2 additions & 5 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ if(WIN32 AND NOT UNIX)
endif()

include_directories(SYSTEM
${CURL_INCLUDEDIR}
${PROJECT_SOURCE_DIR}
${PROTOBUF_INCLUDE_DIR}
${SDFormat_INCLUDE_DIRS}
Expand All @@ -48,15 +47,11 @@ include_directories(SYSTEM
# failures in clang.
link_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CURL_LIBDIR}
${CCD_LIBRARY_DIRS}
${SDFormat_LIBRARY_DIRS}
${tinyxml_LIBRARY_DIRS}
)

if (WIN32)
add_definitions(-DCURL_STATICLIB)
endif()
add_definitions(${Qt5Core_DEFINITIONS})
set (CMAKE_AUTOMOC ON)

Expand Down Expand Up @@ -189,6 +184,8 @@ target_include_directories(SimpleTrackedVehiclePlugin SYSTEM PRIVATE
target_link_libraries(SimpleTrackedVehiclePlugin TrackedVehiclePlugin)
add_dependencies(SimpleTrackedVehiclePlugin TrackedVehiclePlugin)

target_link_libraries(StaticMapPlugin CURL::libcurl)

target_link_libraries(WheelTrackedVehiclePlugin TrackedVehiclePlugin)
add_dependencies(WheelTrackedVehiclePlugin TrackedVehiclePlugin)

Expand Down
5 changes: 4 additions & 1 deletion plugins/rest_web/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ include_directories(
)

add_library(RestWebPlugin SHARED ${server_src} )
target_link_libraries(RestWebPlugin ${GAZEBO_libraries} gazebo_msgs)
target_link_libraries(RestWebPlugin
CURL::libcurl
${GAZEBO_libraries}
gazebo_msgs)
install (TARGETS RestWebPlugin DESTINATION ${GAZEBO_PLUGIN_INSTALL_DIR})
gz_install_includes("plugins" ${server_inc})

Expand Down
1 change: 0 additions & 1 deletion plugins/rest_web/RestUiLoginDialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include <iostream>
#include <curl/curl.h>

#include "RestUiLoginDialog.hh"
#include "RestUiWidget.hh"
Expand Down
8 changes: 0 additions & 8 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ if (HAVE_DART)
link_directories(${DART_LIBRARY_DIRS})
endif()

if (CURL_FOUND)
include_directories(${CURL_INCLUDEDIR})
link_directories(${CURL_LIBDIR})
if (WIN32)
add_definitions(-DCURL_STATICLIB)
endif()
endif()

if(NOT WIN32)
# gz_TEST and gz_log_TEST use fork(), that is not available on Windows
set (test_sources
Expand Down

0 comments on commit 2270bb4

Please sign in to comment.