apache / nuttx

Apache NuttX is a mature, real-time embedded operating system (RTOS)
https://nuttx.apache.org/
Apache License 2.0
2.92k stars 1.19k forks source link

cmake fail to generate build file for target rv-virt:ksmp64 #11861

Open inochisa opened 9 months ago

inochisa commented 9 months ago

I got an error when generating build file for rv-virt:ksmp64 with cmake.

# cmake .. -DBOARD_CONFIG=rv-virt:ksmp64 -GNinja

-- Initializing NuttX
--   Board:  rv-virt
--   Config: ksmp64
--   Appdir: /mnt/files/inochi/cache/mainline/nuttx/../apps
-- Configuring done (1.1s)
CMake Error at CMakeLists.txt:736 (add_executable):
  No SOURCES given to target: nuttx_user

CMake Error at cmake/nuttx_add_library.cmake:90 (add_library):
  No SOURCES given to target: arch_interface
Call Stack (most recent call first):
  arch/CMakeLists.txt:29 (nuttx_add_system_library)

CMake Generate step failed.  Build files cannot be regenerated correctly.

I have tried the following change, but get another error: ninja: error: 'syscall/stubs/nuttx_host_tools', needed by 'syscall/stubs/STUB__assert.c', missing and no known rule to make it

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fce86072c0..730a84cedb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -732,7 +732,7 @@ endif()

 # Userspace portion ##########################################################

-if(NOT CONFIG_BUILD_FLAT)
+if(NOT CONFIG_BUILD_FLAT AND CONFIG_NUTTX_USERSPACE)
   add_executable(nuttx_user)

   get_property(nuttx_system_libs GLOBAL PROPERTY NUTTX_SYSTEM_LIBRARIES)
diff --git a/arch/risc-v/src/common/CMakeLists.txt b/arch/risc-v/src/common/CMakeLists.txt
index f704b210d0..91e59b83a1 100644
--- a/arch/risc-v/src/common/CMakeLists.txt
+++ b/arch/risc-v/src/common/CMakeLists.txt
@@ -100,3 +100,4 @@ if(CONFIG_ARCH_ADDRENV)
 endif()

 target_sources(arch PRIVATE ${SRCS})
+target_sources(arch_interface PRIVATE ${SRCS})

I wonder whether there is something I missed. My cmake version is 3.28.3

anchao commented 9 months ago

Cmake does not support Kernel(CONFIG_BUILD_KERNEL) / Protected(CONFIG_BUILD_PROTECTED) mode building currently. Please use Makefile to build if the board defconfig contains dependencies on these two modes.