This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit d6cf3015d8203ac8f0717382768ee5dec43407ac
Author: Tiago Medicci <[email protected]>
AuthorDate: Fri Jun 12 17:17:15 2026 -0300

    netutils/libwebsockets: Fix error regarding building with CMake
    
    Prior to this change, if an empty folder existed instead of the
    actual libwebsockets source, the build would fail. This commit
    checks for an actual file instead, avoid such kind of errors.
    
    Signed-off-by: Tiago Medicci <[email protected]>
---
 netutils/libwebsockets/CMakeLists.txt | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/netutils/libwebsockets/CMakeLists.txt 
b/netutils/libwebsockets/CMakeLists.txt
index ed3f58674..8f308e292 100644
--- a/netutils/libwebsockets/CMakeLists.txt
+++ b/netutils/libwebsockets/CMakeLists.txt
@@ -26,12 +26,19 @@ if(CONFIG_NETUTILS_LIBWEBSOCKETS)
 
   set(LIBWEBSOCKETS_DIR ${CMAKE_CURRENT_LIST_DIR}/libwebsockets)
 
-  if(NOT EXISTS ${LIBWEBSOCKETS_DIR})
+  # Match Makefile: strip kconfig quotes; default when olddefconfig has not run
+  set(LWS_VERSION ${CONFIG_NETUTILS_LIBWEBSOCKETS_VERSION})
+  string(REGEX REPLACE "^\"(.*)\"$" "\\1" LWS_VERSION "${LWS_VERSION}")
+  if(NOT LWS_VERSION)
+    set(LWS_VERSION "4.3.1")
+  endif()
+
+  if(NOT EXISTS "${LIBWEBSOCKETS_DIR}/lib/plat/unix/unix-caps.c")
     set(LIBWEBSOCKETS_URL "https://github.com/warmcat/libwebsockets/archive";)
     FetchContent_Declare(
       libwebsockets_fetch
-      URL ${LIBWEBSOCKETS_URL}/v${CONFIG_NETUTILS_LIBWEBSOCKETS_VERSION}.zip
-          SOURCE_DIR ${LIBWEBSOCKETS_DIR} BINARY_DIR
+      URL ${LIBWEBSOCKETS_URL}/v${LWS_VERSION}.zip SOURCE_DIR
+          ${LIBWEBSOCKETS_DIR} BINARY_DIR
           ${CMAKE_BINARY_DIR}/apps/netutils/libwebsockets/libwebsockets
       DOWNLOAD_NO_PROGRESS true
       TIMEOUT 30)
@@ -52,17 +59,26 @@ if(CONFIG_NETUTILS_LIBWEBSOCKETS)
   # Flags
   # 
############################################################################
 
-  string(REGEX MATCHALL "[0-9]" versions
-               "${CONFIG_NETUTILS_LIBWEBSOCKETS_VERSION}")
-  list(GET versions 0 VERSION_MAJOR)
-  list(GET versions 1 VERSION_MINOR)
-  list(GET versions 2 VERSION_PATCH)
+  string(REPLACE "." ";" LWS_VERSION_PARTS "${LWS_VERSION}")
+  list(GET LWS_VERSION_PARTS 0 VERSION_MAJOR)
+  list(LENGTH LWS_VERSION_PARTS LWS_VERSION_PARTS_LEN)
+  if(LWS_VERSION_PARTS_LEN GREATER 1)
+    list(GET LWS_VERSION_PARTS 1 VERSION_MINOR)
+  else()
+    set(VERSION_MINOR 0)
+  endif()
+  if(LWS_VERSION_PARTS_LEN GREATER 2)
+    list(GET LWS_VERSION_PARTS 2 VERSION_PATCH)
+  else()
+    set(VERSION_PATCH 0)
+  endif()
+
   set(FLAGS
       -DLWS_LIBRARY_VERSION_MAJOR=${VERSION_MAJOR}
       -DLWS_LIBRARY_VERSION_MINOR=${VERSION_MINOR}
       -DLWS_LIBRARY_VERSION_PATCH=${VERSION_PATCH}
       -DLWS_LIBRARY_VERSION_PATCH_ELABORATED=${VERSION_PATCH}-unknown
-      -DLWS_LIBRARY_VERSION="${CONFIG_NETUTILS_LIBWEBSOCKETS_VERSION}-unknown"
+      -DLWS_LIBRARY_VERSION="${LWS_VERSION}-unknown"
       -Wno-shadow
       -Wno-format)
 

Reply via email to