Only set FPRIME_PROJECT_ROOT when fprime is the top-level project#101
Conversation
When F Prime is used as a subdirectory via add_subdirectory(), the parent project should set FPRIME_PROJECT_ROOT to its own root. Previously, fprime unconditionally overwrote this with its own directory, breaking the build root detection for project-level modules. Guard the set with CMAKE_SOURCE_DIR == CMAKE_CURRENT_SOURCE_DIR so it only applies when fprime is the top-level project. Co-Authored-By: michael.d.starch <michael.d.starch@jpl.nasa.gov>
Original prompt from michael.d.starch
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Change Description
Guard the
FPRIME_PROJECT_ROOTcache variable inCMakeLists.txtso it is only set when F Prime is the top-level CMake project (CMAKE_SOURCE_DIR == CMAKE_CURRENT_SOURCE_DIR). When F Prime is included viaadd_subdirectory(), the parent project is expected to setFPRIME_PROJECT_ROOTto its own root directory.Rationale
When using F Prime as a CMake subdirectory via
add_subdirectory(), the unconditionalset(FPRIME_PROJECT_ROOT ... FORCE)overwrites the parent project's root with fprime's own directory. This causesget_nearest_build_rootto fail for project-level modules since they are not underlib/fprime/.This fix enables the
add_subdirectorypattern used in the fprime_add_subdirectory_reference project.Testing/Review Recommendations
Future Work
Additional fixes may be needed in F Prime's cmake system to fully support the
add_subdirectory()pattern (e.g.,CMAKE_MODULE_PATHpropagation, include directory scoping).AI Usage (see policy)
AI (Devin) was used to identify the root cause and implement the fix while building the fprime_add_subdirectory_reference project.
Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/0f7a8879993340a3a8351d9b087177c0