conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
7.95k stars 951 forks source link

[question] Please help how to use NuGet Libraries with Conan and CMake for Builds. #16536

Open leviskim17 opened 6 days ago

leviskim17 commented 6 days ago

What is your question?

conanfile - libpng.txt conandata.yml-libpng.txt conanfile - zlib.txt conandata.yml-zlib.txt

conan version: 2.2.3

Situation After downloading the zlib library through NuGet in Conan, I encountered an issue where CMake could not find zlib when building the libpng package in Conan

Attempts Made

  1. Downloading zlib as NuGet is not working:
  1. Building zlib from source is working well.
  1. Manual Modified CMakeList in libpng.
# Set CMP0091 policy to NEW
if(POLICY CMP0091)
    cmake_policy(SET CMP0091 NEW)
endif()

# Include the Conan toolchain using the absolute path
include("C:/Users/kimjas/.conan2/p/b/zlib0f59ff8bfa3fe/b/conan_toolchain.cmake")
  1. conan_toolchain.cmake in libpng When I checked conan_toolchain.cmake in C:\Users\kimjas.conan2\p\b**libpnb1f2c624ba939**\b\build\generators, I can see CMake configurations for zlib lib, include, bin locations related. However, why is it that the zlib downloaded as NuGet cannot be recognized by CMake in the libpng package?

Are there any further steps required, beyond the attached conanfile, to ensure the usage of the zlib package downloaded from NuGet? Any advice would be greatly appreciated.

Have you read the CONTRIBUTING guide?

memsharded commented 4 days ago

Hi @leviskim17

Thanks for your question.

After downloading the zlib library through NuGet in Conan,

Sorry, it is not very clear what you are trying to achieve. Why would you download it from Nuget?

Some important notes:

I would suggest just building from source the combinations that you need, it is going to be much faster and simpler than trying to fetch them as pre-built from other place. If you still need to go this way, I'd suggest to just do the downloads in the build() method as explained in the docs: https://docs.conan.io/2/tutorial/creating_packages/other_types_of_packages/package_prebuilt_binaries.html#downloading-and-packaging-pre-built-binaries. Do everything in the build() method, do not use source() or layout() for any of this logic.