diff --git a/CMakeLists.txt b/CMakeLists.txt index 021e51b93b..5fedeaa335 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,6 +250,15 @@ else() file(TOUCH ${CMAKE_BINARY_DIR}/drivers/platform/Kconfig) endif() +# board common directory + +if(CONFIG_ARCH_BOARD_COMMON) + file( + GLOB NUTTX_COMMON_DIR + LIST_DIRECTORIES true + "${NUTTX_DIR}/boards/${CONFIG_ARCH}/${CONFIG_ARCH_CHIP}/common") +endif() + # Custom chip ################################################### if(CONFIG_ARCH_CHIP_CUSTOM) @@ -521,6 +530,28 @@ endif() # Get linker script to use get_property(ldscript GLOBAL PROPERTY LD_SCRIPT) +# Pre-compile linker script +if(DEFINED PREPROCES) + get_filename_component(LD_SCRIPT_NAME ${ldscript} NAME) + set(LD_SCRIPT_TMP "${CMAKE_BINARY_DIR}/${LD_SCRIPT_NAME}.tmp") + + add_custom_command( + OUTPUT ${LD_SCRIPT_TMP} + DEPENDS ${ldscript} + COMMAND + ${PREPROCES} + -I${CMAKE_BINARY_DIR}/include + -I${NUTTX_CHIP_ABS_DIR} + ${ldscript} > ${LD_SCRIPT_TMP} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + + add_custom_target(ldscript_tmp DEPENDS ${LD_SCRIPT_TMP}) + add_dependencies(nuttx ldscript_tmp) + + set(ldscript ${LD_SCRIPT_TMP}) +endif() + # Perform link # Add empty source file to nuttx target since cmake requires at least one file @@ -703,10 +734,3 @@ if(NOT CONFIG_BUILD_FLAT) # TODO: could also merge elf binaries endif() - -if(CONFIG_ARCH_BOARD_COMMON) - file( - GLOB NUTTX_COMMON_DIR - LIST_DIRECTORIES true - "${NUTTX_DIR}/boards/${CONFIG_ARCH}/${CONFIG_ARCH_CHIP}/common") -endif() diff --git a/arch/arm/src/cmake/platform.cmake b/arch/arm/src/cmake/platform.cmake index a4261f6b20..e013f1c764 100644 --- a/arch/arm/src/cmake/platform.cmake +++ b/arch/arm/src/cmake/platform.cmake @@ -101,3 +101,5 @@ if(CONFIG_ARCH_COVERAGE) endif() set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES ${EXTRA_LIB}) + +set(PREPROCES ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} -E -P -x c)