Hi
I'm trying to cross compile my code for android i have to pass an command line argument to cmake like mentioned below
cmake -DPlatform:STRING=android
Is there any way to provide these details during conan build command or Is there a way to mention in conanfile.py
Have a look here in the docs.
At the end of the topic you can find an example how to manipulate or add new arguments.
This implies using the CMake build helper.
If you do not use the build helper you can traditionally invoke CMake with self.run (see here).
def build(self):
cmake = CMake(self)
cmake.definitions["Platform"] = "android"
cmake.configure()
cmake.build()
cmake.install() # Build --target=install
Hi @deekshith-elear
Please take a look at the example and links provided by @Johnnyxy. That should be the most convenient way to achieve what you are trying to do.
If you issue is solved please remember to get it closed. Thanks! 馃槃
Hi @danimtb @Johnnyxy
Insted of giving them in conanfile.py can I pass them through command line arguments because it is not fixed value it will change
I do not know if you can issue arguments directly to any subsequent processes (commandline -> conanfile.py -> process).
But you can use conan's options for that.
class recipe(Conanfile)
...
options = {"Platform": None}
...
def build(self):
cmake = CMake(self)
cmake.definitions["Platform"] = self.options.Platform
cmake.configure()
cmake.build()
cmake.install() # Build --target=install
conan create ... --options Platform="android"
If you are building for android anyway, you could use the informations conan provides already.
You did not elaborate what strings are valid for the CMake argument, but it seems to be some mapping.
def build(self):
cmake = CMake(self)
if (self.settings.os == "Android"):
cmake.definitions["Platform"] = "android"
cmake.configure()
cmake.build()
cmake.install() # Build --target=install
@deekshith-elear
Insted of giving them in conanfile.py can I pass them through command line arguments because it is not fixed value it will change
You could use Conan environment variables for that too, for example:
`$ conan create . user/channel -e PLATFORM=android
However this will not be takeing into account in the package ID generation as it is created from settings and options. The right approach would be using settings or at least options for that.
We have a OS setting in settings.yml file for Andorid operating system as @Johnnyxy pointed out in the comment above. That would be the best way to do it.
I am closing this as the answer and approach is clear but feel free to comment or reopen the issue if you find any stopper. Thanks!
Most helpful comment
Have a look here in the docs.
At the end of the topic you can find an example how to manipulate or add new arguments.
This implies using the CMake build helper.
If you do not use the build helper you can traditionally invoke CMake with
self.run(see here).