From add50b3bd5dcdf35987041f6c6b1d459c3cbad0b Mon Sep 17 00:00:00 2001 From: xuxin19 Date: Wed, 18 Dec 2024 11:39:38 +0800 Subject: [PATCH] cmake(bugfix):fix NuttX CMake Wasm build multi dirs cannot be identified System is unknown to cmake, create: Platform/WASI to use this system, please post your config file on discourse.cmake.org so it can be added to cmake Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org. CMake Error at CMakeLists.txt:100 (add_subdirectory): add_subdirectory given source /home/data/vela/tmp/apps/frameworks/security/ta/hello_world /home/data/vela/tmp/apps/frameworks/security/ta/" which is not an existing directory. Signed-off-by: xuxin19 --- tools/CMakeLists.txt | 2 +- tools/Wasm/CMakeLists.txt | 2 ++ tools/Wasm/WASI-SDK.cmake | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index d53a81929..640b597e1 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -50,7 +50,7 @@ if(CONFIG_TOOLS_WASM_BUILD OR CONFIG_INTERPRETERS_WAMR_BUILD_MODULES_FOR_NUTTX) ${CMAKE_COMMAND} -B${CMAKE_BINARY_DIR}/Wasm ${CMAKE_CURRENT_SOURCE_DIR}/Wasm -DAPPDIR=${APPDIR} -DTOPDIR=${TOPDIR} -DTOPBINDIR=${CMAKE_BINARY_DIR} -DKCONFIG_FILE_PATH=${KCONFIG_FILE_PATH} - -DWASI_SDK_PATH=$ENV{WASI_SDK_PATH} -DWASM_DIRS=${WASM_DIRS}) + -DWASI_SDK_PATH=$ENV{WASI_SDK_PATH} -DWASM_DIRS="${WASM_DIRS}") add_custom_target(wasm_build COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/Wasm) diff --git a/tools/Wasm/CMakeLists.txt b/tools/Wasm/CMakeLists.txt index 29c66a724..9272c20c5 100644 --- a/tools/Wasm/CMakeLists.txt +++ b/tools/Wasm/CMakeLists.txt @@ -95,6 +95,8 @@ function(nuttx_add_library) endfunction() +separate_arguments(WASM_DIRS) + # ~~~ # Add all the Wasm apps to the build process. foreach(WASM_APP ${WASM_DIRS}) diff --git a/tools/Wasm/WASI-SDK.cmake b/tools/Wasm/WASI-SDK.cmake index 34ffd4ff7..4785e0ec0 100644 --- a/tools/Wasm/WASI-SDK.cmake +++ b/tools/Wasm/WASI-SDK.cmake @@ -378,6 +378,13 @@ function(wasm_add_library) message(FATAL_ERROR "NAME is not provided.") endif() + # Check if the LIB_NAME (NAME) is already declared If it is, then skip the + # rest of the function + if(TARGET ${LIB_NAME}) + message(STATUS "Target ${LIB_NAME} already declared.") + return() + endif() + # Check if the LIB_SRCS (SRCS) is provided if(NOT LIB_SRCS) message(FATAL_ERROR "SRCS is not provided.")