# Combine two independent cmake projects into a single project

**URL:** <https://discourse.cmake.org/t/combine-two-independent-cmake-projects-into-a-single-project/10505>\
**Category:** Code\
**Created:** [March 27, 2024, 12:57pm UTC](https://discourse.cmake.org/t/combine-two-independent-cmake-projects-into-a-single-project/10505 "2024-03-27T12:57:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adwait\_Naik](https://discourse.cmake.org/user_avatar/discourse.cmake.org/adwait_naik/32/4444_2.png) [@Adwait\_Naik](https://discourse.cmake.org/u/Adwait_Naik)\
**Post date:** [March 27, 2024, 12:57pm UTC](https://discourse.cmake.org/t/combine-two-independent-cmake-projects-into-a-single-project/10505/1 "2024-03-27T12:57:14Z")

</div>

So I’ve two projects [Azure C++ IOT SDK](https://github.com/Azure/azure-iot-sdk-c)(used to send robot data like joint angles and positions to IotHub) and [libfranka](https://github.com/frankaemika/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

```auto
cmake -Bcmake -Duse_prov_client=ON -Dhsm_type_symm_key=ON -Drun_e2e_tests=OFF

```

Got this error

```auto

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.

```auto
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF ..
cmake --build .
sudo make install

```

I know that using

```auto
add_subdirectory(libfranka)

```

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

Is there a simple way to combine these two projects?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [March 4, 2025, 9:01am UTC](https://discourse.cmake.org/t/combine-two-independent-cmake-projects-into-a-single-project/10505/2 "2025-03-04T09:01:12Z")

</div>

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).
