diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 97007fec5c..a6f3cc02bf 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -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 @@ -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") diff --git a/gazebo/CMakeLists.txt b/gazebo/CMakeLists.txt index 7ed1ea81c3..9ad9d02a7a 100644 --- a/gazebo/CMakeLists.txt +++ b/gazebo/CMakeLists.txt @@ -16,7 +16,6 @@ link_directories( ${SDFormat_LIBRARY_DIRS} ${PROJECT_BINARY_DIR}/test ${TBB_LIBRARY_DIR} - ${CURL_LIBDIR} ${IGNITION-MSGS_LIBRARY_DIRS} ) diff --git a/gazebo/common/CMakeLists.txt b/gazebo/common/CMakeLists.txt index 6e32435d61..13ce89f4a4 100644 --- a/gazebo/common/CMakeLists.txt +++ b/gazebo/common/CMakeLists.txt @@ -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}) @@ -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} @@ -248,6 +239,7 @@ target_link_libraries(gazebo_common ${SDFormat_LIBRARIES} ${tinyxml_LIBRARIES} PRIVATE + CURL::libcurl ${libtool_library} ${libavcodec_LIBRARIES} ${libavformat_LIBRARIES} diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index dd426626f9..4392f86e3c 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -28,7 +28,6 @@ if(WIN32 AND NOT UNIX) endif() include_directories(SYSTEM - ${CURL_INCLUDEDIR} ${PROJECT_SOURCE_DIR} ${PROTOBUF_INCLUDE_DIR} ${SDFormat_INCLUDE_DIRS} @@ -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) @@ -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) diff --git a/plugins/rest_web/CMakeLists.txt b/plugins/rest_web/CMakeLists.txt index 6f8df8af8d..d7eb70cbf4 100644 --- a/plugins/rest_web/CMakeLists.txt +++ b/plugins/rest_web/CMakeLists.txt @@ -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} diff --git a/plugins/rest_web/RestUiLoginDialog.cc b/plugins/rest_web/RestUiLoginDialog.cc index d2ab6269e5..82f50fe351 100644 --- a/plugins/rest_web/RestUiLoginDialog.cc +++ b/plugins/rest_web/RestUiLoginDialog.cc @@ -16,7 +16,6 @@ */ #include -#include #include "RestUiLoginDialog.hh" #include "RestUiWidget.hh" diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 2209d57990..5f2c112105 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -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