Open hwhsu1231 opened 2 years ago
This is kind of a chicken and egg problem, you cannot pass the toolchain because it doesnt exist yet. Unless you want to build a cmake flow that actually stops at the first pass after generating the conan stuff, and then it can use the toolchain at the second run, then, using the toolchain file is impossible by CMake behavior. Even if that is possible, then it is certainly not a conventional flow, and if you need to teach developers to do that, why not just letting them run a "conan install"?
In any case the conan_toolchain.cmake
is mostly there to try go guarantee that your CMake configuration follows the Conan settings. As the goal of cmake-conan is the opposite, to obtain the Conan settings from the current CMake configuration, that renders the conan_toolchain.cmake
mostly useles, because it should largely contain what is somewhat already defined in the current CMake run.
@memsharded Are you saying,
It's "not" possible/reasonable/recommended to use CMake-Conan with CMakeToolchain
generator?
Can somebody clarify this? I would also like to use cmake-conan (but with an existing conanfile.py) because this would integrate with IDEs which doesn't have a good conan integration yet.
Can somebody clarify this? I would also like to use cmake-conan (but with an existing conanfile.py) because this would integrate with IDEs which doesn't have a good conan integration yet.
@lbckmnn, If you want to use the existing conanfile.py
, then you won't need to use conan_cmake_configure()
. Because this command is used to generate a conanfile.txt
recipe file.
If you want to use CMake-Conan, I suggest that you use CMakeDeps
generator, instead. Because it seems that it has some problems with CMakeToolchain
generator when using CMake-Conan.
@czoido @memsharded
If CMakeToolchain
generator is NOT appropriate to use with CMake-Conan, should it add some NOTES on README.md
to tell users not to use it?
Hi @hwhsu1231, I think so, we will add a note about that in the docs. Also, please check we added a note about compatibility with Conan 2.0 in the README in develop branch.
This CAE problem is probably solved by the solution that I proposed previously. (https://github.com/conan-io/cmake-conan/issues/449)
Project Link: https://github.com/hwhsu1231/cmake-conan-setup
In Conan documentation, it says that we need to add
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake
in the command-line. That is, we have to generate theconan_toolchain.cmake
file "before" we runcmake
to configure the project.However, with CMake-Conan, we use
conan_cmake_configure()
to generateconanfile.txt
file, and useconan_cmake_install()
to runconan install
command. If we addCMakeToolchain
generator inconan_cmake_configure()
, theconan_toolchain.cmake
file will be generated after theconan_cmake_install()
is conducted.It looks like the
conan_toolchain.cmake
file is generated "after" we runcmake
executable.How to deal with this situation?