Skip to content

Conversation

@OwenCochell
Copy link
Contributor

Hello,

When adding the project via FetchContent, or when including it as a subdirectory, an error occurs when building. Specifically, when building the generate_core_mavlink_xml_header target, an error occurs as CMake can't find cmake/generate_embedded_xml.cmake.

This can be reproduced by the following CMake file:

cmake_minimum_required(VERSION 4.2)

project(test)

add_subdirectory(MAVSDK)

In this case, we are adding a sub-directory that contains the MAVSDK source, but this could be done via FetchContent as well. Configuring will go ok, but if CMake is asked to build all targets then the error occurs.

This is because there is a custom CMake command that uses the CMAKE_SOURCE_DIR variable to locate the root of the project. The problem is, when including MAVSDK using the methods defined above, this variable instead points to the root of the project including MAVSDK. Because the parent project does not have this file, a build error occurs. We fix this by instead navigating to the root manually from the problematic CMake file.

Please let me know if there are any changes required, this is a small patch. Also, if it is not intended to include MAVSDK in this way, then this change might not be useful.

Thanks!

@sonarqubecloud
Copy link

Copy link
Collaborator

@julianoes julianoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@julianoes julianoes merged commit 1572ea3 into mavlink:main Nov 27, 2025
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants