From bbf0e3d811ad2c5069af3c7434779496375a15f0 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Mon, 21 Jun 2021 14:17:09 -0700 Subject: [PATCH 1/9] Use CURL::libcurl instead of variables Signed-off-by: Shane Loretz --- gazebo/common/CMakeLists.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gazebo/common/CMakeLists.txt b/gazebo/common/CMakeLists.txt index 6e32435d61..ae20b8e01b 100644 --- a/gazebo/common/CMakeLists.txt +++ b/gazebo/common/CMakeLists.txt @@ -17,12 +17,8 @@ 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() +if (CURL_FOUND AND WIN32) + add_definitions(-DCURL_STATICLIB) endif() include_directories(${tinyxml_INCLUDE_DIRS}) @@ -237,7 +233,7 @@ target_compile_definitions(gazebo_common target_link_libraries(gazebo_common PUBLIC ${Boost_LIBRARIES} - ${CURL_LIBRARIES} + CURL::libcurl ${freeimage_LIBRARIES} ignition-common3::graphics ${IGNITION-FUEL_TOOLS_LIBRARIES} From 2d35a06252ae601cc1da8ea81df0c161889d38ce Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Mon, 21 Jun 2021 16:47:36 -0700 Subject: [PATCH 2/9] Make an interface target for CURL on bionic Signed-off-by: Shane Loretz --- cmake/SearchForStuff.cmake | 24 +++++++++--------------- gazebo/CMakeLists.txt | 1 - gazebo/common/CMakeLists.txt | 4 ---- plugins/CMakeLists.txt | 10 +++++----- tools/CMakeLists.txt | 9 +-------- 5 files changed, 15 insertions(+), 33 deletions(-) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 97007fec5c..e628a3fefc 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -93,14 +93,15 @@ endif () 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 (NOT TARGET CURL::libcurl) + # Make a target on Bionic because FindCURL.cmake only sets old-style CMake variables + add_library(CURL::libcurl INTERFACE) + target_include_directories(CURL::libcurl INTERFACE "${CURL_INCLUDE_DIRS}") + target_link_libraries(CURL::libcurl INTERFACE "${CURL_LIBRARIES}") + if (WIN32) + target_compile_definitions(CURL::libcurl INTERFACE "CURL_STATICLIB") + endif() + endif() endif () # In Visual Studio we use configure.bat to trick all path cmake @@ -110,13 +111,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 ae20b8e01b..62385a6062 100644 --- a/gazebo/common/CMakeLists.txt +++ b/gazebo/common/CMakeLists.txt @@ -17,10 +17,6 @@ if (HAVE_GDAL) include_directories(${GDAL_INCLUDE_DIR}) endif() -if (CURL_FOUND AND WIN32) - add_definitions(-DCURL_STATICLIB) -endif() - include_directories(${tinyxml_INCLUDE_DIRS}) link_directories(${tinyxml_LIBRARY_DIRS}) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index dd426626f9..7b44aeea78 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) @@ -168,6 +163,7 @@ set (DARTplugins add_library(TrackedVehiclePlugin SHARED TrackedVehiclePlugin.cc) target_link_libraries(TrackedVehiclePlugin + CURL::libcurl libgazebo ${ogre_libraries} ${IGNITION-TRANSPORT_LIBRARIES} @@ -181,6 +177,7 @@ gz_install_includes("plugins" TrackedVehiclePlugin.hh) foreach (src ${plugins_single_header}) add_library(${src} SHARED ${src}.cc) target_link_libraries(${src} + CURL::libcurl libgazebo ${ogre_libraries} ${IGNITION-TRANSPORT_LIBRARIES} @@ -203,6 +200,7 @@ add_dependencies(WheelTrackedVehiclePlugin TrackedVehiclePlugin) foreach (src ${plugins_private_header}) add_library(${src} SHARED ${src}.cc) target_link_libraries(${src} + CURL::libcurl libgazebo ${ogre_libraries} ${IGNITION-TRANSPORT_LIBRARIES} @@ -218,6 +216,7 @@ endforeach () foreach (src ${GUIplugins}) add_library(${src} SHARED ${src}.cc ${${src}_MOC}) target_link_libraries(${src} + CURL::libcurl libgazebo gazebo_gui ${ogre_libraries} @@ -237,6 +236,7 @@ if (HAVE_DART_URDF) foreach (src ${DARTplugins}) add_library(${src} SHARED ${src}.cc) target_link_libraries(${src} + CURL::libcurl libgazebo ${DART_LIBRARIES} ) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 2209d57990..abc6b1166e 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 @@ -53,6 +45,7 @@ if (WIN32) endif() target_link_libraries(gz + CURL::libcurl libgazebo_client gazebo_gui gazebo_physics From 73e7865768a1ced1bebc0f8c92d18f077fd65b8c Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Mon, 21 Jun 2021 16:53:09 -0700 Subject: [PATCH 3/9] Try an IMPORTED target instead of an INTERFACE one Signed-off-by: Shane Loretz --- cmake/SearchForStuff.cmake | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index e628a3fefc..3cd0ba422c 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -95,11 +95,14 @@ find_package(CURL) if (CURL_FOUND) if (NOT TARGET CURL::libcurl) # Make a target on Bionic because FindCURL.cmake only sets old-style CMake variables - add_library(CURL::libcurl INTERFACE) - target_include_directories(CURL::libcurl INTERFACE "${CURL_INCLUDE_DIRS}") - target_link_libraries(CURL::libcurl INTERFACE "${CURL_LIBRARIES}") + add_library(CURL::libcurl UNKNOWN IMPORTED) + set_target_properties(CURL::libcurl PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${CURL_LIBRARIES}" + ) if (WIN32) - target_compile_definitions(CURL::libcurl INTERFACE "CURL_STATICLIB") + set_target_properties(CURL::libcurl PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB") endif() endif() endif () From ce586afbcc96013388f78d454ecab957e831f063 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Tue, 22 Jun 2021 09:19:01 -0700 Subject: [PATCH 4/9] Debug print and SHARED target Signed-off-by: Shane Loretz --- cmake/SearchForStuff.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 3cd0ba422c..099bcb6f37 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -95,11 +95,11 @@ find_package(CURL) if (CURL_FOUND) if (NOT TARGET CURL::libcurl) # Make a target on Bionic because FindCURL.cmake only sets old-style CMake variables - add_library(CURL::libcurl UNKNOWN IMPORTED) + add_library(CURL::libcurl SHARED IMPORTED) set_target_properties(CURL::libcurl PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${CURL_LIBRARIES}" - ) + INTERFACE_LINK_LIBRARIES "${CURL_LIBRARIES}") + message(STATUS "XXX CURL include dirs: ${CURL_INCLUDE_DIRS} libraries: ${CURL_LIBRARIES} XXX") if (WIN32) set_target_properties(CURL::libcurl PROPERTIES INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB") From 2e7b694a949d68104dd8cb28a168efc6d7a84b67 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Tue, 22 Jun 2021 10:56:56 -0700 Subject: [PATCH 5/9] set IMPORTED_LOCATION Signed-off-by: Shane Loretz --- cmake/SearchForStuff.cmake | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 099bcb6f37..657795cbcc 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -92,18 +92,17 @@ endif () # Find packages find_package(CURL) -if (CURL_FOUND) - if (NOT TARGET CURL::libcurl) - # Make a target on Bionic because FindCURL.cmake only sets old-style CMake variables - add_library(CURL::libcurl SHARED IMPORTED) +if (CURL_FOUND AND NOT TARGET CURL::libcurl AND CURL_LIBRARY) + message(STATUS "XXX CURL include dirs: ${CURL_INCLUDE_DIRS} libraries: ${CURL_LIBRARIES} curl library: ${CURL_LIBRARY} XXX") + # 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_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${CURL_LIBRARIES}") - message(STATUS "XXX CURL include dirs: ${CURL_INCLUDE_DIRS} libraries: ${CURL_LIBRARIES} XXX") - if (WIN32) - set_target_properties(CURL::libcurl PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB") - endif() + INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB") endif() endif () From 9057ef9a36b01fd490f78889d17d0351c85985e5 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Wed, 23 Jun 2021 10:10:04 -0700 Subject: [PATCH 6/9] CURL is a PRIVATE dep Signed-off-by: Shane Loretz --- gazebo/common/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gazebo/common/CMakeLists.txt b/gazebo/common/CMakeLists.txt index 62385a6062..13ce89f4a4 100644 --- a/gazebo/common/CMakeLists.txt +++ b/gazebo/common/CMakeLists.txt @@ -229,7 +229,6 @@ target_compile_definitions(gazebo_common target_link_libraries(gazebo_common PUBLIC ${Boost_LIBRARIES} - CURL::libcurl ${freeimage_LIBRARIES} ignition-common3::graphics ${IGNITION-FUEL_TOOLS_LIBRARIES} @@ -240,6 +239,7 @@ target_link_libraries(gazebo_common ${SDFormat_LIBRARIES} ${tinyxml_LIBRARIES} PRIVATE + CURL::libcurl ${libtool_library} ${libavcodec_LIBRARIES} ${libavformat_LIBRARIES} From 3ec4db6eb97f41d44fe6d91edb65948e9a3ef85c Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Wed, 23 Jun 2021 10:10:17 -0700 Subject: [PATCH 7/9] Remove debug print statement Signed-off-by: Shane Loretz --- cmake/SearchForStuff.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 657795cbcc..a6f3cc02bf 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -93,7 +93,6 @@ endif () find_package(CURL) if (CURL_FOUND AND NOT TARGET CURL::libcurl AND CURL_LIBRARY) - message(STATUS "XXX CURL include dirs: ${CURL_INCLUDE_DIRS} libraries: ${CURL_LIBRARIES} curl library: ${CURL_LIBRARY} XXX") # 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 From dba62f38550a914ec36f128b7f93e60019f3a787 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Wed, 23 Jun 2021 16:20:39 -0700 Subject: [PATCH 8/9] Remove unneeded CURL include, linkage Signed-off-by: Steve Peters --- plugins/CMakeLists.txt | 4 ---- plugins/rest_web/RestUiLoginDialog.cc | 1 - tools/CMakeLists.txt | 1 - 3 files changed, 6 deletions(-) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 7b44aeea78..adf1bdd897 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -163,7 +163,6 @@ set (DARTplugins add_library(TrackedVehiclePlugin SHARED TrackedVehiclePlugin.cc) target_link_libraries(TrackedVehiclePlugin - CURL::libcurl libgazebo ${ogre_libraries} ${IGNITION-TRANSPORT_LIBRARIES} @@ -200,7 +199,6 @@ add_dependencies(WheelTrackedVehiclePlugin TrackedVehiclePlugin) foreach (src ${plugins_private_header}) add_library(${src} SHARED ${src}.cc) target_link_libraries(${src} - CURL::libcurl libgazebo ${ogre_libraries} ${IGNITION-TRANSPORT_LIBRARIES} @@ -216,7 +214,6 @@ endforeach () foreach (src ${GUIplugins}) add_library(${src} SHARED ${src}.cc ${${src}_MOC}) target_link_libraries(${src} - CURL::libcurl libgazebo gazebo_gui ${ogre_libraries} @@ -236,7 +233,6 @@ if (HAVE_DART_URDF) foreach (src ${DARTplugins}) add_library(${src} SHARED ${src}.cc) target_link_libraries(${src} - CURL::libcurl libgazebo ${DART_LIBRARIES} ) 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 abc6b1166e..5f2c112105 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -45,7 +45,6 @@ if (WIN32) endif() target_link_libraries(gz - CURL::libcurl libgazebo_client gazebo_gui gazebo_physics From c47c2b043efc3e4ac1ec364866e105e1058658cf Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Wed, 23 Jun 2021 16:21:14 -0700 Subject: [PATCH 9/9] Link to CURL for two plugins only Only StaticMapPlugin and RestWebPlugin use CURL, so only add linking for these. Signed-off-by: Steve Peters --- plugins/CMakeLists.txt | 3 ++- plugins/rest_web/CMakeLists.txt | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index adf1bdd897..4392f86e3c 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -176,7 +176,6 @@ gz_install_includes("plugins" TrackedVehiclePlugin.hh) foreach (src ${plugins_single_header}) add_library(${src} SHARED ${src}.cc) target_link_libraries(${src} - CURL::libcurl libgazebo ${ogre_libraries} ${IGNITION-TRANSPORT_LIBRARIES} @@ -193,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}