-
Notifications
You must be signed in to change notification settings - Fork 951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[question] Using custom cross-compilation toolchains with requirements and CMakeDeps #16376
Comments
Hi @rollebolle Thanks for your question. The def generate(self):
tc = CMakeToolchain(self)
gen_folder = self.generators_folder.replace("\\", "/") # Windows-CMake not happy
tc.variables["MYPATH_GEN"] = gen_folder # IT will be a variable in conan_toolchain.cmake
tc.cache_variables["MYPATH_GEN"] = gen_folder # It will be a cache variables in CMakePresets (and passed in CLI arg)
tc.generate() Does this make sense for your use case? |
Thanks. This does work and I I'll use it. However it means my recipe now has adapations that is only needed in the special case of supplying a toolchain from outside. Ideally I would like the recipe to be agnostic to this detail. As I wrote above, this was not needed with the old generators as the FindXXX files happened to all end up in the build folder. Let me know if I misunderstood. |
Quick question:
Why don't you use the generated |
I tried that but get some nasty conflicts - I think in many advanced cases you want to have complete control of the toolchain file, as in our case. |
I have been thinking a bit about this problem, and honestly I don't know yet what would be the best approach. I think it might be possible to try to find the generated files from your toolchain. This might be done for example by looking for the location of the What would be the best mechanism to communicate the Please let me know if this helps. |
Thanks for taking the time to think about this. Would it make sense for Conan to always append a valid CMAKE_MODULE_PATH to CMakeUserPresets.json, so that even if we use a custom toolchain we can find the dependencies? I don't really know the details around this, but in Conan 2, a dependency on using the generated toolchains to be able to find any requirement packages was introduced. This in combination with the common cross-compile scenario where we want to use a custom toolchain file certainly makes it a bit more complicated to "get it right". |
Yes, this might be something worth exploring.
yes, it is true that the But in any case, I understand the use case, let me discuss with the team, it sounds that to minimize risks we could add those variables when the |
I am exploring the idea in #16455, but it is a draft, I am not very convinced, I might explore other approaches too. |
I have been syncing with the team about #16455 we are still not fully convinced about the approach. We are going to explore the possibility of fully controlling the |
Ok interesting! |
This would be the follow up PR: #16563 Full control over which blocks are enabled or not, with just a conf. That would allow to keep the If you want to give it a try from sources, that would be very useful feedback. |
What is your question?
Updating to conan 2.3.2
I'm building packages via a Yocto based x-compilation toolchain, and the SDK generates this toolchain for us. It is vital to use it as it sets
CMAKE_FIND_ROOT_PATH
among other things, to find packages that are in the SDK and does not come from Conan. Therefore I override the generated toolchain with thetools.cmake.cmaketoolchain:toolchain_file
option.However this poses a problem when we also have
requirements
statements for our Conan requirements. Conan generates the correct<dep>-config.cmake
files for each requirement, but they end up under.../build/Release/generators
. As we are using a custom toolchain, we have no way of knowing this path in beforehand, and therefore we dont know how to set theCMAKE_MODULE_PATH
.If I instead do NOT use the custom toolchain file, but rely on the generated one from Conan with CMakeToolchain, I find the requirement packages as the module path is calculated and added to the toolchain file. But then I get problems for packages in our cross-compilation SDK that we cannot find.
The solution we had in Conan 1.63 was to use the old syntax without toolchain etc, and using
cmake_find_package
. This worked, even with a custom toolchain file, because theFind<dep>.cmake
files ended up in the build folder. Ascmake_find_package
is deprecated, I want to move away from this.What is the best practice here?
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: