-
Notifications
You must be signed in to change notification settings - Fork 950
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] How do you set the NDK path for Android builds in CMakeToolchain? #9025
Comments
Hi @ssrobins Configuration can be added to profiles, you can try:
Conan 1.37, to be released today, contains CMakeToolchain changes to allow both providing your toolchain file (replacing |
Thanks @memsharded, putting that code in
I tried adding
The For Conan 1.x, this is all I had to add to my
I was just able to pass CMake params exactly how it would work without Conan. Yes it's more code than if it was taken care of for me, but I appreciated the transparency and simplicity. It let me use the For the Android toolchain as well as any custom toolchain, I would love for this to be done with a setting in the conanfile.py, like it was before. The |
The main reason is the developer flows, which at the moment are broken. The developer experience that needs to develop without Conan, just with the IDE or command line. Everything that the
I am glad that you find it useful, but that is not the majority of the users feedback, that push towards a more CMake idiomatic integration (find_package and toolchain files, basically). Dont worry too much, I think that you are experiencing the first iterations of the new integrations so some releases might be necessary to stabilize and provide the same (or hopefully better) integration and transparency. In your case, I am moving this to a feature request, because from what I see, there are some items which are good candidates to be implemented in the
And Regarding the generator, if you are using profile files, you might also simplify your recipe by defining also the generator in configuration with |
@memsharded Thankfully, Kitware helped solve this in CMake itself with the new CMake Presets feature. Here's an example file. Using presets, the CMake command line is I'm not saying to force the use of presets instead of toolchains. Presets came into CMake in 3.19 and I'm sure some will desire older CMake compatibility than that. I'm just saying don't force us to use either one. Seems way more flexible and easier on you, while still allowing for reasonable developer workflows to just let me pass in anything to If there's anything I can do to help with documentation or convincing those who disagree, let me know. I have a lot of open source examples floating around. I'd also be happy to contribute code to other people's projects to help address workflow issues with Conan 1.x. But please, don't take away the flexibility! |
As for I'd like to avoid profiles if I can, it's just one more thing I have to handle getting installed in the developer and automation environments. I want someone to be able to clone my package repo, install Conan, and run a single command to build/package (and do fancier stuff with the various |
Not really. CMake commands might not be the most ergonomic, but people know them. The problem that Conan introduced is that if you want to build your binary, locally, as a developer, and get the same binary as Conan would build in the cache, you would need to type something like:
This is not acceptable, and it makes a lot of sense that users have been requesting a more idiomatic way to achieve this. This will be replaced with the new toolchain by:
At some points we will probably integrate better CMakePresets, but yes, at this moment we are aiming for CMake 3.15 as the supported base version. Yes, the CMAKE_MAKE_PROGRAM might be a bug or something, we should check it and fix it. |
Ah, I was not considering the custom paths and settings specific to Conan to get a CMake build result 100% like the Conan build. I agree, that's not acceptable. Thanks for listening and thanks for considering those two CMakeToolchain additions. Feel free to close this, if it's not being used to track that other potential work. I'll keep working with Conan 2.0 as I see more improvements come out. |
Finally got Android builds working with Conan 2.0. Got past this error:
I just had to set |
Ok, great, happy to hear that you got it working! Lets keep this open, to make sure the above cases are correctly covered, if everything is good, we will close it in 1.38. |
#9075 closed this issue, will be in 1.38 |
I still have to use Here's my generate function:
macOS configuration:
iOS configuration:
Adding this to the generate function still fixes it:
So I'm not blocked, but it sounded like you were interested in implementing this capability. Let me know if I should log a separate item. |
Hi @ssrobins Yes, please, as the title of this issue is NDK for Android, I think it is better to file a new issue dedicated for it. From your code it seems that it would be: if self.settings.os == "iOS" or self.settings.os == "Macos":
# assign CMAKE_OSX_DEPLOYMENT_TARGET Do you know if it also applies to watchOS or tvOS? |
Just created a new one from your comment in #9282, please track it and provide feedback there. Thanks! |
I'm trying to figure out how to build for Android using the Conan 2.0
CMakeToolchain
. I get this error:ConanException: CMakeToolchain needs tools.android:ndk_path configuration defined
The docs mention
tools.android:ndk_path
, but not how to set it. There are a few clues in the source code, but all the things I've tried inconanfile.py
andconan.conf
haven't worked. This was very easy with thecmake
generator, I just did this:cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = os.getenv("ANDROID_NDK_ROOT") + "/build/cmake/android.toolchain.cmake"
...but it doesn't work anymore.
Currently, I share this Python script with my Conan 1.x packages to define build settings for desktop and mobile platform builds:
https://github.com/ssrobins/conan-cmake_utils/blob/217df94/cmake_utils.py.
In addition to being stuck on this, I'm a bit concerned that Conan 2.0 will make it not possible or at least harder to use custom toolchains, which is critical for close-sourced platforms that don't have any built-in CMake support.
The text was updated successfully, but these errors were encountered: