Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CURL::libcurl instead of variables #3030

Merged
merged 9 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 1 addition & 9 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 Expand Up @@ -237,7 +229,6 @@ target_compile_definitions(gazebo_common
target_link_libraries(gazebo_common
PUBLIC
${Boost_LIBRARIES}
${CURL_LIBRARIES}
${freeimage_LIBRARIES}
ignition-common3::graphics
${IGNITION-FUEL_TOOLS_LIBRARIES}
Expand All @@ -248,6 +239,7 @@ target_link_libraries(gazebo_common
${SDFormat_LIBRARIES}
${tinyxml_LIBRARIES}
PRIVATE
CURL::libcurl
${libtool_library}
${libavcodec_LIBRARIES}
${libavformat_LIBRARIES}
Expand Down
7 changes: 2 additions & 5 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ if(WIN32 AND NOT UNIX)
endif()

include_directories(SYSTEM
${CURL_INCLUDEDIR}
${PROJECT_SOURCE_DIR}
${PROTOBUF_INCLUDE_DIR}
${SDFormat_INCLUDE_DIRS}
Expand All @@ -53,15 +52,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 @@ -197,6 +192,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
LIBRARY DESTINATION ${GAZEBO_PLUGIN_LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${GAZEBO_PLUGIN_LIB_INSTALL_DIR}
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