Skip to content

Commit f10b54a

Browse files
anchaoxiaoxiang781216
authored andcommitted
cmake: fix CMake build break
Signed-off-by: chao an <[email protected]>
1 parent f49ee08 commit f10b54a

File tree

21 files changed

+527
-212
lines changed

21 files changed

+527
-212
lines changed

arch/sim/src/cmake/Toolchain.cmake

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,97 @@ if(APPLE)
2222
find_program(CMAKE_C_ELF_COMPILER x86_64-elf-gcc)
2323
find_program(CMAKE_CXX_ELF_COMPILER x86_64-elf-g++)
2424
endif()
25+
26+
if(WIN32)
27+
return()
28+
endif()
29+
30+
add_compile_options(-fno-common)
31+
32+
if(CONFIG_DEBUG_SYMBOLS)
33+
add_compile_options(-g)
34+
endif()
35+
36+
if(CONFIG_SIM_M32)
37+
add_compile_options(-m32)
38+
endif()
39+
40+
if(CONFIG_DEBUG_CUSTOMOPT)
41+
add_compile_options(${CONFIG_DEBUG_OPTLEVEL})
42+
elseif(CONFIG_DEBUG_FULLOPT)
43+
if(CONFIG_ARCH_TOOLCHAIN_CLANG)
44+
add_compile_options(-Oz)
45+
else()
46+
add_compile_options(-Os)
47+
endif()
48+
endif()
49+
50+
if(NOT CONFIG_DEBUG_NOOPT)
51+
add_compile_options(-fno-strict-aliasing)
52+
endif()
53+
54+
if(CONFIG_FRAME_POINTER)
55+
add_compile_options(-fno-omit-frame-pointer -fno-optimize-sibling-calls)
56+
else()
57+
add_compile_options(-fomit-frame-pointer)
58+
endif()
59+
60+
if(CONFIG_STACK_CANARIES)
61+
add_compile_options(-fstack-protector-all)
62+
endif()
63+
64+
if(CONFIG_STACK_USAGE)
65+
add_compile_options(-fstack-usage)
66+
endif()
67+
68+
if(CONFIG_ARCH_COVERAGE)
69+
add_compile_options(-fprofile-generate -ftest-coverage)
70+
endif()
71+
72+
if(CONFIG_SIM_ASAN)
73+
add_compile_options(-fsanitize=address)
74+
add_compile_options(-fsanitize-address-use-after-scope)
75+
add_compile_options(-fsanitize=pointer-compare)
76+
add_compile_options(-fsanitize=pointer-subtract)
77+
elseif(CONFIG_MM_KASAN_ALL)
78+
add_compile_options(-fsanitize=kernel-address)
79+
endif()
80+
81+
if(CONFIG_SIM_UBSAN)
82+
add_compile_options(-fsanitize=undefined)
83+
else()
84+
if(CONFIG_MM_UBSAN_ALL)
85+
add_compile_options(${CONFIG_MM_UBSAN_OPTION})
86+
endif()
87+
88+
if(CONFIG_MM_UBSAN_TRAP_ON_ERROR)
89+
add_compile_options(-fsanitize-undefined-trap-on-error)
90+
endif()
91+
endif()
92+
93+
set(ARCHCFLAGS "-Wstrict-prototypes")
94+
set(ARCHCXXFLAGS "-nostdinc++")
95+
96+
if(CONFIG_CXX_EXCEPTION)
97+
string(APPEND ARCHCXXFLAGS " -fno-exceptions -fcheck-new")
98+
endif()
99+
100+
if(CONFIG_CXX_RTTI)
101+
string(APPEND ARCHCXXFLAGS " -fno-rtti")
102+
endif()
103+
104+
if(NOT "${CMAKE_C_FLAGS}" STREQUAL "")
105+
string(REGEX MATCH "${ARCHCFLAGS}" EXISTS_FLAGS "${CMAKE_C_FLAGS}")
106+
endif()
107+
108+
if(NOT EXISTS_FLAGS)
109+
set(CMAKE_ASM_FLAGS
110+
"${CMAKE_ASM_FLAGS}${ARCHCFLAGS}"
111+
CACHE STRING "" FORCE)
112+
set(CMAKE_C_FLAGS
113+
"${CMAKE_C_FLAGS}${ARCHCFLAGS}"
114+
CACHE STRING "" FORCE)
115+
set(CMAKE_CXX_FLAGS
116+
"${CMAKE_CXX_FLAGS}${ARCHCXXFLAGS}"
117+
CACHE STRING "" FORCE)
118+
endif()

