question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using conan_toolchain.cmake when generating it from CMake itself

See original GitHub issue

I am starting to test conan and I am using the CMakeToolchain generator. However, instead of calling conan install ., I am calling it through the CMake conan.cmake package.

So if I just run

cmake -S . --preset whatever

the conan_toolchain.cmake file is generated correctly. On the next run I can do

cmake -S . preset whatever -DCMAKE_TOOLCHAIN_FILE=...

This is unconvenient, as I have to run twice the configuration

However, if I try to run directly with the toolchain file on a clean build, it simply fails to configure because the toolchain is not found. Is there any workaround for this?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
czoidocommented, Jul 1, 2022

Hi @jjcasmar,

Thanks a lot for your question. The use of cmake-conan with CMakeToolchain generator is not recommended. In fact, cmake-conan does not support Conan 2.0 and we don’t know yet if it will. Please, check the comments in this issue about that: https://github.com/conan-io/cmake-conan/issues/410#issuecomment-1095611994 I opened a PR warning about this here: https://github.com/conan-io/cmake-conan/pull/437 I would recommend you to do a conan install directly. We are making lots of improvements in the preset support (better if you use CMake>=3.23) and also you can define the layout now in the conanfile.txt that should make everything easier. There’s some information in this blogpost about the latest release: https://blog.conan.io/2022/06/16/New-conan-release-1-49.html

0reactions
jjcasmarcommented, Jul 3, 2022

In the preset I am adding some build options. However, as you said, (better if you use CMake>=3.23) in CMake 3.23 you can include one preset from another, so probably the developer can add the preset generated by conan on its own preset.

At some point it will be nice if calling cmake could code conan anyway. It will be much easier to integrate.

The last thing I am thinking is how to deal with release/debug mode on dependencies. Most of the time you dont want your dependencies build on Debug mode, even if you are compiling in Debug mode your code. This can be solved with profiles, right?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using conan_toolchain.cmake when generating it ... - GitHub
I am starting to test conan and I am using the CMakeToolchain generator. However, instead of calling conan install . , I am...
Read more >
Cross Compiling With CMake
In order to use CMake for cross-compiling, a CMake file that describes the target platform has to be created, called the “toolchain file,”...
Read more >
CMakeToolchain — conan 1.53.0 documentation
The CMakeToolchain is the toolchain generator for CMake. It will generate toolchain files that can be used in the command line invocation of...
Read more >
CMake Tutorial - Medium
CMake can generate a native build environment that will compile source code, ... CMake itself is a software program, so it should be...
Read more >
Building LLVM with CMake — LLVM 16.0.0git documentation
txt stored at the root of your build directory that is generated by cmake . Editing it yourself is not recommended. Variables are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found