conan-io / conan-clion-plugin

CLion C/C++ IDE plugin for Conan Package Manager
Apache License 2.0
98 stars 27 forks source link

[Question] Local conan cache package use #185

Open nikoladsp opened 2 months ago

nikoladsp commented 2 months ago

Hi, I am trying to make this plugin works with CLion 2024.1.2. I have a package made by conan that is private, and built locally - so it only exists in my local cache. I failed to figure out how to configure this plugin in CLion in this case. It does not detect my package from cache. Moreover, I am not sure how to configure CMake profiles so I can build and debug using CLion.

What I tried from console is:

export BUILD_TYPE=Debug
conan install . -pr profiles/gcc -s build_type="${BUILD_TYPE}"
cmake -DCMAKE_TOOLCHAIN_FILE="build/${BUILD_TYPE}/generators/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -B "build/${BUILD_TYPE}" -S .
cmake --build "build/${BUILD_TYPE}"

Above commands work. They produces executable that link appropriate GraphicsMagick 1.3.43 (instead of system's 1.3.42).

But if I try to use from CLion it constantly refuses to find it. I tried adding CMake options to Debug profile:

-G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="build/Debug/generators/conan_toolchain.cmake" -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="conan_provider.cmake" -DCONAN_COMMAND="~/.local/bin/conan" 

The output of the build is:

CMake Error at CMakeLists.txt:4 (find_package):
  Could not find a configuration file for package "graphicsmagick" that is
  compatible with requested version "1.3.43".

  The following configuration files were considered but not accepted:

    ~/project_conan/build/Debug/generators/graphicsmagick-config.cmake, version: unknown

I see there are files graphicsmagick-config-version.cmake (with set(PACKAGE_VERSION "1.3.43")) and build/Debug/generators/graphicsmagick-config.cmake

So in the end I am unsure did I do something wrong when building Conan package (asked this on their repo already), is there some problem in this plugin or CLion itself?

Thank you kindly

czoido commented 2 months ago

Hi @nikoladsp, Thanks for the question. I can see that you are running some commands manually, but that should not be necessary using the plugin. You just need to use the UI of CLion and Conan will be launched automatically. A couple of things:

image

Also, please check the docs, you may start from a simple case, check that it works and then add your package for a simple example and see if everything goes fine.

Hope this helps.