Skip to content

cmake(enhance):add NuttX CMake extensions module #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

xuxin930
Copy link
Contributor

Summary

[Enhancement]

  1. Wrapped CMake native method is nuttx_cmake module,
    It can be quickly called in the build system

  2. Add sanity check for commonly called functions

This will make our build system simpler and more modern :-)

e.g:

# we are currently adding an application library like:
# apps/libfoo/CMakeLists.txt
if(CONFIG_LIB_FOO)
  set(FLAGS -Werror)
  set(INCDIR ${CMAKE_CURRENT_LIST_DIR}/include)

  file(GLOB CSRCS ${CMAKE_CURRENT_LIST_DIR}/*.c)
  set(CSRCS ${CSRCS})

  if(CONFIG_AAA)
    list(APPEND CSRCS a.c)
  endif()
 
  if(CONFIG_BBB)
    list(APPEND CSRCS b.c)
  endif()

  if(CONFIG_OPT)
    list(APPEND FLAGS -Os)
  endif()
  
  nuttx_add_library(foo STATIC)
  target_sources(foo PRIVATE ${CSRCS})
  target_compile_options(foo PRIVATE ${FLAGS})
  target_include_directories(foo PRIVATE ${INCDIR})

endif()
# after using the extension, it can be simplified to:
# apps/libfoo/CMakeLists.txt
nuttx_library_ifdef(CONFIG_LIB_FOO foo)

nuttx_wildcard_sources(./*.c)
nuttx_sources_ifdef(CONFIG_AAA a.c)
nuttx_sources_ifdef(CONFIG_BBB b.c)

nuttx_compile_options(-Werror)
nuttx_compile_options_ifdef(CONFIG_OPT -Os)

nuttx_include_directories(${CMAKE_CURRENT_LIST_DIR}/include)

Impact

Enhanced cmake module, forward compatibility, no impact on the past

Testing

I haven't made any module changes to use the new extensions,
but I've modified the tests in local apps and it's feasible.
It greatly reduces the amount of code and is elegant enough.

@xiaoxiang781216 xiaoxiang781216 merged commit 85fa462 into open-vela:dev Dec 22, 2024
3 checks passed
@xuxin930 xuxin930 deleted the sync-1220-3 branch December 23, 2024 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants