<div dir="ltr">Thanks for the write-up Robert. Having thought about it, I don't believe we have a satisfying answer at the gradle level for this kind of organization. In the gradle model module projects are the unit of organization for configurations, C/C++ flags, etc. and that's something we're pretty much stuck with.<div>Regarding just the redundant build issue, would something like ccache help? I know people have used it with ndk-build with success, I'm not sure about CMake but I don't see why that should make a difference.</div><div><br></div><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 22, 2017 at 10:27 AM, Robert Dailey <span dir="ltr"><<a href="mailto:rcdailey.lists@gmail.com" target="_blank">rcdailey.lists@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Another reason to reduce the number of binary directories is that<br>
there are different ways of managing third party libraries. One in<br>
particular that we use is to clone a repository into the binary<br>
directory and build all third party libs in real time based on a<br>
toolchain file (Similar to the functionality provided by<br>
ExternalProject module in CMake). This is repeated from scratch only<br>
if the work hasn't already been done in the binary directory before.<br>
By having more binary dirs than needed, this work is being done an<br>
exponential amount of times which can result in a lot of wasted time<br>
waiting. There are 1 time operations that multiple targets can benefit<br>
from in a single binary tree, instead of 1 per unique target being<br>
invoked.<br>
<br>
Sorry to keep responding: I'm just thinking of things as I go and<br>
bringing them up, to shed light on some of the reasoning behind my<br>
suggestions.<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Aug 22, 2017 at 9:26 AM, Robert Dailey <<a href="mailto:rcdailey.lists@gmail.com">rcdailey.lists@gmail.com</a>> wrote:<br>
> Sorry I forgot to answer your last set of questions:<br>
><br>
> CommonLib is indeed 2 things:<br>
><br>
> * A common (static or shared) library for native code (most of our<br>
> CMake targets specify CommonLib as a link dependency)<br>
> * A common library for Java code (we do specify this as a dependency<br>
> for most java targets in Gradle, specifically those under<br>
> Applications/)<br>
><br>
> On Mon, Aug 21, 2017 at 6:20 PM, Raymond Chiu <<a href="mailto:chiur@google.com">chiur@google.com</a>> wrote:<br>
>> Hi Robert,<br>
>><br>
>> I work with Jom on the Android Studio team, and I would like to clarify a<br>
>> few things to better understand your situation.<br>
>> You mentioned the project is intend to be cross platform.  Normally, in such<br>
>> situation, we expect there to be a single CMake root project to be imported<br>
>> into one of the Android library/application.  However, in your case, there<br>
>> are subprojects with Java code.<br>
>><br>
>> Are the CMake code in App1/2/3 intended to be cross platform too?  Or are<br>
>> they Android specific code?  If they are meant to be cross platform, how<br>
>> does the Java code works on other platforms?  Or perhaps you added Java<br>
>> binding in those subprojects just for Android?<br>
>><br>
>> The build.gradle in CommonLib, what kind of Gradle project is that?  From<br>
>> your description, it doesn't look like an Android library project.  Or am I<br>
>> mistaken and it also applies the android library plugin?<br>
>><br>
>> Raymond<br>
>><br>
>> On Mon, Aug 21, 2017 at 3:34 PM, Jom O'Fisher <<a href="mailto:jomofisher@gmail.com">jomofisher@gmail.com</a>> wrote:<br>
>>><br>
>>> + a colleague<br>
>>><br>
>>> On Mon, Aug 21, 2017 at 3:11 PM, Jom O'Fisher <<a href="mailto:jomofisher@gmail.com">jomofisher@gmail.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>> You can find that number like this:<br>
>>>> - x = number of externalNativeBuild.cmake.path in your build.gradle files<br>
>>>> - y = number of gradle configurations (like debug and release)<br>
>>>> - z = number of ABIs that you build<br>
>>>><br>
>>>> The result is x * y * z. To be more accurate, you should consider y and z<br>
>>>> to be functions of each build.gradle file since these can vary.<br>
>>>><br>
>>>> There is a second set of folders that hold the stripped versions of the<br>
>>>> .so files that is purely managed by the android gradle plugin, so you might<br>
>>>> consider the answer to be 2 * x * y * z.<br>
>>>><br>
>>>> Hope this helps.<br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> On Mon, Aug 21, 2017 at 2:41 PM, Robert Dailey <<a href="mailto:rcdailey.lists@gmail.com">rcdailey.lists@gmail.com</a>><br>
>>>> wrote:<br>
>>>>><br>
>>>>> This definitely a bit better, but still requires the boilerplate in<br>
>>>>> each leaf gradle file. But I can't seriously complain too much. I<br>
>>>>> think I'm more concerned with the implications this has underneath.<br>
>>>>> First, let me ask just to make sure I'm not misunderstanding: Does<br>
>>>>> each `externalNativeBuild` entry essentially mean 1 CMAKE_BINARY_DIR?<br>
>>>>> How many binary dirs do you manage internally and what determines when<br>
>>>>> they get created?<br>
>>>>><br>
>>>>> On Mon, Aug 21, 2017 at 2:35 PM, Jom O'Fisher <<a href="mailto:jomofisher@gmail.com">jomofisher@gmail.com</a>><br>
>>>>> wrote:<br>
>>>>> > Would it work for your scenario to provide properties in the root<br>
>>>>> > build.gradle:<br>
>>>>> ><br>
>>>>> > ext {<br>
>>>>> >     cmakePath = file "CMakeLists.txt"<br>
>>>>> > }<br>
>>>>> ><br>
>>>>> > And then consume them in the leaf app/build.gradle like this?<br>
>>>>> ><br>
>>>>> > externalNativeBuild {<br>
>>>>> >     cmake {<br>
>>>>> >         path cmakePath<br>
>>>>> >     }<br>
>>>>> > }<br>
>>>>> ><br>
>>>>> > It doesn't fully hide the details but it does centralize the<br>
>>>>> > information.<br>
>>>>> ><br>
>>>>> ><br>
>>>>> > On Mon, Aug 21, 2017 at 11:20 AM, Robert Dailey<br>
>>>>> > <<a href="mailto:rcdailey.lists@gmail.com">rcdailey.lists@gmail.com</a>><br>
>>>>> > wrote:<br>
>>>>> >><br>
>>>>> >> I wouldn't want to do that, it's too convoluted. I have other<br>
>>>>> >> platforms that use these CMake scripts as well. For example, I run on<br>
>>>>> >> Windows and Linux platforms as well to build the native code. Normal<br>
>>>>> >> CMake behavior is designed to work at a root then go downwards to<br>
>>>>> >> find<br>
>>>>> >> targets. However it seems Gradle wants to start at a subdirectory and<br>
>>>>> >> work its way up to the root, which is opposite of CMake's intended<br>
>>>>> >> behavior IMHO. Not only that but I want to avoid special-casing<br>
>>>>> >> behavior in CMake just for Android's use.<br>
>>>>> >><br>
>>>>> >> At the moment it feels like (again referring back to my previous<br>
>>>>> >> example structure) that both App2 and App3 each run CMake in<br>
>>>>> >> independent binary directories instead of sharing 1 binary directory<br>
>>>>> >> and building 2 targets inside of it. I prefer this behavior instead,<br>
>>>>> >> especially since it allows CMake to operate as it was intended. I<br>
>>>>> >> think it's a common case that projects will define multiple targets<br>
>>>>> >> starting from a single root, and expect multiple APKs or java<br>
>>>>> >> dependencies to be built within it.<br>
>>>>> >><br>
>>>>> >> If I'm misunderstanding or making false assumptions please let me<br>
>>>>> >> know.<br>
>>>>> >><br>
>>>>> >><br>
>>>>> >><br>
>>>>> >> On Mon, Aug 21, 2017 at 12:00 PM, Jom O'Fisher <<a href="mailto:jomofisher@gmail.com">jomofisher@gmail.com</a>><br>
>>>>> >> wrote:<br>
>>>>> >> > Would it work for your situation for the leaf CMakeLists.txt to<br>
>>>>> >> > include<br>
>>>>> >> > the<br>
>>>>> >> > root CMakeLists.txt? Then have the leaf-specific logic in the leaf<br>
>>>>> >> > CMakeLists.txt?<br>
>>>>> >> ><br>
>>>>> >> ><br>
>>>>> >> ><br>
>>>>> >> > On Mon, Aug 21, 2017 at 9:33 AM, Robert Dailey<br>
>>>>> >> > <<a href="mailto:rcdailey.lists@gmail.com">rcdailey.lists@gmail.com</a>><br>
>>>>> >> > wrote:<br>
>>>>> >> >><br>
>>>>> >> >> Basically, yes. We have this sort of structure:<br>
>>>>> >> >><br>
>>>>> >> >> <Root of git clone>/<br>
>>>>> >> >>     Applications/<br>
>>>>> >> >>         App1/<br>
>>>>> >> >>             build.gradle<br>
>>>>> >> >>             CMakeLists.txt<br>
>>>>> >> >>         App2/<br>
>>>>> >> >>             build.gradle<br>
>>>>> >> >>             CMakeLists.txt<br>
>>>>> >> >>         App3/<br>
>>>>> >> >>             build.gradle<br>
>>>>> >> >>             CMakeLists.txt<br>
>>>>> >> >>     CommonLib/<br>
>>>>> >> >>         build.gradle<br>
>>>>> >> >>         CMakeLists.txt<br>
>>>>> >> >>     CMakeLists.txt<br>
>>>>> >> >><br>
>>>>> >> >> The libs are defined as follows:<br>
>>>>> >> >><br>
>>>>> >> >> * CommonLib is a static library (java code builds into a library)<br>
>>>>> >> >>     * No dependencies of its own<br>
>>>>> >> >> * App1 is a shared library (java code builds into a library)<br>
>>>>> >> >>     * Dependencies (both java & native): CommonLib<br>
>>>>> >> >> * App2 is a shared library (java code builds into an APK)<br>
>>>>> >> >>    * Dependencies (both java & native): App1, CommonLib<br>
>>>>> >> >> * App3 is a shared library (java code builds into an APK)<br>
>>>>> >> >>    * Dependencies (both java & native): CommonLib<br>
>>>>> >> >><br>
>>>>> >> >> In all cases, CMake must be invoked starting at the root<br>
>>>>> >> >> CMakeLists.txt 1 time. Each target can be built from the same<br>
>>>>> >> >> binary<br>
>>>>> >> >> directory after that. Previously with ANT, I was building all<br>
>>>>> >> >> native<br>
>>>>> >> >> targets first, then moved libs to appropriate directories so that<br>
>>>>> >> >> the<br>
>>>>> >> >> 'ant' command would package the libs.<br>
>>>>> >> >><br>
>>>>> >> >> For gradle, I wanted to avoid redundantly specifying the root<br>
>>>>> >> >> directory in each leaf-level project directory. Using the example<br>
>>>>> >> >> above, the leaf-level directories in this case would be App1,<br>
>>>>> >> >> App2,<br>
>>>>> >> >> App3, and CommonLib. However I think we only specify the native<br>
>>>>> >> >> CMake<br>
>>>>> >> >> stuff for the java targets that actually output an APK (that would<br>
>>>>> >> >> be<br>
>>>>> >> >> App2 and App3 only).<br>
>>>>> >> >><br>
>>>>> >> >> The ultimate goal is to specify stuff that doesn't change per<br>
>>>>> >> >> independent "module" of ours at the top level so it is transitive<br>
>>>>> >> >> /<br>
>>>>> >> >> inherited. Then only specify the differences (e.g. the native<br>
>>>>> >> >> CMake<br>
>>>>> >> >> target to build) in the leaf build gradle files. However you<br>
>>>>> >> >> indicated<br>
>>>>> >> >> this isn't possible.<br>
>>>>> >> >><br>
>>>>> >> >><br>
>>>>> >> >><br>
>>>>> >> >> On Mon, Aug 21, 2017 at 11:11 AM, Jom O'Fisher<br>
>>>>> >> >> <<a href="mailto:jomofisher@gmail.com">jomofisher@gmail.com</a>><br>
>>>>> >> >> wrote:<br>
>>>>> >> >> > What you're doing already sounds correct. You can't directly<br>
>>>>> >> >> > specify<br>
>>>>> >> >> > CMakeLists.txt from the top-level build.gradle. Recommendation<br>
>>>>> >> >> > is<br>
>>>>> >> >> > that<br>
>>>>> >> >> > it<br>
>>>>> >> >> > should be specified from the build.gradle of the module of the<br>
>>>>> >> >> > APK.<br>
>>>>> >> >> > Is<br>
>>>>> >> >> > the<br>
>>>>> >> >> > issue that you have multiple APK modules that all reference the<br>
>>>>> >> >> > same<br>
>>>>> >> >> > CMake<br>
>>>>> >> >> > libraries?<br>
>>>>> >> >> ><br>
>>>>> >> >> > On Mon, Aug 21, 2017 at 9:00 AM, Robert Dailey<br>
>>>>> >> >> > <<a href="mailto:rcdailey.lists@gmail.com">rcdailey.lists@gmail.com</a>><br>
>>>>> >> >> > wrote:<br>
>>>>> >> >> >><br>
>>>>> >> >> >> Thanks this is very helpful. The other question I have is: Is<br>
>>>>> >> >> >> there<br>
>>>>> >> >> >> a<br>
>>>>> >> >> >> place to centrally specify the root CMakeLists.txt? Basically,<br>
>>>>> >> >> >> I<br>
>>>>> >> >> >> want<br>
>>>>> >> >> >> to specify the CMake root in 1 place, and have targets (defined<br>
>>>>> >> >> >> further down in subdirectories) that require APK packaging to<br>
>>>>> >> >> >> specify<br>
>>>>> >> >> >> only the native target name that should be built & packaged.<br>
>>>>> >> >> >><br>
>>>>> >> >> >> At the moment we specify the root CMakeLists.txt by walking up<br>
>>>>> >> >> >> the<br>
>>>>> >> >> >> tree, paths like "../../../../CMakeLists.txt". I think this<br>
>>>>> >> >> >> should<br>
>>>>> >> >> >> be<br>
>>>>> >> >> >> put at the top-level build gradle file if possible. Is this<br>
>>>>> >> >> >> doable<br>
>>>>> >> >> >> at<br>
>>>>> >> >> >> the moment? What is the recommended setup?<br>
>>>>> >> >> >><br>
>>>>> >> >> >> On Mon, Aug 21, 2017 at 9:37 AM, Jom O'Fisher<br>
>>>>> >> >> >> <<a href="mailto:jomofisher@gmail.com">jomofisher@gmail.com</a>><br>
>>>>> >> >> >> wrote:<br>
>>>>> >> >> >> > Gradle does introspection on the CMake build to find .so<br>
>>>>> >> >> >> > targets<br>
>>>>> >> >> >> > and<br>
>>>>> >> >> >> > those<br>
>>>>> >> >> >> > get packaged.<br>
>>>>> >> >> >> > There is also a special case for stl/runtime .so files from<br>
>>>>> >> >> >> > the<br>
>>>>> >> >> >> > NDK.<br>
>>>>> >> >> >> > Any additional .so files need to specified in build.gradle<br>
>>>>> >> >> >> > using<br>
>>>>> >> >> >> > jniDirs<br>
>>>>> >> >> >> ><br>
>>>>> >> >> >> > On Mon, Aug 21, 2017 at 7:30 AM, Robert Dailey<br>
>>>>> >> >> >> > <<a href="mailto:rcdailey.lists@gmail.com">rcdailey.lists@gmail.com</a>><br>
>>>>> >> >> >> > wrote:<br>
>>>>> >> >> >> >><br>
>>>>> >> >> >> >> How exactly does Gradle package *.so files in an APK? I know<br>
>>>>> >> >> >> >> that<br>
>>>>> >> >> >> >> ANT<br>
>>>>> >> >> >> >> used to do this for any libs under "libs/<ABI>". Does Gradle<br>
>>>>> >> >> >> >> do<br>
>>>>> >> >> >> >> some<br>
>>>>> >> >> >> >> introspection into CMake targets to see if outputs are *.so,<br>
>>>>> >> >> >> >> and<br>
>>>>> >> >> >> >> copy<br>
>>>>> >> >> >> >> those to some location if needed? What about libraries like<br>
>>>>> >> >> >> >> libgnustl_shared.so that come with the NDK? I'd like to know<br>
>>>>> >> >> >> >> if<br>
>>>>> >> >> >> >> any<br>
>>>>> >> >> >> >> manual copy steps are needed in CMake to put outputs in<br>
>>>>> >> >> >> >> proper<br>
>>>>> >> >> >> >> locations for the APK build step. I had to do this when<br>
>>>>> >> >> >> >> using<br>
>>>>> >> >> >> >> ANT.<br>
>>>>> >> >> >> >><br>
>>>>> >> >> >> >> On Mon, Aug 7, 2017 at 6:16 PM, Jom O'Fisher<br>
>>>>> >> >> >> >> <<a href="mailto:jomofisher@gmail.com">jomofisher@gmail.com</a>><br>
>>>>> >> >> >> >> wrote:<br>
>>>>> >> >> >> >> > 1) There is a folder created for each ABI under the<br>
>>>>> >> >> >> >> > project<br>
>>>>> >> >> >> >> > module<br>
>>>>> >> >> >> >> > folder<br>
>>>>> >> >> >> >> > (so unique per module per ABI)<br>
>>>>> >> >> >> >> > 2) Gradle doesn't specify language level though you can<br>
>>>>> >> >> >> >> > choose<br>
>>>>> >> >> >> >> > to<br>
>>>>> >> >> >> >> > specify it<br>
>>>>> >> >> >> >> > yourself from the build.gradle. This doc does a pretty<br>
>>>>> >> >> >> >> > good job<br>
>>>>> >> >> >> >> > of<br>
>>>>> >> >> >> >> > explaining which variables are set by Gradle:<br>
>>>>> >> >> >> >> ><br>
>>>>> >> >> >> >> > <a href="https://developer.android.com/ndk/guides/cmake.html#variables" rel="noreferrer" target="_blank">https://developer.android.com/<wbr>ndk/guides/cmake.html#<wbr>variables</a>.<br>
>>>>> >> >> >> >> > Philosophically, we try to set as little as we can get<br>
>>>>> >> >> >> >> > away<br>
>>>>> >> >> >> >> > with.<br>
>>>>> >> >> >> >> > In<br>
>>>>> >> >> >> >> > particular, the section titled "Understanding the CMake<br>
>>>>> >> >> >> >> > build<br>
>>>>> >> >> >> >> > command"<br>
>>>>> >> >> >> >> > lays<br>
>>>>> >> >> >> >> > out exactly what we set. You can also see the folders we<br>
>>>>> >> >> >> >> > specify<br>
>>>>> >> >> >> >> > (one<br>
>>>>> >> >> >> >> > per<br>
>>>>> >> >> >> >> > module per ABI)<br>
>>>>> >> >> >> >> > 3) Not sure I understand this.<br>
>>>>> >> >> >> >> ><br>
>>>>> >> >> >> >> > The other document worth taking a look at (if you haven't<br>
>>>>> >> >> >> >> > already)<br>
>>>>> >> >> >> >> > is:<br>
>>>>> >> >> >> >> ><br>
>>>>> >> >> >> >> ><br>
>>>>> >> >> >> >> > <a href="https://developer.android.com/studio/projects/add-native-code.html" rel="noreferrer" target="_blank">https://developer.android.com/<wbr>studio/projects/add-native-<wbr>code.html</a><br>
>>>>> >> >> >> >> ><br>
>>>>> >> >> >> >> ><br>
>>>>> >> >> >> >> > On Mon, Aug 7, 2017 at 3:35 PM, Robert Dailey<br>
>>>>> >> >> >> >> > <<a href="mailto:rcdailey.lists@gmail.com">rcdailey.lists@gmail.com</a>><br>
>>>>> >> >> >> >> > wrote:<br>
>>>>> >> >> >> >> >><br>
>>>>> >> >> >> >> >> Thanks Jom<br>
>>>>> >> >> >> >> >><br>
>>>>> >> >> >> >> >> Honestly, I prefer option 1 to work simply because that's<br>
>>>>> >> >> >> >> >> how<br>
>>>>> >> >> >> >> >> Google's<br>
>>>>> >> >> >> >> >> officially supporting CMake. But it also has debugging<br>
>>>>> >> >> >> >> >> which<br>
>>>>> >> >> >> >> >> is<br>
>>>>> >> >> >> >> >> the<br>
>>>>> >> >> >> >> >> #1<br>
>>>>> >> >> >> >> >> reason for me.<br>
>>>>> >> >> >> >> >><br>
>>>>> >> >> >> >> >> However, I'd like to understand a lot more about how the<br>
>>>>> >> >> >> >> >> integration<br>
>>>>> >> >> >> >> >> really happens. For example, I have these questions:<br>
>>>>> >> >> >> >> >><br>
>>>>> >> >> >> >> >> 1) How, internally, are CMake build directories managed?<br>
>>>>> >> >> >> >> >> Do<br>
>>>>> >> >> >> >> >> you<br>
>>>>> >> >> >> >> >> generate 1 per unique android project? What about for<br>
>>>>> >> >> >> >> >> each<br>
>>>>> >> >> >> >> >> specific<br>
>>>>> >> >> >> >> >> platform (x86, armeabi-v7a, etc)?<br>
>>>>> >> >> >> >> >> 2) Last time I looked into CMake integration, things<br>
>>>>> >> >> >> >> >> defined<br>
>>>>> >> >> >> >> >> inside<br>
>>>>> >> >> >> >> >> the CMake scripts were ignored because they are specified<br>
>>>>> >> >> >> >> >> at<br>
>>>>> >> >> >> >> >> the<br>
>>>>> >> >> >> >> >> command line. Namely, all of those settings that are<br>
>>>>> >> >> >> >> >> driven by<br>
>>>>> >> >> >> >> >> the<br>
>>>>> >> >> >> >> >> Gradle configuration (CXX language level was one in<br>
>>>>> >> >> >> >> >> particular<br>
>>>>> >> >> >> >> >> I<br>
>>>>> >> >> >> >> >> think; I specify C++14 support via CMake, but I recall<br>
>>>>> >> >> >> >> >> this<br>
>>>>> >> >> >> >> >> being<br>
>>>>> >> >> >> >> >> overridden from outside)?<br>
>>>>> >> >> >> >> >> 3) How redundant is it to configure individual libraries<br>
>>>>> >> >> >> >> >> via<br>
>>>>> >> >> >> >> >> the<br>
>>>>> >> >> >> >> >> gradle scripts? In my previous attempts, I wanted to<br>
>>>>> >> >> >> >> >> define<br>
>>>>> >> >> >> >> >> common<br>
>>>>> >> >> >> >> >> stuff for CMake / native code at the root gradle or<br>
>>>>> >> >> >> >> >> settings<br>
>>>>> >> >> >> >> >> file,<br>
>>>>> >> >> >> >> >> and<br>
>>>>> >> >> >> >> >> only define the differences in the actual gradle build<br>
>>>>> >> >> >> >> >> files<br>
>>>>> >> >> >> >> >> for<br>
>>>>> >> >> >> >> >> each<br>
>>>>> >> >> >> >> >> corresponding Java target (like, defining the name of the<br>
>>>>> >> >> >> >> >> native<br>
>>>>> >> >> >> >> >> (shared library) target in Gradle, but the command line<br>
>>>>> >> >> >> >> >> invocation,<br>
>>>>> >> >> >> >> >> -D<br>
>>>>> >> >> >> >> >> CMake settings, etc would all be common and defined at<br>
>>>>> >> >> >> >> >> the<br>
>>>>> >> >> >> >> >> root).<br>
>>>>> >> >> >> >> >><br>
>>>>> >> >> >> >> >> The TLDR is, the closer we can stay to CMake's way of<br>
>>>>> >> >> >> >> >> doing<br>
>>>>> >> >> >> >> >> things<br>
>>>>> >> >> >> >> >> and<br>
>>>>> >> >> >> >> >> keep CMake-related settings self-contained to the CMake<br>
>>>>> >> >> >> >> >> scripts<br>
>>>>> >> >> >> >> >> themselves, the better. This also makes cross-platform<br>
>>>>> >> >> >> >> >> easier<br>
>>>>> >> >> >> >> >> (we<br>
>>>>> >> >> >> >> >> build the native code in Windows, for example, so having<br>
>>>>> >> >> >> >> >> settings<br>
>>>>> >> >> >> >> >> specified in the gradle files do not carry over to other<br>
>>>>> >> >> >> >> >> platforms.<br>
>>>>> >> >> >> >> >> Namely, settings that are not platform specific like the<br>
>>>>> >> >> >> >> >> C++<br>
>>>>> >> >> >> >> >> language<br>
>>>>> >> >> >> >> >> level).<br>
>>>>> >> >> >> >> >><br>
>>>>> >> >> >> >> >> If there's a detailed document / wiki I can read on the<br>
>>>>> >> >> >> >> >> intrinsics<br>
>>>>> >> >> >> >> >> of<br>
>>>>> >> >> >> >> >> CMake integration in Gradle / Android Studio, I'd love to<br>
>>>>> >> >> >> >> >> read<br>
>>>>> >> >> >> >> >> it.<br>
>>>>> >> >> >> >> >> Otherwise, I hope you won't mind if I pick your brain as<br>
>>>>> >> >> >> >> >> questions<br>
>>>>> >> >> >> >> >> come up. I think I'm going to try option 1 for now and<br>
>>>>> >> >> >> >> >> see how<br>
>>>>> >> >> >> >> >> it<br>
>>>>> >> >> >> >> >> goes. It's just black box for me because unlike option 2,<br>
>>>>> >> >> >> >> >> I<br>
>>>>> >> >> >> >> >> have<br>
>>>>> >> >> >> >> >> very<br>
>>>>> >> >> >> >> >> little control over what happens after building the<br>
>>>>> >> >> >> >> >> shared<br>
>>>>> >> >> >> >> >> libraries,<br>
>>>>> >> >> >> >> >> and to make up for that I need to really get a deep<br>
>>>>> >> >> >> >> >> understanding<br>
>>>>> >> >> >> >> >> of<br>
>>>>> >> >> >> >> >> how it works so I can make sure I code my CMake scripts<br>
>>>>> >> >> >> >> >> properly<br>
>>>>> >> >> >> >> >> for<br>
>>>>> >> >> >> >> >> not only Android, but my other platforms as well<br>
>>>>> >> >> >> >> >> (non-Android<br>
>>>>> >> >> >> >> >> platforms).<br>
>>>>> >> >> >> >> >><br>
>>>>> >> >> >> >> >> Thanks again.<br>
>>>>> >> >> >> >> >><br>
>>>>> >> >> >> >> >> On Mon, Aug 7, 2017 at 5:12 PM, Jom O'Fisher<br>
>>>>> >> >> >> >> >> <<a href="mailto:jomofisher@gmail.com">jomofisher@gmail.com</a>><br>
>>>>> >> >> >> >> >> wrote:<br>
>>>>> >> >> >> >> >> > Either option can work fine. Disclosure: I work on<br>
>>>>> >> >> >> >> >> > Android<br>
>>>>> >> >> >> >> >> > Studio<br>
>>>>> >> >> >> >> >> > and<br>
>>>>> >> >> >> >> >> > was<br>
>>>>> >> >> >> >> >> > the one that added CMake support.<br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> > Option (1) is the way it's designed to work and we're<br>
>>>>> >> >> >> >> >> > working<br>
>>>>> >> >> >> >> >> > toward<br>
>>>>> >> >> >> >> >> > getting<br>
>>>>> >> >> >> >> >> > rid of the need for the CMake fork. I can't really say<br>
>>>>> >> >> >> >> >> > when<br>
>>>>> >> >> >> >> >> > that<br>
>>>>> >> >> >> >> >> > will<br>
>>>>> >> >> >> >> >> > happen<br>
>>>>> >> >> >> >> >> > but if you can get away with an older CMake for now<br>
>>>>> >> >> >> >> >> > then I'd<br>
>>>>> >> >> >> >> >> > go<br>
>>>>> >> >> >> >> >> > this<br>
>>>>> >> >> >> >> >> > way.<br>
>>>>> >> >> >> >> >> > As you mentioned, option (1) will allow you to view<br>
>>>>> >> >> >> >> >> > your<br>
>>>>> >> >> >> >> >> > source<br>
>>>>> >> >> >> >> >> > file<br>
>>>>> >> >> >> >> >> > structure in Android Studio, edit files, and debug<br>
>>>>> >> >> >> >> >> > using the<br>
>>>>> >> >> >> >> >> > built-in<br>
>>>>> >> >> >> >> >> > debugging support.<br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> > To get option (2) to work, you can use jniDirs setting<br>
>>>>> >> >> >> >> >> > to<br>
>>>>> >> >> >> >> >> > tell<br>
>>>>> >> >> >> >> >> > Android<br>
>>>>> >> >> >> >> >> > Gradle where to pick up your built .so files (see<br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> > <a href="https://stackoverflow.com/questions/21255125/how-can-i-add-so-files-to-an-android-library-project-using-gradle-0-7" rel="noreferrer" target="_blank">https://stackoverflow.com/<wbr>questions/21255125/how-can-i-<wbr>add-so-files-to-an-android-<wbr>library-project-using-gradle-<wbr>0-7</a>).<br>
>>>>> >> >> >> >> >> > I'm not aware of any projects that use this approach<br>
>>>>> >> >> >> >> >> > but it<br>
>>>>> >> >> >> >> >> > should<br>
>>>>> >> >> >> >> >> > work<br>
>>>>> >> >> >> >> >> > in<br>
>>>>> >> >> >> >> >> > principal.<br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> > I hope this helps,<br>
>>>>> >> >> >> >> >> > Jomo<br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> > On Mon, Aug 7, 2017 at 11:09 AM, Robert Dailey<br>
>>>>> >> >> >> >> >> > <<a href="mailto:rcdailey.lists@gmail.com">rcdailey.lists@gmail.com</a>><br>
>>>>> >> >> >> >> >> > wrote:<br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> Right now I have custom targets set to execute the<br>
>>>>> >> >> >> >> >> >> "ant<br>
>>>>> >> >> >> >> >> >> release"<br>
>>>>> >> >> >> >> >> >> command after my native targets are built. Part of<br>
>>>>> >> >> >> >> >> >> that<br>
>>>>> >> >> >> >> >> >> command<br>
>>>>> >> >> >> >> >> >> involves copying *.so files to the libs/armeabi-v7a<br>
>>>>> >> >> >> >> >> >> directory<br>
>>>>> >> >> >> >> >> >> so<br>
>>>>> >> >> >> >> >> >> they<br>
>>>>> >> >> >> >> >> >> get packaged in an APK.<br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> When switching to gradle, I have two options:<br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> 1. Gradle drives CMake: This means using Android<br>
>>>>> >> >> >> >> >> >> Studio and<br>
>>>>> >> >> >> >> >> >> being<br>
>>>>> >> >> >> >> >> >> locked down to Google's fork of CMake which is a few<br>
>>>>> >> >> >> >> >> >> major<br>
>>>>> >> >> >> >> >> >> releases<br>
>>>>> >> >> >> >> >> >> behind. I see that as a negative.<br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> 2. CMake drives Gradle: This would be the same or<br>
>>>>> >> >> >> >> >> >> similar<br>
>>>>> >> >> >> >> >> >> to<br>
>>>>> >> >> >> >> >> >> what<br>
>>>>> >> >> >> >> >> >> I'm<br>
>>>>> >> >> >> >> >> >> already doing: The custom targets I have would execute<br>
>>>>> >> >> >> >> >> >> gradle<br>
>>>>> >> >> >> >> >> >> as<br>
>>>>> >> >> >> >> >> >> a<br>
>>>>> >> >> >> >> >> >> separate build step, instead of running ant commands.<br>
>>>>> >> >> >> >> >> >> I'm<br>
>>>>> >> >> >> >> >> >> not<br>
>>>>> >> >> >> >> >> >> too<br>
>>>>> >> >> >> >> >> >> familiar with Gradle, so I'm not sure how you tell it<br>
>>>>> >> >> >> >> >> >> where<br>
>>>>> >> >> >> >> >> >> your<br>
>>>>> >> >> >> >> >> >> shared libraries are for the APK packaging steps.<br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> Which does everyone recommend? Is anyone using one of<br>
>>>>> >> >> >> >> >> >> these<br>
>>>>> >> >> >> >> >> >> setups<br>
>>>>> >> >> >> >> >> >> successfully? The downside to option 2 is probably no<br>
>>>>> >> >> >> >> >> >> on-device<br>
>>>>> >> >> >> >> >> >> native<br>
>>>>> >> >> >> >> >> >> debugging since Android Studio probably can't handle<br>
>>>>> >> >> >> >> >> >> gradle<br>
>>>>> >> >> >> >> >> >> projects<br>
>>>>> >> >> >> >> >> >> without any external CMake builds set up.<br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> Would like some general direction & advice before I<br>
>>>>> >> >> >> >> >> >> move<br>
>>>>> >> >> >> >> >> >> away<br>
>>>>> >> >> >> >> >> >> from<br>
>>>>> >> >> >> >> >> >> ANT. Thanks in advance.<br>
>>>>> >> >> >> >> >> >> --<br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> Please keep messages on-topic and check the CMake FAQ<br>
>>>>> >> >> >> >> >> >> at:<br>
>>>>> >> >> >> >> >> >> <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/<wbr>CMake_FAQ</a><br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> Kitware offers various services to support the CMake<br>
>>>>> >> >> >> >> >> >> community.<br>
>>>>> >> >> >> >> >> >> For<br>
>>>>> >> >> >> >> >> >> more<br>
>>>>> >> >> >> >> >> >> information on each offering, please visit:<br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> CMake Support:<br>
>>>>> >> >> >> >> >> >> <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>support.html</a><br>
>>>>> >> >> >> >> >> >> CMake Consulting:<br>
>>>>> >> >> >> >> >> >> <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>consulting.html</a><br>
>>>>> >> >> >> >> >> >> CMake Training Courses:<br>
>>>>> >> >> >> >> >> >> <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>training.html</a><br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> Visit other Kitware open-source projects at<br>
>>>>> >> >> >> >> >> >> <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
>>>>> >> >> >> >> >> >><br>
>>>>> >> >> >> >> >> >> Follow this link to subscribe/unsubscribe:<br>
>>>>> >> >> >> >> >> >> <a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/cmake</a><br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> >> ><br>
>>>>> >> >> >> >> ><br>
>>>>> >> >> >> >> ><br>
>>>>> >> >> >> ><br>
>>>>> >> >> >> ><br>
>>>>> >> >> ><br>
>>>>> >> >> ><br>
>>>>> >> ><br>
>>>>> >> ><br>
>>>>> ><br>
>>>>> ><br>
>>>><br>
>>>><br>
>>><br>
>><br>
</div></div></blockquote></div><br></div>