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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[package] libcurl/8.0.1: Failure to build libcurl with c-ares on Windows (MSVC) #17193

Open
sburton84 opened this issue Apr 24, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@sburton84
Copy link

Description

When installing libcurl as a dependency on Windows (using MSVC 2022 (v17)) with the with_c_ares option enabled it fails to configure the libcurl CMake project with the following error:

CMake Error at C:/Users/_/.conan/data/libcurl/8.0.1/_/_/build/3d6dc9bc3e93f92e143d8d9e86f4c0f89607a5b8/build/CMakeFiles/CMakeScratch/TryCompile-ar9c8l/cmTC_b7435Targets.cmake:21 (set_target_properties):
  The link interface of target "c-ares::cares" contains:

    CONAN_LIB::c-ares_c-ares_cares_cares_DEBUG

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

This only seems to happen on Windows, Linux builds work fine. Release builds fail in the same way but with the CONAN_LIB::c-ares_c-ares_cares_cares_RELEASE target instead.

Package and Environment Details

  • Package Name/Version: libcurl/8.0.1
  • Operating System+version: Windows Server 2022
  • Compiler+version: Visual Studio Enterprise 2022 (version 17.5.33530.505)
  • Conan version: conan 1.59.0
  • Python version: Python 3.9.13

Conan profile

Configuration (profile_host):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=Visual Studio
compiler.runtime=MDd
compiler.version=17
os=Windows
os_build=Windows
[options]
libcurl:with_ssl=openssl
[build_requires]
[env]

Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=17
os=Windows
os_build=Windows
[options]
[build_requires]
[env]

Steps to reproduce

conan install libcurl/8.0.1@ -s build_type=Debug -pr:b=default -pr:h=default --build=missing --update -o with_c_ares=True

Logs

Click to expand log
libcurl/8.0.1: Copying sources to build folder
libcurl/8.0.1: Building your package in C:\Users\_\.conan\data\libcurl\8.0.1\_\_\build\6962e5555191b0f8cd70795c0ffd574d19c1c001
libcurl/8.0.1: Generator txt created conanbuildinfo.txt
libcurl/8.0.1: Calling generate()
libcurl/8.0.1: Preset 'default' added to CMakePresets.json. Invoke it manually using 'cmake --preset default'
libcurl/8.0.1: If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake <path> -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=C:\Users\_\.conan\data\libcurl\8.0.1\_\_\build\6962e5555191b0f8cd70795c0ffd574d19c1c001\build\generators\conan_toolchain.cmake -DCURL_CA_BUNDLE=auto -DCURL_CA_PATH=auto -DCURL_CA_FALLBACK=OFF -DCMAKE_POLICY_DEFAULT_CMP0091=NEW'
libcurl/8.0.1: Aggregating env generators
libcurl/8.0.1: Calling build()
libcurl/8.0.1: apply_conandata_patches(): No patches defined in conandata
libcurl/8.0.1: CMake command: cmake -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="C:/Users/_/.conan/data/libcurl/8.0.1/_/_/build/6962e5555191b0f8cd70795c0ffd574d19c1c001/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/_/.conan/data/libcurl/8.0.1/_/_/package/6962e5555191b0f8cd70795c0ffd574d19c1c001" -DCURL_CA_BUNDLE="auto" -DCURL_CA_PATH="auto" -DCURL_CA_FALLBACK="OFF" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "C:\Users\_\.conan\data\libcurl\8.0.1\_\_\build\6962e5555191b0f8cd70795c0ffd574d19c1c001\src"
-- Using Conan toolchain: C:/Users/_/.conan/data/libcurl/8.0.1/_/_/build/6962e5555191b0f8cd70795c0ffd574d19c1c001/build/generators/conan_toolchain.cmake
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.34.31937.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- curl version=[8.0.1]
-- Conan: Component target declared 'c-ares::cares'
-- Found Perl: C:/Strawberry/perl/bin/perl.exe (found version "5.32.1")
-- Looking for getch in ws2_32;c-ares::cares
CMake Error at C:/Users/_/.conan/data/libcurl/8.0.1/_/_/build/6962e5555191b0f8cd70795c0ffd574d19c1c001/build/CMakeFiles/CMakeScratch/TryCompile-upo164/cmTC_55d49Targets.cmake:21 (set_target_properties):
  The link interface of target "c-ares::cares" contains:

    CONAN_LIB::c-ares_c-ares_cares_cares_DEBUG

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  C:/Users/_/.conan/data/libcurl/8.0.1/_/_/build/6962e5555191b0f8cd70795c0ffd574d19c1c001/build/CMakeFiles/CMakeScratch/TryCompile-upo164/CMakeLists.txt:19 (include)


CMake Error at C:/Program Files/CMake/share/cmake-3.26/Modules/CheckLibraryExists.cmake:71 (try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  CMake/Macros.cmake:32 (check_library_exists)
  CMakeLists.txt:357 (check_library_exists_concat)


-- Configuring incomplete, errors occurred!
libcurl/8.0.1:
libcurl/8.0.1: ERROR: Package '6962e5555191b0f8cd70795c0ffd574d19c1c001' build failed
libcurl/8.0.1: WARN: Build folder C:\Users\_\.conan\data\libcurl\8.0.1\_\_\build\6962e5555191b0f8cd70795c0ffd574d19c1c001\build
ERROR: libcurl/8.0.1: Error in build() method, line 243
        cmake.configure()
        ConanException: Error 1 while executing cmake -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="C:/Users/_/.conan/data/libcurl/8.0.1/_/_/build/6962e5555191b0f8cd70795c0ffd574d19c1c001/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/_/.conan/data/libcurl/8.0.1/_/_/package/6962e5555191b0f8cd70795c0ffd574d19c1c001" -DCURL_CA_BUNDLE="auto" -DCURL_CA_PATH="auto" -DCURL_CA_FALLBACK="OFF" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "C:\Users\_\.conan\data\libcurl\8.0.1\_\_\build\6962e5555191b0f8cd70795c0ffd574d19c1c001\src"
@sburton84 sburton84 added the bug Something isn't working label Apr 24, 2023
@SpaceIm
Copy link
Contributor

SpaceIm commented Apr 24, 2023

I guess it's a consequence of this macro in libcurl (https://github.com/curl/curl/blob/curl-8_0_1/CMake/Macros.cmake#L31-L37) called several times, which fails in some circumstances depending on what has been appended to CURL_LIBS, due to a conan client issue related to CMakeDeps: conan-io/conan#12180 & conan-io/conan#12012.

I think this line check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}" could be replaced by check_library_exists("${LIBRARY}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}" as a workaround to fix this issue, without other side effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants