Skip to content

Commit 4bdd33a

Browse files
wangchdoanchao
authored andcommitted
nuttx/cmake: Remove redundant logic in CMake scripts
Simplify the CMake scripts by removing redundant logic to improve code readability and maintainability. Signed-off-by: Chengdong Wang <[email protected]>
1 parent 519ffe6 commit 4bdd33a

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

CMakeLists.txt

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -270,24 +270,21 @@ if(CONFIG_ARCH_BOARD_CUSTOM)
270270
ABSOLUTE BASE_DIR ${NUTTX_DIR})
271271
else()
272272
set(NUTTX_BOARD_ABS_DIR ${NUTTX_BOARD_DIR})
273-
file(TOUCH ${CMAKE_BINARY_DIR}/boards/dummy/Kconfig)
274273
endif()
275274

276275
# check if board custom dir points to NuttX upstream board. This is useful when
277276
# an out-of-tree configuration uses an upstream board directory
278277
string(FIND "${CONFIG_ARCH_BOARD_CUSTOM_DIR}" "boards/" IS_NUTTX_BOARD)
279278

280-
if(NOT EXISTS ${CMAKE_BINARY_DIR}/boards/dummy/Kconfig)
281-
# link dummy/Kconfig only if this is not upstream board otherwise the same
282-
# Kconfig file is included twice which cause CMake warnings
283-
if(CONFIG_ARCH_BOARD_CUSTOM
284-
AND EXISTS ${NUTTX_BOARD_ABS_DIR}/Kconfig
285-
AND NOT (IS_NUTTX_BOARD EQUAL 0))
286-
nuttx_create_symlink(${NUTTX_BOARD_ABS_DIR}/Kconfig
287-
${CMAKE_BINARY_DIR}/boards/dummy/Kconfig)
288-
else()
289-
file(TOUCH ${CMAKE_BINARY_DIR}/boards/dummy/Kconfig)
290-
endif()
279+
# link dummy/Kconfig only if this is not upstream board otherwise the same
280+
# Kconfig file is included twice which cause CMake warnings
281+
if(CONFIG_ARCH_BOARD_CUSTOM
282+
AND EXISTS ${NUTTX_BOARD_ABS_DIR}/Kconfig
283+
AND NOT (IS_NUTTX_BOARD EQUAL 0))
284+
nuttx_create_symlink(${NUTTX_BOARD_ABS_DIR}/Kconfig
285+
${CMAKE_BINARY_DIR}/boards/dummy/Kconfig)
286+
else()
287+
file(TOUCH ${CMAKE_BINARY_DIR}/boards/dummy/Kconfig)
291288
endif()
292289

293290
# board platform driver
@@ -318,13 +315,11 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/arch/dummy)
318315
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/arch/dummy)
319316
endif()
320317

321-
if(NOT EXISTS ${CMAKE_BINARY_DIR}/arch/dummy/Kconfig)
322-
if(CONFIG_ARCH_CHIP_CUSTOM AND EXISTS ${NUTTX_CHIP_ABS_DIR}/Kconfig)
323-
nuttx_create_symlink(${NUTTX_CHIP_ABS_DIR}/Kconfig
324-
${CMAKE_BINARY_DIR}/arch/dummy/Kconfig)
325-
else()
326-
file(TOUCH ${CMAKE_BINARY_DIR}/arch/dummy/Kconfig)
327-
endif()
318+
if(CONFIG_ARCH_CHIP_CUSTOM AND EXISTS ${NUTTX_CHIP_ABS_DIR}/Kconfig)
319+
nuttx_create_symlink(${NUTTX_CHIP_ABS_DIR}/Kconfig
320+
${CMAKE_BINARY_DIR}/arch/dummy/Kconfig)
321+
else()
322+
file(TOUCH ${CMAKE_BINARY_DIR}/arch/dummy/Kconfig)
328323
endif()
329324

330325
if(NOT EXISTS ${CMAKE_BINARY_DIR}/arch/${CONFIG_ARCH})

0 commit comments

Comments
 (0)