I have a repository with multiple modules that have various inter-dependencies. These modules contain C++ and Java code. I have them separated into modules so that consuming projects can take dependencies on only what they need. Is it possible to setup an android project with cmake in this way? Here's what I would like:
x/
--CMakeLists.txt
--build.gradle
--java/
----x.java
--cpp/
----x.cpp
----x.hpp
y/
--CMakeLists.txt
--build.gradle
--java/
----y.java
--cpp/
----y.cpp
----y.hpp
in this example, suppose that: x and y are modules; each module builds a shared library (libx.so and liby.so); and x's cpp code depends on y's cpp code. So now an android app could depend on y/build.gradle and they would only get module y, or they could depend on x/build.gradle and they would get both x and y (because x depends on y).
Given that structure, how would I express x's C++-level dependency on y?
I do have a working example that gets me halfway there, but it has one super build.gradle:
build.gradle
CMakeLists.txt
x/
--CMakeLists.txt
--java/
----x.java
--cpp/
----x.cpp
----x.hpp
y/
--CMakeLists.txt
--java/
----y.java
--cpp/
----y.cpp
----y.hpp
In this example, the top-level build.gradle sets externalNativeBuild to the top-level CMakeLists.txt. The top-level CMakeLists.txt calls add_subdirectory for each module. This builds everything as expected and allows x's C++ to take a dependency on y, but it requires a consumer to pull all modules in (via the top-level build.gradle).