From 0cace35e340d58d9405f7cb3c21a81f89aadf504 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 10:13:00 -0800 Subject: [PATCH 01/14] Remove libcurl_vendor Signed-off-by: Shane Loretz --- libcurl_vendor/CHANGELOG.rst | 79 --------------- libcurl_vendor/CMakeLists.txt | 97 ------------------- .../env_hook/libcurl_vendor_library_path.bat | 41 -------- .../libcurl_vendor_library_path.dsv.in | 1 - .../env_hook/libcurl_vendor_library_path.sh | 16 --- libcurl_vendor/libcurl_vendor-extras.cmake.in | 55 ----------- libcurl_vendor/package.xml | 31 ------ resource_retriever/CMakeLists.txt | 19 ++-- resource_retriever/package.xml | 6 +- 9 files changed, 14 insertions(+), 331 deletions(-) delete mode 100644 libcurl_vendor/CHANGELOG.rst delete mode 100644 libcurl_vendor/CMakeLists.txt delete mode 100644 libcurl_vendor/env_hook/libcurl_vendor_library_path.bat delete mode 100644 libcurl_vendor/env_hook/libcurl_vendor_library_path.dsv.in delete mode 100644 libcurl_vendor/env_hook/libcurl_vendor_library_path.sh delete mode 100644 libcurl_vendor/libcurl_vendor-extras.cmake.in delete mode 100644 libcurl_vendor/package.xml diff --git a/libcurl_vendor/CHANGELOG.rst b/libcurl_vendor/CHANGELOG.rst deleted file mode 100644 index 796cfba..0000000 --- a/libcurl_vendor/CHANGELOG.rst +++ /dev/null @@ -1,79 +0,0 @@ -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Changelog for package libcurl_vendor -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -3.0.0 (2022-01-14) ------------------- -* Update maintainers (`#66 `_) -* Contributors: Audrow Nash - -2.5.0 (2021-04-06) ------------------- -* Update libcurl_vendor to the latest version (7.75.0). (`#60 `_) -* Contributors: Chris Lalancette - -2.4.2 (2021-03-18) ------------------- -* Add an override flag to force vendored build (`#58 `_) -* Contributors: Scott K Logan - -2.4.1 (2020-12-08) ------------------- -* Update maintainers (`#53 `_) -* Contributors: Alejandro Hernández Cordero - -2.4.0 (2020-08-12) ------------------- -* bump curl version to 7.68 (`#47 `_) -* Contributors: Dirk Thomas - -2.3.2 (2020-06-03) ------------------- -* export TARGETS in libcurl_vendor (`#46 `_) -* Contributors: Dirk Thomas - -2.3.1 (2020-05-08) ------------------- - -2.3.0 (2020-04-30) ------------------- -* Ignore broken curl-config.cmake (`#40 `_) -* Update curl reference from 7.57 to 7.58 (`#36 `_) -* Contributors: Nathan Brooks, Scott K Logan - -2.2.0 (2019-09-26) ------------------- -* add .dsv file beside custom environment hook (`#30 `_) -* Contributors: Dirk Thomas - -2.1.1 (2019-05-08) ------------------- - -2.1.0 (2018-06-21) ------------------- -* depend on curl (mapping to curl, libcurl4-openssl-dev) for packaging (`#25 `_) -* add missing dependency on pkg-config (`#19 `_) -* [libcurl_vendor] convert to ament and setup env hooks for library paths (`#14 `_) -* Contributors: Dirk Thomas, Mikael Arguedas, William Woodall - -2.0.0 (2017-12-08) ------------------- -* disable docs and tests for libcurl to avoid needing perl -* fix libcurl vendor package on Windows and warnings -* add temporary libcurl_vendor and use it to get curl -* Contributors: William Woodall - -1.12.3 (2017-03-27) -------------------- - -1.12.2 (2016-06-10 14:16) -------------------------- - -1.12.1 (2016-06-10 10:28) -------------------------- - -1.12.0 (2016-03-23) -------------------- - -1.11.6 (2014-11-30) -------------------- diff --git a/libcurl_vendor/CMakeLists.txt b/libcurl_vendor/CMakeLists.txt deleted file mode 100644 index 87e37ce..0000000 --- a/libcurl_vendor/CMakeLists.txt +++ /dev/null @@ -1,97 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -project(libcurl_vendor) - -option(FORCE_BUILD_VENDOR_PKG - "Build libcurl from source, even if system-installed package is available" - OFF) - -find_package(ament_cmake REQUIRED) - -macro(build_libcurl) - set(extra_cxx_flags) - set(extra_c_flags) - if(NOT WIN32) - list(APPEND extra_cxx_flags "-std=c++14 -w") - list(APPEND extra_c_flags "-w") - endif() - - set(PKGCONFIG_FOR_OPENSSL) - if(APPLE) - set(PKGCONFIG_FOR_OPENSSL "/usr/local/opt/openssl/lib/pkgconfig") - endif() - - if(WIN32 AND NOT ${CMAKE_VERBOSE_MAKEFILE}) - set(should_log ON) # prevent warnings in Windows CI - else() - set(should_log OFF) - endif() - - include(ExternalProject) - if(WIN32) - ExternalProject_Add(curl-7.75.0 - URL https://github.com/curl/curl/releases/download/curl-7_75_0/curl-7.75.0.tar.gz - URL_MD5 2071994cfc5079d03439915f2751c8bc - LOG_CONFIGURE ${should_log} - LOG_BUILD ${should_log} - CMAKE_ARGS - -DENABLE_MANUAL=OFF - -DBUILD_TESTING=OFF - -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/libcurl_install - -Wno-dev - TIMEOUT 600 - ) - else() - ExternalProject_Add(curl-7.75.0 - URL https://github.com/curl/curl/releases/download/curl-7_75_0/curl-7.75.0.tar.gz - URL_MD5 2071994cfc5079d03439915f2751c8bc - CONFIGURE_COMMAND - /configure - CFLAGS=${extra_c_flags} - CXXFLAGS=${extra_cxx_flags} - PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PKGCONFIG_FOR_OPENSSL} - --prefix=${CMAKE_CURRENT_BINARY_DIR}/libcurl_install - --with-ssl - --without-libpsl - --without-libidn2 - BUILD_COMMAND $(MAKE) - INSTALL_COMMAND $(MAKE) install - TIMEOUT 600 - ) - endif() - - # The external project will install to the build folder, but we'll install that on make install. - install( - DIRECTORY - ${CMAKE_CURRENT_BINARY_DIR}/libcurl_install/ - DESTINATION - ${CMAKE_INSTALL_PREFIX}/opt/libcurl_vendor - ) -endmacro() - -find_package(CURL QUIET) - -if(FORCE_BUILD_VENDOR_PKG OR NOT CURL_FOUND) - # System curl not found, build one locally. - build_libcurl() - - if(WIN32) - ament_environment_hooks(env_hook/libcurl_vendor_library_path.bat) - set(ENV_VAR_NAME "PATH") - set(ENV_VAR_VALUE "opt\\libcurl_vendor\\bin") - else() - ament_environment_hooks(env_hook/libcurl_vendor_library_path.sh) - if(APPLE) - set(ENV_VAR_NAME "DYLD_LIBRARY_PATH") - else() - set(ENV_VAR_NAME "LD_LIBRARY_PATH") - endif() - set(ENV_VAR_VALUE "opt/libcurl_vendor/lib") - endif() - ament_environment_hooks(env_hook/libcurl_vendor_library_path.dsv.in) - set(CURL_FOUND FALSE) -endif() - -ament_package( - CONFIG_EXTRAS "libcurl_vendor-extras.cmake.in" -) diff --git a/libcurl_vendor/env_hook/libcurl_vendor_library_path.bat b/libcurl_vendor/env_hook/libcurl_vendor_library_path.bat deleted file mode 100644 index 15d8e67..0000000 --- a/libcurl_vendor/env_hook/libcurl_vendor_library_path.bat +++ /dev/null @@ -1,41 +0,0 @@ -:: copied from libcurl_vendor/env_hook/libcurl_vendor_library_path.bat -@echo off - -call:ament_prepend_unique_value PATH "%AMENT_CURRENT_PREFIX%\opt\libcurl_vendor\bin" - -goto:eof - -:: Prepend non-duplicate values to environment variables -:: using semicolons as separators and avoiding trailing separators. -:: first argument: the name of the result variable -:: second argument: the value -:ament_prepend_unique_value - setlocal enabledelayedexpansion - :: arguments - set "listname=%~1" - set "value=%~2" - :: skip if path doesn't exist - if NOT EXIST "%value%" ( - goto:eof - ) - :: expand the list variable - set "list=!%listname%!" - :: check if the list contains the value - set "is_duplicate=" - if "%list%" NEQ "" ( - for %%v in ("%list:;=";"%") do ( - if "%%~v" == "%value%" set "is_duplicate=1" - ) - ) - :: if it is not a duplicate prepend it - if "%is_duplicate%" == "" ( - :: if not empty, prepend a semi-colon - if "!list!" NEQ "" set "list=;!list!" - :: prepend the value - set "list=%value%!list!" - ) - endlocal & ( - :: set result variable in parent scope - set "%~1=%list%" - ) -goto:eof diff --git a/libcurl_vendor/env_hook/libcurl_vendor_library_path.dsv.in b/libcurl_vendor/env_hook/libcurl_vendor_library_path.dsv.in deleted file mode 100644 index 92145c4..0000000 --- a/libcurl_vendor/env_hook/libcurl_vendor_library_path.dsv.in +++ /dev/null @@ -1 +0,0 @@ -prepend-non-duplicate;@ENV_VAR_NAME@;@ENV_VAR_VALUE@ diff --git a/libcurl_vendor/env_hook/libcurl_vendor_library_path.sh b/libcurl_vendor/env_hook/libcurl_vendor_library_path.sh deleted file mode 100644 index 696b961..0000000 --- a/libcurl_vendor/env_hook/libcurl_vendor_library_path.sh +++ /dev/null @@ -1,16 +0,0 @@ -# copied from libcurl_vendor/env_hook/libcurl_vendor_library_path.sh - -# detect if running on Darwin platform -_UNAME=`uname -s` -_IS_DARWIN=0 -if [ "$_UNAME" = "Darwin" ]; then - _IS_DARWIN=1 -fi -unset _UNAME - -if [ $_IS_DARWIN -eq 0 ]; then - ament_prepend_unique_value LD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/opt/libcurl_vendor/lib" -else - ament_prepend_unique_value DYLD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/opt/libcurl_vendor/lib" -fi -unset _IS_DARWIN diff --git a/libcurl_vendor/libcurl_vendor-extras.cmake.in b/libcurl_vendor/libcurl_vendor-extras.cmake.in deleted file mode 100644 index 4e57e15..0000000 --- a/libcurl_vendor/libcurl_vendor-extras.cmake.in +++ /dev/null @@ -1,55 +0,0 @@ -# Ignore the broken curl-config.cmake in 7.58 -if(NOT @CURL_FOUND@) - set(CURL_NO_CURL_CMAKE ON) -endif() - -# Look for system curl first. -find_package(CURL QUIET) - -# System curl not found, try to find our locally built copy. -if(NOT CURL_FOUND) - if(WIN32) - # Force cmake to find the curl-config file in our local build. - set(curl_DIR "${@PROJECT_NAME@_DIR}/../../../opt/libcurl_vendor/CMake") - message(STATUS "Setting curl_DIR to: '${curl_DIR}'") - - find_package(curl REQUIRED PATHS "${curl_DIR}" NO_MODULE NO_DEFAULT_PATH) - - set(CURL_LIBRARIES CURL::libcurl) - else() - # In this case, the vendor package should have built and installed a local copy. - include(FindPkgConfig) - if(NOT PKG_CONFIG_FOUND) - message(FATAL_ERROR "Could not find pkg-config") - endif() - # Put the local copy's pkgconfig dir on the PKG_CONFIG_PATH. - set(ENV{PKG_CONFIG_PATH} - "$ENV{PKG_CONFIG_PATH}:${@PROJECT_NAME@_DIR}/../../../opt/libcurl_vendor/lib/pkgconfig") - pkg_search_module(CURL REQUIRED libcurl) - endif() -endif() - -# message(STATUS "CURL_FOUND: ${CURL_FOUND}") -# message(STATUS "CURL_LIBRARIES: ${CURL_LIBRARIES}") -# message(STATUS "CURL_LIBRARY_DIRS: ${CURL_LIBRARY_DIRS}") -# message(STATUS "CURL_INCLUDE_DIRS: ${CURL_INCLUDE_DIRS}") - -set(libcurl_vendor_LIBRARIES) -foreach(library IN LISTS CURL_LIBRARIES) - message(STATUS "library: ${library}") - if(IS_ABSOLUTE "${library}" OR TARGET ${library}) - list(APPEND libcurl_vendor_LIBRARIES "${library}") - else() - find_library(library_abs ${library} PATHS "${CURL_LIBRARY_DIRS}" NO_DEFAULT_PATH) - list(APPEND libcurl_vendor_LIBRARIES "${library_abs}") - endif() -endforeach() -set(libcurl_vendor_LIBRARY_DIRS ${CURL_LIBRARY_DIRS}) -set(libcurl_vendor_INCLUDE_DIRS ${CURL_INCLUDE_DIRS}) -if(TARGET CURL::libcurl) - set(libcurl_vendor_TARGETS CURL::libcurl) -endif() - -# message(STATUS "libcurl_vendor_LIBRARIES: ${libcurl_vendor_LIBRARIES}") -# message(STATUS "libcurl_vendor_LIBRARY_DIRS: ${libcurl_vendor_LIBRARY_DIRS}") -# message(STATUS "libcurl_vendor_INCLUDE_DIRS: ${libcurl_vendor_INCLUDE_DIRS}") diff --git a/libcurl_vendor/package.xml b/libcurl_vendor/package.xml deleted file mode 100644 index 1d6b8b7..0000000 --- a/libcurl_vendor/package.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - libcurl_vendor - 3.0.0 - - Wrapper around libcurl, it provides a fixed CMake module and an ExternalProject build of it. - - - Alejandro Hernandez Cordero - - Apache License 2.0 - - MIT - - William Woodall - - https://github.com/curl/curl - - ament_cmake - - pkg-config - - curl - - - ament_cmake - - diff --git a/resource_retriever/CMakeLists.txt b/resource_retriever/CMakeLists.txt index 5198148..6690397 100644 --- a/resource_retriever/CMakeLists.txt +++ b/resource_retriever/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(resource_retriever) # Default to C++14 @@ -10,10 +10,9 @@ if(NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic") endif() -find_package(ament_cmake_ros REQUIRED) +find_package(ament_cmake REQUIRED) find_package(ament_index_cpp REQUIRED) -# TODO(wjwwood): remove libcurl_vendor and just use system curl when possible -find_package(libcurl_vendor REQUIRED) +find_package(CURL REQUIRED) # TODO(wjwwood): split cpp and python apis into separate packages @@ -23,20 +22,22 @@ target_include_directories(${PROJECT_NAME} $ $ ) -ament_target_dependencies(${PROJECT_NAME} - ament_index_cpp - libcurl_vendor +target_link_libraries(${PROJECT_NAME} PRIVATE + ament_index_cpp::ament_index_cpp + CURL::libcurl ) # Causes the visibility macros to use dllexport rather than dllimport, # which is appropriate when building the dll but not consuming it. target_compile_definitions(${PROJECT_NAME} PRIVATE "RESOURCE_RETRIEVER_BUILDING_LIBRARY") -# specific order: dependents before dependencies +# Export old-style CMake variables ament_export_include_directories(include) + +# Export modern CMake targets ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET) +# specific order: dependents before dependencies ament_export_dependencies(ament_index_cpp) -ament_export_dependencies(libcurl_vendor) ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR src/${PROJECT_NAME}) diff --git a/resource_retriever/package.xml b/resource_retriever/package.xml index 1af9bdf..2d9ef4d 100644 --- a/resource_retriever/package.xml +++ b/resource_retriever/package.xml @@ -23,11 +23,13 @@ https://github.com/ros/robot_model https://github.com/ros/robot_model/issues - ament_cmake_ros + ament_cmake + + libcurl-dev + libcurl ament_index_cpp ament_index_python - libcurl_vendor ament_cmake_gtest ament_cmake_pytest From 8ce5c417f0ec771e2b9f3655191003752b0ed6fe Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 13:56:35 -0800 Subject: [PATCH 02/14] Use curl location has hint to find_package Signed-off-by: Shane Loretz --- resource_retriever/CMakeLists.txt | 8 ++++---- resource_retriever/package.xml | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/resource_retriever/CMakeLists.txt b/resource_retriever/CMakeLists.txt index 6690397..0b52a4a 100644 --- a/resource_retriever/CMakeLists.txt +++ b/resource_retriever/CMakeLists.txt @@ -12,11 +12,12 @@ endif() find_package(ament_cmake REQUIRED) find_package(ament_index_cpp REQUIRED) -find_package(CURL REQUIRED) + +include(find_libcurl-extras.cmake) # TODO(wjwwood): split cpp and python apis into separate packages -add_library(${PROJECT_NAME} src/retriever.cpp) +add_library(${PROJECT_NAME} SHARED src/retriever.cpp) target_include_directories(${PROJECT_NAME} PUBLIC $ @@ -36,7 +37,6 @@ ament_export_include_directories(include) # Export modern CMake targets ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET) -# specific order: dependents before dependencies ament_export_dependencies(ament_index_cpp) ament_python_install_package(${PROJECT_NAME} @@ -97,4 +97,4 @@ install( DESTINATION include ) -ament_package() +ament_package(CONFIG_EXTRAS find_libcurl-extras.cmake) diff --git a/resource_retriever/package.xml b/resource_retriever/package.xml index 2d9ef4d..187c2eb 100644 --- a/resource_retriever/package.xml +++ b/resource_retriever/package.xml @@ -26,6 +26,7 @@ ament_cmake libcurl-dev + libcurl libcurl ament_index_cpp From 45e1c81ca3b4d66da622bc1a5ece22274b934726 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 15:11:53 -0800 Subject: [PATCH 03/14] Add find_libcurl-extras file Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 resource_retriever/find_libcurl-extras.cmake diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake new file mode 100644 index 0000000..2ba4fc2 --- /dev/null +++ b/resource_retriever/find_libcurl-extras.cmake @@ -0,0 +1,11 @@ +find_package(CURL QUIET) + +if(NOT CURL_FOUND) + find_program(_curl_program NAMES curl curl.exe) + if(_curl_program) + get_filename_component(_curl_prefix "${_curl_program}" DIRECTORY) + find_package(CURL REQUIRED HINTS "${_curl_prefix}") + else() + find_package(CURL REQUIRED) + endif() +endif() From ed91937ef035ac033f10d79e0be4bb8dd33a6f22 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 15:31:53 -0800 Subject: [PATCH 04/14] Use CMAKE_FIND_LIBRARY_SUFFIXES Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake index 2ba4fc2..6435d1d 100644 --- a/resource_retriever/find_libcurl-extras.cmake +++ b/resource_retriever/find_libcurl-extras.cmake @@ -1,9 +1,14 @@ find_package(CURL QUIET) if(NOT CURL_FOUND) + if(WIN32) + # Chocolatey package is compiled with mingw, which uses these suffixes for libraries + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") + endif() find_program(_curl_program NAMES curl curl.exe) if(_curl_program) get_filename_component(_curl_prefix "${_curl_program}" DIRECTORY) + message(STATUS "Looking for CURL in ${_curl_prefix}") find_package(CURL REQUIRED HINTS "${_curl_prefix}") else() find_package(CURL REQUIRED) From a2b9b56fadd677eff9b6ab9aa668cb405ca83cd4 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 15:37:23 -0800 Subject: [PATCH 05/14] Copyright Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake index 6435d1d..c3fc8d3 100644 --- a/resource_retriever/find_libcurl-extras.cmake +++ b/resource_retriever/find_libcurl-extras.cmake @@ -1,3 +1,17 @@ +# Copyright 2022 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + find_package(CURL QUIET) if(NOT CURL_FOUND) From 06215484ffc39913d4659118fc1ac157f8966d84 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 15:52:57 -0800 Subject: [PATCH 06/14] Ignore Windows 10 curl install Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake index c3fc8d3..a30f937 100644 --- a/resource_retriever/find_libcurl-extras.cmake +++ b/resource_retriever/find_libcurl-extras.cmake @@ -18,8 +18,16 @@ if(NOT CURL_FOUND) if(WIN32) # Chocolatey package is compiled with mingw, which uses these suffixes for libraries list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") + # Ignore curl shipped with default windows 10 since it has no headers or libraries + # We want the one installed by chocolatey + set(_old_ignore_paths "${CMAKE_IGNORE_PATH}") + list(APPEND CMAKE_IGNORE_PATH "C:/Windows/System32") endif() find_program(_curl_program NAMES curl curl.exe) + if(WIN32) + # Undo ignoring of the system paths + set(CMAKE_IGNORE_PATH "${_old_ignore_paths}") + endif() if(_curl_program) get_filename_component(_curl_prefix "${_curl_program}" DIRECTORY) message(STATUS "Looking for CURL in ${_curl_prefix}") From f35a90ee717121de253b15bc9f592ab198bce45f Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 16:46:47 -0800 Subject: [PATCH 07/14] Try looking for shimgen executables Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 67 ++++++++++++++------ 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake index a30f937..496167f 100644 --- a/resource_retriever/find_libcurl-extras.cmake +++ b/resource_retriever/find_libcurl-extras.cmake @@ -12,27 +12,58 @@ # See the License for the specific language governing permissions and # limitations under the License. -find_package(CURL QUIET) -if(NOT CURL_FOUND) - if(WIN32) - # Chocolatey package is compiled with mingw, which uses these suffixes for libraries - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") - # Ignore curl shipped with default windows 10 since it has no headers or libraries - # We want the one installed by chocolatey - set(_old_ignore_paths "${CMAKE_IGNORE_PATH}") - list(APPEND CMAKE_IGNORE_PATH "C:/Windows/System32") - endif() +function(locate_chocolatey_curl output_var) + set("${output_var}" "${output_var}-NOTFOUND") + + # Chocolatey package is compiled with mingw, which uses these suffixes for libraries + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") + + # Find the chocolatey curl executable - ignore curl shipped with Windows 10 + set(_old_ignore_paths "${CMAKE_IGNORE_PATH}") + list(APPEND CMAKE_IGNORE_PATH "C:/Windows/System32") find_program(_curl_program NAMES curl curl.exe) + # Undo ignoring of the system paths + set(CMAKE_IGNORE_PATH "${_old_ignore_paths}") + + if(_curl_program) + # Check if this is a shimgen executable + execute_process(COMMAND "${_curl_program}" --shimgen-noop OUTPUT_VARIABLE shimgen_output) + message(STATUS "Shimgen: ${shimgen_output}") + + # Look for output that says the real path to executable + string(REGEX MATCH "path to executable: ([^\r^\n]+)" "${shimgen_output}") + if(CMAKE_MATCH_0) + message(STATUS "Found chocolatey curl: ${CMAKE_MATCH_0}") + get_filename_component(dir_containing_curl "${CMAKE_MATCH_0}" DIRECTORY) + get_filename_component(dir_containing_dir "${dir_containing_curl}" DIRECTORY) + set("${output_var}" "${dir_containing_dir}" PARENT_SCOPE) + endif() + endif() + + set("${output_var}" "${output_var}" PARENT_SCOPE) +endfunction() + + +macro(find_curl_win32) + find_package(CURL QUIET) + + if(NOT CURL_FOUND) + locate_chocolatey_curl(choco_curl_location) + message(STATUS "Looking for CURL in ${choco_curl_location}") + find_package(CURL REQUIRED HINTS "${choco_curl_location}") + endif() +endmacro() + + +macro(find_curl) if(WIN32) - # Undo ignoring of the system paths - set(CMAKE_IGNORE_PATH "${_old_ignore_paths}") + find_curl_win32() endif() - if(_curl_program) - get_filename_component(_curl_prefix "${_curl_program}" DIRECTORY) - message(STATUS "Looking for CURL in ${_curl_prefix}") - find_package(CURL REQUIRED HINTS "${_curl_prefix}") - else() + + if(NOT CURL_FOUND) find_package(CURL REQUIRED) endif() -endif() +endmacro() + +find_curl() From cefdb56f9b00658c0e2eaa7f772d494e9ba2d1dd Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 17:07:01 -0800 Subject: [PATCH 08/14] Fix string() args error Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake index 496167f..e50c0c1 100644 --- a/resource_retriever/find_libcurl-extras.cmake +++ b/resource_retriever/find_libcurl-extras.cmake @@ -32,8 +32,8 @@ function(locate_chocolatey_curl output_var) message(STATUS "Shimgen: ${shimgen_output}") # Look for output that says the real path to executable - string(REGEX MATCH "path to executable: ([^\r^\n]+)" "${shimgen_output}") - if(CMAKE_MATCH_0) + string(REGEX MATCH "path to executable: ([^\r\n]+)" regex_match "${shimgen_output}") + if(regex_match) message(STATUS "Found chocolatey curl: ${CMAKE_MATCH_0}") get_filename_component(dir_containing_curl "${CMAKE_MATCH_0}" DIRECTORY) get_filename_component(dir_containing_dir "${dir_containing_curl}" DIRECTORY) @@ -50,8 +50,10 @@ macro(find_curl_win32) if(NOT CURL_FOUND) locate_chocolatey_curl(choco_curl_location) - message(STATUS "Looking for CURL in ${choco_curl_location}") - find_package(CURL REQUIRED HINTS "${choco_curl_location}") + if(choco_curl_location) + message(STATUS "Looking for CURL in ${choco_curl_location}") + find_package(CURL REQUIRED HINTS "${choco_curl_location}") + endif() endif() endmacro() From 1be60a27c5b171dbc7de963a72b8ceade0f6a61d Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 17:18:41 -0800 Subject: [PATCH 09/14] Fix another bug Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake index e50c0c1..8e61e28 100644 --- a/resource_retriever/find_libcurl-extras.cmake +++ b/resource_retriever/find_libcurl-extras.cmake @@ -14,7 +14,7 @@ function(locate_chocolatey_curl output_var) - set("${output_var}" "${output_var}-NOTFOUND") + set(location "${output_var}-NOTFOUND") # Chocolatey package is compiled with mingw, which uses these suffixes for libraries list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") @@ -37,11 +37,11 @@ function(locate_chocolatey_curl output_var) message(STATUS "Found chocolatey curl: ${CMAKE_MATCH_0}") get_filename_component(dir_containing_curl "${CMAKE_MATCH_0}" DIRECTORY) get_filename_component(dir_containing_dir "${dir_containing_curl}" DIRECTORY) - set("${output_var}" "${dir_containing_dir}" PARENT_SCOPE) + set(location "${dir_containing_dir}" PARENT_SCOPE) endif() endif() - set("${output_var}" "${output_var}" PARENT_SCOPE) + set("${output_var}" "${location}" PARENT_SCOPE) endfunction() From dabd096e7b20e22ac371dffc1715b30bf6b28322 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 17:31:44 -0800 Subject: [PATCH 10/14] Fix more bugs Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake index 8e61e28..a9475c8 100644 --- a/resource_retriever/find_libcurl-extras.cmake +++ b/resource_retriever/find_libcurl-extras.cmake @@ -34,10 +34,12 @@ function(locate_chocolatey_curl output_var) # Look for output that says the real path to executable string(REGEX MATCH "path to executable: ([^\r\n]+)" regex_match "${shimgen_output}") if(regex_match) - message(STATUS "Found chocolatey curl: ${CMAKE_MATCH_0}") - get_filename_component(dir_containing_curl "${CMAKE_MATCH_0}" DIRECTORY) - get_filename_component(dir_containing_dir "${dir_containing_curl}" DIRECTORY) - set(location "${dir_containing_dir}" PARENT_SCOPE) + message(STATUS "Found chocolatey curl: ${CMAKE_MATCH_1}") + # Get .../bin directory + get_filename_component(dir_containing_curl "${CMAKE_MATCH_1}" DIRECTORY) + # The prefix to look for libcurl is the directory containing bin + get_filename_component(dir_containing_bin "${dir_containing_curl}" DIRECTORY) + set(location "${dir_containing_bin}" PARENT_SCOPE) endif() endif() From 95e427fbb8aba0e8c3e3b0d247dace40569f9bac Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 17:46:05 -0800 Subject: [PATCH 11/14] more bugs? Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake index a9475c8..3e454cc 100644 --- a/resource_retriever/find_libcurl-extras.cmake +++ b/resource_retriever/find_libcurl-extras.cmake @@ -34,12 +34,12 @@ function(locate_chocolatey_curl output_var) # Look for output that says the real path to executable string(REGEX MATCH "path to executable: ([^\r\n]+)" regex_match "${shimgen_output}") if(regex_match) - message(STATUS "Found chocolatey curl: ${CMAKE_MATCH_1}") + message(STATUS "Found chocolatey curl: '${CMAKE_MATCH_1}'") # Get .../bin directory get_filename_component(dir_containing_curl "${CMAKE_MATCH_1}" DIRECTORY) # The prefix to look for libcurl is the directory containing bin get_filename_component(dir_containing_bin "${dir_containing_curl}" DIRECTORY) - set(location "${dir_containing_bin}" PARENT_SCOPE) + set(location "${dir_containing_bin}") endif() endif() From 0eec9ec9db430ebf831a44a75ba5eef0ea9cfdd4 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 18:05:13 -0800 Subject: [PATCH 12/14] Another try Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake index 3e454cc..764cd48 100644 --- a/resource_retriever/find_libcurl-extras.cmake +++ b/resource_retriever/find_libcurl-extras.cmake @@ -54,6 +54,10 @@ macro(find_curl_win32) locate_chocolatey_curl(choco_curl_location) if(choco_curl_location) message(STATUS "Looking for CURL in ${choco_curl_location}") + # Add extra search paths to find_path/find_library to assist FindCURL.cmake + list(APPEND CMAKE_INCLUDE_PATH "${choco_curl_location}") + list(APPEND CMAKE_LIBRARY_PATH "${choco_curl_location}") + # Also set HINTS in case the chocolatey package ever provides curlConfig.cmake find_package(CURL REQUIRED HINTS "${choco_curl_location}") endif() endif() From 93c38796173def96f43010b51f7b85f86309475b Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 18:14:11 -0800 Subject: [PATCH 13/14] Set cmake prefix path Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake index 764cd48..22a8c78 100644 --- a/resource_retriever/find_libcurl-extras.cmake +++ b/resource_retriever/find_libcurl-extras.cmake @@ -54,11 +54,9 @@ macro(find_curl_win32) locate_chocolatey_curl(choco_curl_location) if(choco_curl_location) message(STATUS "Looking for CURL in ${choco_curl_location}") - # Add extra search paths to find_path/find_library to assist FindCURL.cmake - list(APPEND CMAKE_INCLUDE_PATH "${choco_curl_location}") - list(APPEND CMAKE_LIBRARY_PATH "${choco_curl_location}") - # Also set HINTS in case the chocolatey package ever provides curlConfig.cmake - find_package(CURL REQUIRED HINTS "${choco_curl_location}") + # Add extra search path to assist FindCURL.cmake + list(APPEND CMAKE_PREFIX_PATH "${choco_curl_location}") + find_package(CURL REQUIRED) endif() endif() endmacro() From 28d50acf8457c430b0c4d974b69830ea9f8ccee5 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Thu, 3 Feb 2022 18:22:38 -0800 Subject: [PATCH 14/14] Append to CMAKE_FIND_LIBRARY in same scope as find_package call Signed-off-by: Shane Loretz --- resource_retriever/find_libcurl-extras.cmake | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/resource_retriever/find_libcurl-extras.cmake b/resource_retriever/find_libcurl-extras.cmake index 22a8c78..43b1d0b 100644 --- a/resource_retriever/find_libcurl-extras.cmake +++ b/resource_retriever/find_libcurl-extras.cmake @@ -16,9 +16,6 @@ function(locate_chocolatey_curl output_var) set(location "${output_var}-NOTFOUND") - # Chocolatey package is compiled with mingw, which uses these suffixes for libraries - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") - # Find the chocolatey curl executable - ignore curl shipped with Windows 10 set(_old_ignore_paths "${CMAKE_IGNORE_PATH}") list(APPEND CMAKE_IGNORE_PATH "C:/Windows/System32") @@ -54,7 +51,9 @@ macro(find_curl_win32) locate_chocolatey_curl(choco_curl_location) if(choco_curl_location) message(STATUS "Looking for CURL in ${choco_curl_location}") - # Add extra search path to assist FindCURL.cmake + # Chocolatey package is compiled with mingw, which uses these suffixes for libraries + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a") + # Add choco curl location as an extra search path to assist FindCURL.cmake list(APPEND CMAKE_PREFIX_PATH "${choco_curl_location}") find_package(CURL REQUIRED) endif()