Skip to content

Only set FPRIME_PROJECT_ROOT when fprime is the top-level project#101

Open
devin-ai-integration[bot] wants to merge 1 commit into
throw-away-cmake-hacksfrom
devin/1779385765-fix-project-root-for-add-subdirectory
Open

Only set FPRIME_PROJECT_ROOT when fprime is the top-level project#101
devin-ai-integration[bot] wants to merge 1 commit into
throw-away-cmake-hacksfrom
devin/1779385765-fix-project-root-for-add-subdirectory

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented May 21, 2026

Copy link
Copy Markdown
Related Issue(s) N/A
Has Unit Tests (y/n) n
Documentation Included (y/n) n
Generative AI was used in this contribution (y/n) y

Change Description

Guard the FPRIME_PROJECT_ROOT cache variable in CMakeLists.txt so 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 via add_subdirectory(), the parent project is expected to set FPRIME_PROJECT_ROOT to its own root directory.

Rationale

When using F Prime as a CMake subdirectory via add_subdirectory(), the unconditional set(FPRIME_PROJECT_ROOT ... FORCE) overwrites the parent project's root with fprime's own directory. This causes get_nearest_build_root to fail for project-level modules since they are not under lib/fprime/.

This fix enables the add_subdirectory pattern used in the fprime_add_subdirectory_reference project.

Testing/Review Recommendations

  • Verified that the fprime_add_subdirectory_reference project generates and builds successfully (471 targets) with this fix applied.
  • When fprime is the top-level project (standalone build), behavior is unchanged since the guard evaluates to true.

Future Work

Additional fixes may be needed in F Prime's cmake system to fully support the add_subdirectory() pattern (e.g., CMAKE_MODULE_PATH propagation, 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


Open in Devin Review

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>
@devin-ai-integration

Copy link
Copy Markdown
Author
Original prompt from michael.d.starch

will you create a new fprime reference. This one should add fprime as a make subdirectory (add_subdirectory). Use the branch cmake-test-fixes on the lestarch fork. Make sure the reference uses the new format with a project folder containing a deployment folder.

Use fprime-bootstrap to build the project and then fprime-until new to make development after sourcing the venv and cding into the project folder. Then make a commit as a baseline.

Generate and build and then come talk to me….fix errors with the deployment and project…but come back to me if you need a change in fprime.

@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

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.

0 participants