mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
cmake(feat):define elf option and enable apps module build
1.define elf option setting function ext; 2.unify loadable elf and kernel elf build config Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
This commit is contained in:
parent
885ff780c5
commit
6fa3031d9b
9 changed files with 183 additions and 30 deletions
|
|
@ -126,17 +126,21 @@ function(nuttx_add_application)
|
|||
COMMAND
|
||||
${CMAKE_LD}
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_global,NUTTX_ELF_APP_LINK_OPTIONS>>
|
||||
-e __start -Bstatic -T ${CMAKE_BINARY_DIR}/gnu-elf.ld
|
||||
-e __start -T ${CMAKE_BINARY_DIR}/gnu-elf.ld
|
||||
$<TARGET_OBJECTS:STARTUP_OBJS> --start-group
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_global,NUTTX_ELF_LINK_LIBRARIES>>
|
||||
$<$<BOOL:${CONFIG_BUILD_KERNEL}>:$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_global,NUTTX_ELF_LINK_LIBRARIES>>>
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_global,NUTTX_ELF_LINK_EXTRA_LIBRARIES>>
|
||||
$<TARGET_FILE:${TARGET}> --end-group -o
|
||||
${CMAKE_BINARY_DIR}/bin/${ELF_NAME}
|
||||
COMMENT "Building ELF:${ELF_NAME}"
|
||||
COMMAND_EXPAND_LISTS)
|
||||
else()
|
||||
add_executable(${TARGET} ${SRCS})
|
||||
target_link_options(
|
||||
${TARGET} PRIVATE
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_ELF_APP_LINK_OPTIONS>>)
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_global,NUTTX_ELF_APP_LINK_OPTIONS>>
|
||||
)
|
||||
endif()
|
||||
|
||||
# easy access to final ELF, regardless of how it was created
|
||||
|
|
@ -148,10 +152,11 @@ function(nuttx_add_application)
|
|||
# loadable build requires applying ELF flags to all applications
|
||||
|
||||
if(CONFIG_MODULES)
|
||||
add_dependencies(nuttx_apps_mksymtab ${TARGET})
|
||||
target_compile_options(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_ELF_APP_COMPILE_OPTIONS>>
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_global,NUTTX_ELF_APP_COMPILE_OPTIONS>>
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
@ -165,24 +170,6 @@ function(nuttx_add_application)
|
|||
set(TARGET "apps_${NAME}")
|
||||
add_library(${TARGET} ${SRCS})
|
||||
|
||||
# Set apps global compile options & definitions hold by
|
||||
# nuttx_apps_interface
|
||||
target_compile_options(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_apps_interface,APPS_COMPILE_OPTIONS>>
|
||||
)
|
||||
target_compile_definitions(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_apps_interface,APPS_COMPILE_DEFINITIONS>>
|
||||
)
|
||||
target_include_directories(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_apps_interface,APPS_INCLUDE_DIRECTORIES>>
|
||||
)
|
||||
|
||||
nuttx_add_library_internal(${TARGET})
|
||||
# add to list of application libraries
|
||||
|
||||
|
|
@ -247,6 +234,23 @@ function(nuttx_add_application)
|
|||
target_include_directories(${TARGET} BEFORE
|
||||
PRIVATE ${INCLUDE_DIRECTORIES})
|
||||
endif()
|
||||
|
||||
# Set apps global compile options & definitions hold by nuttx_apps_interface
|
||||
target_compile_options(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_apps_interface,APPS_COMPILE_OPTIONS>>
|
||||
)
|
||||
target_compile_definitions(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_apps_interface,APPS_COMPILE_DEFINITIONS>>
|
||||
)
|
||||
target_include_directories(
|
||||
${TARGET}
|
||||
PRIVATE
|
||||
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx_apps_interface,APPS_INCLUDE_DIRECTORIES>>
|
||||
)
|
||||
endif()
|
||||
|
||||
# add supplied dependencies
|
||||
|
|
|
|||
|
|
@ -258,12 +258,10 @@ function(nuttx_add_extra_library)
|
|||
set_property(GLOBAL APPEND PROPERTY NUTTX_USER_EXTRA_LIBRARIES
|
||||
${extra_target})
|
||||
endif()
|
||||
if(CONFIG_BUILD_KERNEL)
|
||||
set_property(
|
||||
TARGET nuttx_global
|
||||
APPEND
|
||||
PROPERTY NUTTX_ELF_LINK_LIBRARIES $<TARGET_FILE:${extra_target}>)
|
||||
endif()
|
||||
set_property(
|
||||
TARGET nuttx_global
|
||||
APPEND
|
||||
PROPERTY NUTTX_ELF_LINK_EXTRA_LIBRARIES $<TARGET_FILE:${extra_target}>)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
|
|
|||
|
|
@ -257,6 +257,78 @@ function(nuttx_compile_options_ifndef cond)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
# Function: nuttx_elf_compile_options
|
||||
#
|
||||
# Adds compile options to elf targets
|
||||
#
|
||||
# Usage: nuttx_elf_compile_options("-O2" "-Wall")
|
||||
function(nuttx_elf_compile_options)
|
||||
set_property(
|
||||
TARGET nuttx_global
|
||||
APPEND
|
||||
PROPERTY NUTTX_ELF_APP_COMPILE_OPTIONS ${ARGN})
|
||||
endfunction()
|
||||
|
||||
# Function: nuttx_elf_compile_options_ifdef
|
||||
#
|
||||
# Conditionally adds compile options to the elf target if the given condition is
|
||||
# true.
|
||||
#
|
||||
# Usage: nuttx_elf_compile_options_ifdef(MY_CONDITION "-O2" "-Wall")
|
||||
function(nuttx_elf_compile_options_ifdef cond)
|
||||
if(${cond})
|
||||
nuttx_elf_compile_options(${ARGN})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Function: nuttx_elf_compile_options_ifndef
|
||||
#
|
||||
# Conditionally adds compile options to the elf target if the given condition is
|
||||
# false.
|
||||
#
|
||||
# Usage: nuttx_elf_compile_options_ifndef(MY_CONDITION "-O2" "-Wall")
|
||||
function(nuttx_elf_compile_options_ifndef cond)
|
||||
if(NOT ${cond})
|
||||
nuttx_elf_compile_options(${ARGN})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Function: nuttx_elf_link_options
|
||||
#
|
||||
# Adds link options to elf targets
|
||||
#
|
||||
# Usage: nuttx_elf_link_options("-r")
|
||||
function(nuttx_elf_link_options)
|
||||
set_property(
|
||||
TARGET nuttx_global
|
||||
APPEND
|
||||
PROPERTY NUTTX_ELF_APP_LINK_OPTIONS ${ARGN})
|
||||
endfunction()
|
||||
|
||||
# Function: nuttx_elf_link_options_ifdef
|
||||
#
|
||||
# Conditionally adds link options to the elf target if the given condition is
|
||||
# true.
|
||||
#
|
||||
# Usage: nuttx_elf_link_options_ifdef(MY_CONDITION "-r")
|
||||
function(nuttx_elf_link_options_ifdef cond)
|
||||
if(${cond})
|
||||
nuttx_elf_link_options(${ARGN})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Function: nuttx_elf_link_options_ifndef
|
||||
#
|
||||
# Conditionally adds link options to the elf target if the given condition is
|
||||
# false.
|
||||
#
|
||||
# Usage: nuttx_elf_link_options_ifndef(MY_CONDITION "-r")
|
||||
function(nuttx_elf_link_options_ifndef cond)
|
||||
if(NOT ${cond})
|
||||
nuttx_elf_link_options(${ARGN})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# the visible scope is all the APPS include search path
|
||||
function(nuttx_include_directories_for_all_apps)
|
||||
set_property(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue