conan-io / conan

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

[question] How to use Keychain https://conan.io/center/recipes/keychain in cmake project #16925

Closed hnxsad closed 1 month ago

hnxsad commented 2 months ago

What is your question?

Hi Everyone ,

I new Conan, i have installed https://conan.io/center/recipes/keychain keychain from conan using .py file def requirements(self): self.requires("qt/5.15.14") self.requires("keychain/1.3.0")

and in CMakeList.txt find_package(Qt5 .... keychain REQUIRED)

i tried adding keychain::keychain in target_link_library but its not working . i keep on searching but i am not able to find any thing please help me.. thanks in Advance

Have you read the CONTRIBUTING guide?

hnxsad commented 2 months ago

@memsharded please have a look :)

memsharded commented 2 months ago

Hi @hnxsad

Thanks for your question.

It would be necessary to have some more information, so we can reproduce the issue here. Can you please post:

Thanks for your feedback.

hnxsad commented 2 months ago

Hi @memsharded

1>conan version : 2.0.17

================================================= 2>

Conan version 2.0.17

import subprocess from conan import ConanFile

class WSM(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "CMakeToolchain", "CMakeDeps"

def requirements(self):
    self.requires("keychain/1.3.0")

def build_requirements(self):
    self.build_requires("cmake/[>=3.28]")

# cmake_layout
def layout(self):
    self.folders.generators = "build/generators"
    self.folders.build = "cmake_layout"

=================================================

3>

CMake minimun version required

cmake_minimum_required(VERSION 3.15)

Project details

project(ABC LANGUAGES CXX)

Set C++ standard

set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(keychain REQUIRED)

in target_link_libraries i tried keychain::keychain , but got error : the target was not found

======================================================================

4> conan install conanfile.py -s build_type=Release --profile=windows-64-intel.profile --build=missing

conan install conanfile.py -s build_type=Release --profile=windows-64-intel.profile --build=missing

======== Input profiles ======== Profile host: [settings] arch=x86 build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows

Profile build: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows

======== Computing dependency graph ======== qt/5.15.14: qt5: requested modules ['qtnetworkauth', 'qtimageformats', 'qtxmlpatterns', 'qtdeclarative', 'qtmultimedia', 'qtwebsockets', 'qtsvg', 'qttranslations'] Graph root conanfile.py: C:\Code_Base\WSM\WSM\conanfile.py Requirements brotli/1.1.0#d56d7bb9ca722942aba17369cb5c0519 - Cache bzip2/1.0.8#457c272f7da34cb9c67456dd217d36c4 - Cache double-conversion/3.3.0#33321c201741cc32b51169c6d2d05e60 - Cache freetype/2.13.2#7934d59c447d72edcd56025dc60e1aeb - Cache keychain/1.3.0#1698b8d8953c2bfdc7b9cd0b05845587 - Cache libjpeg/9e#3cd27a78643419450ee6d3739514d25c - Cache libpng/1.6.43#c219d8f01983bac10c404fc613605eef - Cache libpq/15.4#a3354d556287c3d091c9f4d578b66ec8 - Cache md4c/0.4.8#9b5da52e0c0b803bb0d1a4b9fdfe10b1 - Cache openal-soft/1.22.2#506a381e0b805519cba4a7f1ee653fed - Cache opengl/system#4df6fecde4084386beded3ed0e56e4ea - Cache openssl/3.3.1#279e86dc2a7dded8c1fe8512e775bdb1 - Cache pcre2/10.42#576680686b88a4dadf6d382d6d6351d9 - Cache qt/5.15.14#8e99c640555798c4c2b5dedfcff7c394 - Cache sqlite3/3.46.0#de3f4913eb79b97c790a8fc1183e0766 - Cache zlib/1.3.1#f52e03ae3d251dec704634230cd806a2 - Cache zstd/1.5.5#1f239731dc45147c7fc2f54bfbde73df - Cache Build requirements cmake/3.30.1#6d832cf2d46f6ec969ca5ed5b41f91eb - Cache jom/1.1.3#88c83718bcf06946b63cd20bde995e92 - Cache meson/1.2.2#d43246711a59751b79c614da4afe2d82 - Cache meson/1.3.2#a62c3ee83b10fea754afd92ffa74b6f0 - Cache nasm/2.16.01#d0aebbd20ccbb6ad9c9c753ab708098c - Cache ninja/1.11.1#77587f8c8318662ac8e5a7867eb4be21 - Cache pkgconf/2.1.0#27f44583701117b571307cf5b5fe5605 - Cache strawberryperl/5.32.1.1#707032463aa0620fa17ec0d887f5fe41 - Cache Resolved version ranges cmake/[>=3.28]: cmake/3.30.1 jom/[>=1.1 <2]: jom/1.1.3 libpng/[>=1.6 <2]: libpng/1.6.43 openssl/[>=1.1 <4]: openssl/3.3.1 sqlite3/[>=3.45.0 <4]: sqlite3/3.46.0 zlib/[>=1.2.11 <2]: zlib/1.3.1

======== Computing necessary packages ======== Requirements keychain/1.3.0#1698b8d8953c2bfdc7b9cd0b05845587:229a27e22d41023d147ff16c00b2d96a6e09029f#ad421533f40a84baea06d31038a67463 - Cache opengl/system#4df6fecde4084386beded3ed0e56e4ea:da39a3ee5e6b4b0d3255bfef95601890afd80709#0ba8627bd47edc3a501e8f0eb9a79e5e - Cache qt/5.15.14#8e99c640555798c4c2b5dedfcff7c394:1145aefaa35330769be5f36774d3baf503384e8f#4bb32d44be4a68444b1055b7c62740ac - Cache Build requirements cmake/3.30.1#6d832cf2d46f6ec969ca5ed5b41f91eb:522dcea5982a3f8a5b624c16477e47195da2f84f#e4039405f7640830990126c02c0c9959 - Cache Skipped binaries brotli/1.1.0, bzip2/1.0.8, double-conversion/3.3.0, freetype/2.13.2, libjpeg/9e, libpng/1.6.43, libpq/15.4, md4c/0.4.8, openal-soft/1.22.2, openssl/3.3.1, pcre2/10.42, sqlite3/3.46.0, zlib/1.3.1, zstd/1.5.5, jom/1.1.3, meson/1.2.2, meson/1.3.2, nasm/2.16.01, ninja/1.11.1, pkgconf/2.1.0, strawberryperl/5.32.1.1

======== Installing packages ======== cmake/3.30.1: Already installed! (1 of 4) cmake/3.30.1: Appending PATH environment variable: C:\Users\61082723.conan2\p\cmake3081ce9d742b2\p\bin keychain/1.3.0: Already installed! (2 of 4) opengl/system: Already installed! (3 of 4) qt/5.15.14: Already installed! (4 of 4) WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X: WARN: deprecated: 'env_info' used in: cmake/3.30.1 WARN: deprecated: 'cpp_info.filenames' used in: opengl/system WARN: deprecated: 'cpp_info.names' used in: qt/5.15.14 WARN: deprecated: 'cpp_info.build_modules' used in: qt/5.15.14

======== Finalizing install (deploy, generators) ======== conanfile.py: Writing generators to C:\Code_Base\WSM\WSM\build\generators conanfile.py: Generator 'CMakeDeps' calling 'generate()' conanfile.py: CMakeDeps necessary find_package() and targets for your CMakeLists.txt find_package(Qt5) find_package(keychain) target_link_libraries(... qt::qt keychain::keychain) conanfile.py: Generator 'CMakeToolchain' calling 'generate()' conanfile.py: CMakeToolchain generated: conan_toolchain.cmake conanfile.py: Preset 'conan-default' added to CMakePresets.json. Invoke it manually using 'cmake --preset conan-default' if using CMake>=3.23 conanfile.py: If your CMake version is not compatible with CMakePresets (<3.23) call cmake like: 'cmake -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=C:\Code_Base\WSM\WSM\build\generators\conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW' conanfile.py: CMakeToolchain generated: CMakePresets.json conanfile.py: CMakeToolchain generated: ....\CMakeUserPresets.json conanfile.py: Generating aggregated env files conanfile.py: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat'] Install finished successfully

======================================================================

5> cmake --preset=windows-release cmake --build --preset=windows-release

=======================================================================

memsharded commented 2 months ago

Thanks for the feedback.

I am afraid the report is not complete. I still see in the output qt/5.15.14: qt5: req, but you didn't have qt as a requires, so I'd say the output doesn't really correspond to the conanfile.py that you are providing.

Then you comment in target_link_libraries i tried keychain::keychain , but got error : the target was not found, but I don't see a target_link_libraries() in the CMakeLists.txt.

Then, I am missing the output of the cmake ... commands, I'd like to see what errors you are getting there. Also, the windows-release is not a Conan generated preset, it should be conan-default, that is the Conan generated one. If you are not using the Conan generated presets, then please include the full presets files you are using too.

Can you please provide full and reproducible details? If you prefer you can put all in a Github repo then share the repo. Thanks for the feedback!

SpaceIm commented 1 month ago

You say find_package(Qt5 .... keychain REQUIRED) in your first message. This command won't find keychain config file, there must be one find_package() per CMake config/module file you want to find.

hnxsad commented 1 month ago

Hi @memsharded,

Apology for not sharing all input & output section. i was trying to share only one thing which i was working.

I have found that the command which i was trying is in wrong way as @SpaceIm mentioned.

The issue was resolved

first it should one package in find_packages(keychain) [ i was trying in two packages in one command)
then in target_link_libraries(keychain::keychain) since i have downloaded from conan we can use ${keychain_PACKAGE_FOLDER_DEBUG} to get location of keychain in

Thank you for response and it was very helpful @memsharded @SpaceIm :)

memsharded commented 1 month ago

Ok, happy that it is working for you now, I am closing then the ticket as solved, don't hesitate to create new tickets if you have any further question. Thanks for the feedback!