arch/sim/src/sim/CMakeLists.txt

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ if(CONFIG_SCHED_BACKTRACE)
7171
list(APPEND SRCS sim_backtrace.c)
7272
endif()
7373

74-
if(CONFIG_ARCH_HAVE_FORK AND CONFIG_SCHED_WAITPID)
74+
if(CONFIG_ARCH_HAVE_FORK)
7575
list(APPEND SRCS sim_fork.c)
7676
endif()
7777

@@ -111,9 +111,11 @@ if(CONFIG_RPTUN)
111111
endif()
112112

113113
if(CONFIG_SIM_SOUND_ALSA)
114-
list(APPEND SRCS sim_alsa.c)
114+
list(APPEND SRCS posix/sim_alsa.c)
115+
list(APPEND SRCS posix/sim_offload.c)
115116
list(APPEND STDLIBS asound)
116117
list(APPEND STDLIBS mad)
118+
list(APPEND STDLIBS mp3lame)
117119
endif()
118120

119121
# host sources ###############################################################
@@ -127,6 +129,12 @@ list(
127129
sim_hosttime.c
128130
sim_hostuart.c)
129131

132+
if(CONFIG_SIM_CAMERA_V4L2)
133+
list(APPEND HOSTSRCS sim_host_v4l2.c)
134+
list(APPEND SRCS sim_camera.c)
135+
list(APPEND STDLIBS v4l2)
136+
endif()
137+
130138
if(CONFIG_SPINLOCK)
131139
list(APPEND HOSTSRCS sim_testset.c)
132140
endif()
@@ -149,6 +157,10 @@ if(CONFIG_SIM_X11FB)
149157
elseif(CONFIG_SIM_BUTTONS)
150158
list(APPEND HOSTSRCS sim_x11eventloop.c)
151159
endif()
160+
161+
if(CONFIG_SIM_KEYBOARD)
162+
list(APPEND SRCS sim_keyboard.c)
163+
endif()
152164
endif()
153165

154166
if(CONFIG_SIM_NETDEV_TAP)
@@ -168,31 +180,37 @@ elseif(CONFIG_SIM_NETDEV_VPNKIT)
168180
list(APPEND HOSTSRCS sim_vpnkit.c vpnkit/protocol.c vpnkit/negotiate.c)
169181
endif()
170182

171-
if(CONFIG_SIM_HCISOCKET)
172-
list(APPEND HOSTSRCS sim_hcisocket_host.c)
173-
list(APPEND SRCS sim_hcisocket.c)
174-
endif()
175-
176183
if(CONFIG_SIM_NETUSRSOCK)
177-
list(APPEND HOSTSRCS sim_usrsock_host.c)
184+
list(APPEND HOSTSRCS sim_hostusrsock.c)
178185
list(APPEND SRCS sim_usrsock.c)
179186
endif()
180187

181-
if(CONFIG_SIM_BTUART)
182-
list(APPEND HOSTSRCS sim_hcisocket_host.c)
183-
list(APPEND SRCS sim_btuart.c)
184-
endif()
185-
186-
if(CONFIG_I2C_RESET)
187-
list(APPEND HOST_DEFINITIONS CONFIG_I2C_RESET=1)
188+
if(CONFIG_SIM_HCISOCKET)
189+
list(APPEND HOSTSRCS sim_hosthcisocket.c)
190+
list(APPEND SRCS sim_hcisocket.c)
188191
endif()
189192

190193
if(CONFIG_SIM_I2CBUS_LINUX)
191-
list(APPEND HOSTSRCS sim_i2cbuslinux.c)
194+
list(APPEND HOSTSRCS sim_linuxi2c.c)
192195
endif()
193196

194197
if(CONFIG_SIM_SPI_LINUX)
195-
list(APPEND HOSTSRCS sim_spilinux.c)
198+
list(APPEND HOSTSRCS sim_linuxspi.c)
199+
endif()
200+
201+
if(CONFIG_SIM_USB_DEV)
202+
list(APPEND SRCS sim_usbdev.c)
203+
if(CONFIG_SIM_USB_RAW_GADGET)
204+
list(APPEND HOSTSRCS sim_rawgadget.c)
205+
endif()
206+
endif()
207+
208+
if(CONFIG_SIM_USB_HOST)
209+
list(APPEND SRCS sim_usbhost.c)
210+
if(CONFIG_SIM_LIBUSB)
211+
list(APPEND HOSTSRCS sim_libusb.c)
212+
list(APPEND STDLIBS usb-1.0)
213+
endif()
196214
endif()
197215

198216
if(CONFIG_SIM_HOSTFS)

boards/sim/sim/sim/src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ if(CONFIG_MOTOR_FOC_DUMMY)
5656
list(APPEND SRCS sim_foc.c)
5757
endif()
5858

59+
if(CONFIG_USBDEV_COMPOSITE)
60+
list(APPEND SRCS sim_composite.c)
61+
endif()
62+
5963
target_sources(board PRIVATE ${SRCS})
6064

6165
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/gnu-elf.ld")

drivers/misc/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ if(CONFIG_DEV_ZERO)
3131
list(APPEND SRCS dev_zero.c)
3232
endif()
3333

34+
if(CONFIG_DEV_ASCII)
35+
list(APPEND SRCS dev_ascii.c)
36+
endif()
37+
3438
if(CONFIG_LWL_CONSOLE)
3539
list(APPEND SRCS lwl_console.c)
3640
endif()
@@ -48,4 +52,20 @@ elseif(CONFIG_DRVR_READAHEAD)
4852
list(APPEND SRCS rwbuffer.c)
4953
endif()
5054

55+
if(CONFIG_DEV_RPMSG)
56+
list(APPEND SRCS rpmsgdev.c)
57+
endif()
58+
59+
if(CONFIG_DEV_RPMSG_SERVER)
60+
list(APPEND SRCS rpmsgdev_server.c)
61+
endif()
62+
63+
if(CONFIG_BLK_RPMSG)
64+
list(APPEND SRCS rpmsgblk.c)
65+
endif()
66+
67+
if(CONFIG_BLK_RPMSG_SERVER)
68+
list(APPEND SRCS rpmsgblk_server.c)
69+
endif()
70+
5171
target_sources(drivers PRIVATE ${SRCS})

drivers/motor/foc/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
# the License.
1818
#
1919
# ##############################################################################
20+
2021
if(CONFIG_MOTOR_FOC)
21-
target_sources(drivers PRIVATE foc_dev.c)
22+
set(SRCS foc_dev.c)
23+
if(CONFIG_MOTOR_FOC_DUMMY)
24+
list(APPEND SRCS foc_dummy.c)
25+
endif()
26+
27+
target_include_directories(drivers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
28+
target_sources(drivers PRIVATE ${SRCS})
2229
endif()

drivers/mtd/CMakeLists.txt

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121
# ##############################################################################
2222

2323
if(CONFIG_MTD)
24-
set(SRCS ftl.c mtd_config.c)
24+
set(SRCS ftl.c)
25+
26+
if(CONFIG_MTD_CONFIG_FAIL_SAFE)
27+
list(APPEND SRCS mtd_config_fs.c)
28+
elseif(CONFIG_MTD_CONFIG)
29+
list(APPEND SRCS mtd_config.c)
30+
endif()
2531

2632
if(CONFIG_MTD_PARTITION)
2733
list(APPEND SRCS mtd_partition.c)
@@ -33,10 +39,8 @@ if(CONFIG_MTD)
3339

3440
if(CONFIG_MTD_WRBUFFER)
3541
list(APPEND SRCS mtd_rwbuffer.c)
36-
else()
37-
if(CONFIG_MTD_READAHEAD)
38-
list(APPEND SRCS mtd_rwbuffer.c)
39-
endif()
42+
elseif(CONFIG_MTD_READAHEAD)
43+
list(APPEND SRCS mtd_rwbuffer.c)
4044
endif()
4145

4246
if(CONFIG_MTD_PROGMEM)
@@ -52,7 +56,6 @@ if(CONFIG_MTD)
5256
mtd_nandscheme.c
5357
mtd_nandmodel.c
5458
mtd_modeltab.c)
55-
5659
if(CONFIG_MTD_NAND_SWECC)
5760
list(APPEND SRCS mtd_nandecc.c hamming.c)
5861
endif()
@@ -66,6 +69,18 @@ if(CONFIG_MTD)
6669
list(APPEND SRCS filemtd.c)
6770
endif()
6871

72+
if(CONFIG_NULLMTD)
73+
list(APPEND SRCS nullmtd.c)
74+
endif()
75+
76+
if(CONFIG_RPMSGMTD)
77+
list(APPEND SRCS rpmsgmtd.c)
78+
endif()
79+
80+
if(CONFIG_RPMSGMTD_SERVER)
81+
list(APPEND SRCS rpmsgmtd_server.c)
82+
endif()
83+
6984
if(CONFIG_MTD_AT24XX)
7085
list(APPEND SRCS at24xx.c)
7186
endif()
@@ -142,10 +157,8 @@ if(CONFIG_MTD)
142157
list(APPEND SRCS is25xp.c)
143158
endif()
144159

145-
if(CONFIG_MTD_SMART)
146-
if(CONFIG_FS_SMARTFS)
147-
list(APPEND SRCS smart.c)
148-
endif()
160+
if(CONFIG_MTD_SMART AND CONFIG_FS_SMARTFS)
161+
list(APPEND SRCS smart.c)
149162
endif()
150163

151164
target_sources(drivers PRIVATE ${SRCS})

drivers/note/CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,26 @@
1919
# ##############################################################################
2020
set(SRCS)
2121

22-
if(CONFIG_DRIVER_NOTE)
22+
if(CONFIG_DRIVERS_NOTE)
2323
list(APPEND SRCS note_driver.c)
24+
list(APPEND SRCS note_initialize.c)
2425
endif()
2526

26-
if(CONFIG_DRIVER_NOTERAM)
27+
if(CONFIG_DRIVERS_NOTERAM)
2728
list(APPEND SRCS noteram_driver.c)
2829
endif()
2930

30-
if(CONFIG_DRIVER_NOTECTL)
31+
if(CONFIG_DRIVERS_NOTELOG)
32+
list(APPEND SRCS notelog_driver.c)
33+
endif()
34+
35+
if(CONFIG_DRIVERS_NOTECTL)
3136
list(APPEND SRCS notectl_driver.c)
3237
endif()
3338

39+
if(CONFIG_DRIVERS_NOTESNAP)
40+
list(APPEND SRCS notesnap_driver.c)
41+
endif()
42+
3443
target_sources(drivers PRIVATE ${SRCS})
44+
target_include_directories(drivers PRIVATE ${NUTTX_DIR}/sched)

0 commit comments

Comments
 (0)