Combine two independent cmake projects into a single project

So I’ve two projects Azure C++ IOT SDK(used to send robot data like joint angles and positions to IotHub) and libfranka(used to interact with the robotic arm).

The purpose is to real-time data or telemetry from the robotic arm to my IoTHub.your text

My attempt at combining two projects:

  1. Added libfranka as a subdirectory to the toplevel CMAkeLists.txt file of azure-iot-sdk and used this command to compile the azure-iot-sdk
cmake -Bcmake -Duse_prov_client=ON -Dhsm_type_symm_key=ON -Drun_e2e_tests=OFF

Got this error


CMake Error at libfranka/test/CMakeLists.txt:10 (include):
  include could not find load file:

    SetupGoogleTest


-- Configuring incomplete, errors occurred!

gtest is already installed on my linux machine.

  1. Next I successfully compiled and installed libfranka(using the commands below) to use its header files in the azure-iot-sdk but it didn’t work as well.
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF ..
cmake --build .
sudo make install

I know that using

add_subdirectory(libfranka)

is not sufficient to add libfranka to the azure-iot-sdk.

Is there a simple way to combine these two projects?

The projects are probably not considering that CMAKE_SOURCE_DIR is not their own top-level directory somewhere. Generally, combining projects is not trivial and the case must be considered by project logic to support it properly. I’d suggest trying to build them using ExternalProject from a “superbuild” that ties them together, but keeps each project still building independently. Development of the repos is not trivial with such a setup (it’s mostly useful for building collections of projects into a package artifact of some kind).