cmake: Use NUTTX(_DIR/_BINARY_DIR) instead of CMAKE(_SOURCE_DIR/BINARY_DIR)

This companion change updates the nuttx-apps CMake build to use
NuttX’s NUTTX_DIR and NUTTX_BINARY_DIR instead of CMAKE_SOURCE_DIR
and CMAKE_BINARY_DIR, which incorrectly refer to the outermost project
when NuttX is embedded via add_subdirectory(). Since apps/ is itself
included from NuttX’s top-level CMakeLists.txt, these variables were
effectively being used as references to NuttX’s root and inherited
the same bug fixed in the matching NuttX change for #19697. All
self-referencing uses are replaced while intentionally preserving
standalone projects and unrelated custom variables or hardcoded paths.
The change affects only the CMake build system, preserves normal
standalone behavior, and was tested with sim:nsh both standalone and
embedded, with apps such as hello and ostest successfully built and
available in NSH.

Fixes #19697.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Alan Carvalho de Assis <acassis@gmail.com>
This commit is contained in:
Alan Carvalho de Assis 2026-08-08 15:53:10 -03:00 • committed by Alan C. Assis
parent 680c5ce797
commit cc8a6c8b85
68 changed files with 153 additions and 153 deletions

View file

@ -78,7 +78,7 @@ if(CONFIG_MATTER)
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/connectedhomeip
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/netutils/connectedhomeip
${NUTTX_BINARY_DIR}/apps/netutils/connectedhomeip
TIMEOUT
90
PATCH_LIST
@ -92,7 +92,7 @@ if(CONFIG_MATTER)
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/pigweed
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/netutils/connectedhomeip
${NUTTX_BINARY_DIR}/apps/netutils/connectedhomeip
TIMEOUT
90)
@ -104,7 +104,7 @@ if(CONFIG_MATTER)
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/nlio
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/netutils/connectedhomeip
${NUTTX_BINARY_DIR}/apps/netutils/connectedhomeip
TIMEOUT
30)
@ -116,7 +116,7 @@ if(CONFIG_MATTER)
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/nlassert
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/netutils/connectedhomeip
${NUTTX_BINARY_DIR}/apps/netutils/connectedhomeip
TIMEOUT
30)
@ -128,7 +128,7 @@ if(CONFIG_MATTER)
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/nlunit-test
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/netutils/connectedhomeip
${NUTTX_BINARY_DIR}/apps/netutils/connectedhomeip
TIMEOUT
30)
@ -140,7 +140,7 @@ if(CONFIG_MATTER)
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/inipp
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/netutils/connectedhomeip
${NUTTX_BINARY_DIR}/apps/netutils/connectedhomeip
TIMEOUT
30)
@ -158,12 +158,12 @@ if(CONFIG_MATTER)
list(APPEND nuttx_include_dirs ${include_dirs})
endif()
list(APPEND nuttx_include_dirs ${NUTTX_DIR}/include
${CMAKE_BINARY_DIR}/include)
${NUTTX_BINARY_DIR}/include)
list(APPEND nuttx_include_dirs ${NUTTX_APPS_BINDIR}/include/mbedtls)
set(MATTER_INCDIR
${nuttx_include_dirs}
${CMAKE_BINARY_DIR}/apps/netutils/connectedhomeip/gen/include
${NUTTX_BINARY_DIR}/apps/netutils/connectedhomeip/gen/include
${NUTTX_APPS_DIR}/include
${NUTTX_APPS_DIR}/netutils/jsoncpp/jsoncpp/include
inipp
@ -353,15 +353,15 @@ if(CONFIG_MATTER)
100)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/apps/netutils/connectedhomeip/lib/libchipnuttx.a
OUTPUT ${NUTTX_BINARY_DIR}/apps/netutils/connectedhomeip/lib/libchipnuttx.a
COMMAND echo generate libchipnuttx.a)
add_custom_target(
libchipnuttx ALL
DEPENDS ${CMAKE_BINARY_DIR}/apps/netutils/connectedhomeip/lib/libchipnuttx.a
DEPENDS ${NUTTX_BINARY_DIR}/apps/netutils/connectedhomeip/lib/libchipnuttx.a
)
add_dependencies(libchipnuttx chip-gn)
nuttx_add_extra_library(
${CMAKE_BINARY_DIR}/apps/netutils/connectedhomeip/lib/libchipnuttx.a)
${NUTTX_BINARY_DIR}/apps/netutils/connectedhomeip/lib/libchipnuttx.a)
endif()

View file

@ -30,7 +30,7 @@ if(CONFIG_NETUTILS_JSONCPP)
FetchContent_Declare(
jsoncpp_fetch
URL ${JSONCPP_URL}/${JSONCPP_VERSION}.zip SOURCE_DIR ${JSONCPP_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/apps/netutils/jsoncpp
BINARY_DIR ${NUTTX_BINARY_DIR}/apps/netutils/jsoncpp
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)

View file

@ -29,7 +29,7 @@ if(CONFIG_NETUTILS_LIBCOAP)
FetchContent_Declare(
libcoap_fetch
URL ${LIBCOAP_URL}/v${LIBCOAP_VERSION} SOURCE_DIR ${LIBCOAP_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/apps/netutils/libcoap
BINARY_DIR ${NUTTX_BINARY_DIR}/apps/netutils/libcoap
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)

View file

@ -39,7 +39,7 @@ if(CONFIG_NETUTILS_LIBWEBSOCKETS)
libwebsockets_fetch
URL ${LIBWEBSOCKETS_URL}/v${LWS_VERSION}.zip SOURCE_DIR
${LIBWEBSOCKETS_DIR} BINARY_DIR
${CMAKE_BINARY_DIR}/apps/netutils/libwebsockets/libwebsockets
${NUTTX_BINARY_DIR}/apps/netutils/libwebsockets/libwebsockets
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)

View file

@ -1,24 +1,24 @@
############################################################################
# ##############################################################################
# apps/netutils/nng/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# License for the specific language governing permissions and limitations under
# the License.
#
############################################################################
# ##############################################################################
if(CONFIG_NETUTILS_NNG)
@ -33,7 +33,7 @@ if(CONFIG_NETUTILS_NNG)
FetchContent_Declare(
nng_fetch
URL ${NNG_URL}/v${CONFIG_NETUTILS_NNG_VERSION}.tar.gz SOURCE_DIR
${NNG_DIR} BINARY_DIR ${CMAKE_BINARY_DIR}/apps/netutils/nng/nng
${NNG_DIR} BINARY_DIR ${NUTTX_BINARY_DIR}/apps/netutils/nng/nng
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)

View file

@ -38,7 +38,7 @@ if(CONFIG_LIB_MQTT5)
FetchContent_Declare(
paho_mqtt_fetch
URL ${PAHO_MQTT_URL}/v${PAHO_MQTT_VERSION}.zip SOURCE_DIR ${PAHO_MQTT_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/apps/netutils/paho_mqtt/paho_mqtt
BINARY_DIR ${NUTTX_BINARY_DIR}/apps/netutils/paho_mqtt/paho_mqtt
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)

View file

@ -34,7 +34,7 @@ if(CONFIG_NETUTILS_RTPTOOLS)
rtptools_fetch
URL ${RTPTOOLS_URL}/${CONFIG_NETUTILS_RTPTOOLS_VERSION}.tar.gz SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/rtptools BINARY_DIR
${CMAKE_BINARY_DIR}/netutils/rtptools/rtptools
${NUTTX_BINARY_DIR}/netutils/rtptools/rtptools
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)

View file

@ -31,7 +31,7 @@ if(CONFIG_NETUTILS_WAKAAMA)
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/wakaama
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/netutils/wakaama/wakaama
${NUTTX_BINARY_DIR}/apps/netutils/wakaama/wakaama
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)