From b37b22eacd689ffd2f56a836bb5ddcba09ae391e Mon Sep 17 00:00:00 2001 From: simbit18 <101105604+simbit18@users.noreply.github.com> Date: Thu, 16 Apr 2026 14:30:03 +0200 Subject: [PATCH] cmake: Moved the creation of the nxtmpdir folder to the root CMake file - Moved the creation of the `nxtmpdir` folder for third-party packages to the root `CMakeLists.txt` file. cmake/nuttx_3rdparty.cmake - Add the nuttx_remove_nxtmpdir function to remove the third-party cache directory under nuttx/../nxtmpdir Signed-off-by: simbit18 --- CMakeLists.txt | 10 ++++++++++ arch/risc-v/src/common/espressif/CMakeLists.txt | 2 -- cmake/nuttx_3rdparty.cmake | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82af32ddb64..77755168edf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,6 +230,16 @@ set(ENV{HOST_OTHER} n) include(nuttx_sethost) +option(NXTMPDIR "Create the nxtmpdir folder for third-party packages." OFF) + +include(nuttx_3rdparty) + +if(NXTMPDIR) + nuttx_make_nxtmpdir() +else() + nuttx_remove_nxtmpdir() +endif() + include(nuttx_parse_function_args) include(nuttx_add_subdirectory) include(nuttx_create_symlink) diff --git a/arch/risc-v/src/common/espressif/CMakeLists.txt b/arch/risc-v/src/common/espressif/CMakeLists.txt index c948bd9b385..10e1415e0c9 100644 --- a/arch/risc-v/src/common/espressif/CMakeLists.txt +++ b/arch/risc-v/src/common/espressif/CMakeLists.txt @@ -243,8 +243,6 @@ if(NOT IS_DIRECTORY "${ESP_HAL_3RDPARTY_REPO}") # NXTMPDIR contains a cached version of the esp-hal-3rdparty repository, which # is located on nuttx/../nxtmpdir/esp-hal-3rdparty if it exists. if(NXTMPDIR) - include(${NUTTX_DIR}/cmake/nuttx_3rdparty.cmake) - nuttx_make_nxtmpdir() set(ESP_HAL_NXTMPDIR_CACHE "${NXTMPDIR_PATH}/${ESP_HAL_3RDPARTY_REPO_NAME}") get_filename_component(ESP_HAL_NXTMPDIR_CACHE "${ESP_HAL_NXTMPDIR_CACHE}" REALPATH) diff --git a/cmake/nuttx_3rdparty.cmake b/cmake/nuttx_3rdparty.cmake index 2bd3d0835da..593bbcd84b1 100644 --- a/cmake/nuttx_3rdparty.cmake +++ b/cmake/nuttx_3rdparty.cmake @@ -40,6 +40,21 @@ function(nuttx_make_nxtmpdir) endif() endfunction() +# ~~~ +# nuttx_remove_nxtmpdir +# +# Description: +# Remove the third-party cache directory under nuttx/../nxtmpdir +# +# ~~~ + +function(nuttx_remove_nxtmpdir) + set(_nxtmpdir "${NUTTX_DIR}/../nxtmpdir") + if(EXISTS "${_nxtmpdir}") + file(REMOVE_RECURSE "${_nxtmpdir}") + endif() +endfunction() + # ~~~ # nuttx_check_git_hash #