apache / apache/nuttx

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

Open
#11,861 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

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
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

Contributor guide

Open the contributing guide

Research direction

Reproduce the rv-virt:ksmp64 configuration with CMake and inspect CMakeLists.txt, cmake/nuttx_add_library.cmake, arch/CMakeLists.txt, and arch/risc-v/src/common/CMakeLists.txt. Trace why nuttx_user and arch_interface receive no sources, then verify that generation succeeds and Ninja can build the resulting target without the missing syscall/stubs/nuttx_host_tools rule.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.