What would be the best approach to bring external dependencies into cross-platform CMake project? See below the problem scope and solutions I see.
Problem Scope
Let's say we have a C/C++ project with following constraints:
- CMake is the build system;
- Has to be built for different platforms (Desktops, Android NDK / Yocto SDK, iOS);
- Has external dependencies built with CMake (ex. Google Test);
- Has external non-CMake based dependencies (ex. SQLite amalgamation, Boost);
- Not all dependencies have Git upstream (ex. SQLite is kept in fossil).
Nice to have things:
- Dependencies are automatically downloaded, so that new devs have less steps to start coding;
- Dependencies are configured in a way that IDE's (like CLion) can do autocomplete (without extra configuration steps to be done).
Possible Solutions
- Git Sub-modules (not clear what to do with non-Cmake based and not kept in Git dependencies);
- Google Repo tool (the same issues as for previous);
- CMake ExternalProject (download, unpack and potentially patch with CMakeLists.txt during generation phase and include to project with add_subdirectory). I have created a PoC[1] based on Craig Scott's[2] answer in [3].