cmake: Use NUTTX(_DIR/_BIN_DIR) instead CMAKE(_SRC_DIR/_BIN_DIR) - #19755
Conversation
|
Please ignore Check issue, "siz" is the file extension: |
This change fixes NuttX’s CMake support when NuttX is embedded in another project via add_subdirectory(). CMake’s CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR refer to the outermost project, causing NuttX to access its .config, generated files, host tools, and build artifacts in the parent project’s directories. The fix introduces NUTTX_DIR and NUTTX_BINARY_DIR, based on CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR, and consistently uses them for NuttX self-references while preserving existing standalone builds. It fixes the Kconfig initialization failure reported in apache#19697 and allows an embedded sim:nsh build to configure, build, and boot successfully. The change affects only the CMake build system (not Make or Kconfig defaults), requires the corresponding nuttx-apps change, and does not extend add_subdirectory() support to cross-compiled non-sim boards due to CMake’s toolchain-file limitation. Fixes apache#19697. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Alan Carvalho de Assis <[email protected]>
|
@simbit18 I think if the Check fails because typos we need to continue the next steps, because it is producing false positives. The only way to make it passing it modifying a legit text to make it wrong just to satisfy the CI |
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s): CI run: https://github.com/apache/nuttx/actions/runs/31277642253 |
|
What problem exactly does this PR solve? support for add_subdirectory is not possible with current cmake support in nuttx and supporting this may require a complete rebuild of cmake build |
@raiden00pl with this simple modification we can run the NuttX sim as external project: This is just the initial step, more modifications will be necessary to support cross-compiling too. As you said it will be a redesign of CMake build system. So I want to do it in baby steps |
|
Hi @simbit18 what is necessary to make the Depends-on Check to reflect here in the official CI Check list?
|
|
@acassis |

Summary
This change fixes NuttX’s CMake support when NuttX is embedded in another project via add_subdirectory(). CMake’s CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR refer to the outermost project, causing NuttX to access its .config, generated files, host tools, and build artifacts in the parent project’s directories. The fix introduces NUTTX_DIR and NUTTX_BINARY_DIR, based on CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR, and consistently uses them for NuttX self-references while preserving existing standalone builds. It fixes the Kconfig initialization failure reported in #19697 and allows an embedded sim:nsh build to configure, build, and boot successfully. The change affects only the CMake build system (not Make or Kconfig defaults), requires the corresponding nuttx-apps change, and does not extend add_subdirectory() support to cross-compiled non-sim boards due to CMake’s toolchain-file limitation.
Depends-on: apache/nuttx-apps#3711
Impact
Fixes #19697
Testing
Complete log: apache/nuttx-apps#3711