# Building out-of-tree modules with dependencies

**URL:** <https://discuss.px4.io/t/building-out-of-tree-modules-with-dependencies/20444>\
**Category:** Uncategorized\
**Created:** [January 9, 2021, 5:31pm UTC](https://discuss.px4.io/t/building-out-of-tree-modules-with-dependencies/20444 "2021-01-09T17:31:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![roman-dvorak](https://discuss.px4.io/user_avatar/discuss.px4.io/roman-dvorak/32/3086_2.png) [@roman-dvorak](https://discuss.px4.io/u/roman-dvorak)\
**Post date:** [January 9, 2021, 5:31pm UTC](https://discuss.px4.io/t/building-out-of-tree-modules-with-dependencies/20444/1 "2021-01-09T17:31:01Z")

</div>

Hi,  
I want to make more changes in take-off controller for use with auogyro. Because I assume it will take a long time, I want to developing it as external (out-of-tree) module. (Sure, then we’ll do PR into upstream).

However, I have some problem with out-of-tree modules and with cmake.

I copied `fw_pos_control_l1` into external folder. `<external>/src/modules`. Then I added `EXTERNAL` statement into CMake in the controller folder. And added it to CMake of external module.

Then I removed this source from board (sitl) CMake file.

On: `sudo make px4_sitl none_shell EXTERNAL_MODULES_LOCATION=../PX4_assets/`

Now, I getting this error:  
That targets from external module are not exists.

```bash
...
...
-- External modules: /home/roman/repos/tf/PX4_assets
CMake Error at /home/roman/repos/tf/PX4Firmware/cmake/px4_add_module.cmake:205 (get_target_property):
  get_target_property() called with non-existent target "l1".
Call Stack (most recent call first):
  /home/roman/repos/tf/PX4_assets/src/modules/fw_pos_control_l1/CMakeLists.txt:39 (px4_add_module)

CMake Error at /home/roman/repos/tf/PX4Firmware/cmake/px4_add_module.cmake:206 (if):
  if given arguments:

    "STREQUAL" "STATIC_LIBRARY"

  Unknown arguments specified
Call Stack (most recent call first):
  /home/roman/repos/tf/PX4_assets/src/modules/fw_pos_control_l1/CMakeLists.txt:39 (px4_add_module)

-- Configuring incomplete, errors occurred!
See also "/home/roman/repos/tf/PX4Firmware/build/px4_sitl_default/CMakeFiles/CMakeOutput.log".
Error: /home/roman/repos/tf/PX4Firmware/build/px4_sitl_default is not a directory
Makefile:224: recipe for target 'px4_sitl' failed
make: *** [px4_sitl] Error 1

```

My external module cmake:

```auto
include(px4_add_library)

add_subdirectory(launchdetection)
add_subdirectory(runway_takeoff)

px4_add_module(
	MODULE modules__fw_pos_control_l1
	MAIN fw_pos_control_l1
	SRCS
		FixedwingPositionControl.cpp
		FixedwingPositionControl.hpp
	DEPENDS
		l1
		launchdetection
		landing_slope
		runway_takeoff
	    tecs
    EXTERNAL
	)

```

Please any ideas what to do with it?

I know an out-of-tree documentation page, this [How to use external module - #9 by notoriou5](https://discuss.px4.io/t/how-to-use-external-module/9974/9) thread and other.

My last question if it is possible to have multiple out-of-tree folders?

Thank you very much!

---

<div class="post-metadata">

**Author:** ![SebastianG](https://discuss.px4.io/user_avatar/discuss.px4.io/sebastiang/32/16396_2.png) [@SebastianG](https://discuss.px4.io/u/SebastianG)\
**Post date:** [May 10, 2024, 10:02am UTC](https://discuss.px4.io/t/building-out-of-tree-modules-with-dependencies/20444/2 "2024-05-10T10:02:04Z")

</div>

Hi Roman,  
I’m at the same point as you were back then. Have you been able to solve the problem?

---

<div class="post-metadata">

**Author:** ![SebastianG](https://discuss.px4.io/user_avatar/discuss.px4.io/sebastiang/32/16396_2.png) [@SebastianG](https://discuss.px4.io/u/SebastianG)\
**Post date:** [May 22, 2024, 12:30pm UTC](https://discuss.px4.io/t/building-out-of-tree-modules-with-dependencies/20444/3 "2024-05-22T12:30:42Z")

</div>

My solution was:  
Dependencies are only needed if they are also in the external module. If the dependency is part of the standard PX4 software, it is built before the external modules.
