From 1240776fb386acc580b22cdcbda970cc73828c95 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 21 May 2026 17:49:41 +0000 Subject: [PATCH] Only set FPRIME_PROJECT_ROOT when fprime is the top-level project 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 --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb6fdaef8a8..857922f6350 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,11 @@ cmake_minimum_required(VERSION 3.16) project(FPrime C CXX) set(FPRIME_FRAMEWORK_PATH "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Location of F prime framework" FORCE) -set(FPRIME_PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Root path of F prime project" FORCE) +# Only set FPRIME_PROJECT_ROOT when F Prime is the top-level project. +# When used as a subdirectory via add_subdirectory(), the parent project sets this. +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(FPRIME_PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Root path of F prime project" FORCE) +endif() # Include the build for F prime. include("${CMAKE_CURRENT_LIST_DIR}/cmake/FPrime.cmake")