build: add initial cmake build system

1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)

------------------

How to test

From within nuttx/. Configure:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja

(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja

This uses ninja generator (install with sudo apt install ninja-build). To build:

$ cmake --build build

menuconfig:

$ cmake --build build -t menuconfig

--------------------------

2. cmake/build: reformat the cmake style by cmake-format

https://github.com/cheshirekow/cmake_format

$ pip install cmakelang

$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done

Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-02-07 14:15:30 +08:00 committed by Xiang Xiao
parent 558fa503d0
commit 6ee9ec7656
317 changed files with 17032 additions and 1 deletions

697
CMakeLists.txt Normal file
View File

@ -0,0 +1,697 @@
# ##############################################################################
# CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# ~~~
# Instructions:
# - Run CMake from the user project directory:
# cmake -S <nuttx-dir> -B <build-directory> -DBOARD_CONFIG=<board>
# - NuttX will look for the nuttx-apps repository from its parent folder
# i.e., ../nuttx-apps.
# - A custom directory can be specified with -DNUTTX_APPS_DIR=<apps-dir>.
# - Build the user project with:
# cmake --build <build-dir>
# ~~~
# Request a version available on latest Ubuntu LTS (20.04)
cmake_minimum_required(VERSION 3.16)
# Handle newer CMake versions correctly by setting policies
if(POLICY CMP0115)
# do not auto-guess extension in target_sources()
cmake_policy(SET CMP0115 NEW)
endif()
# Basic CMake configuration ##################################################
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS OFF)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Setup build type (Debug Release RelWithDebInfo MinSizeRel Coverage). Default
# to minimum size release
# Use nuttx optimization configuration options, workaround for cmake build type
# TODO Integration the build type with CMAKE
# if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING
# "Build type" FORCE) endif() set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
# STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel")
# Process board config & directory locations #################################
set(NUTTX_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT DEFINED BOARD_CONFIG)
message(FATAL_ERROR "Please define configuration with BOARD_CONFIG")
endif()
if(EXISTS ${BOARD_CONFIG} AND EXISTS ${BOARD_CONFIG}/defconfig)
get_filename_component(NUTTX_BOARD_ABS_DIR ${BOARD_CONFIG} ABSOLUTE BASE_DIR
${NUTTX_DIR})
string(REPLACE "/" ";" CONFIG_ARRAY ${NUTTX_BOARD_ABS_DIR})
list(LENGTH CONFIG_ARRAY CONFIG_ARRAY_LENGTH)
if(${CONFIG_ARRAY_LENGTH} LESS 4)
message(FATAL_ERROR "Please define correct board config : ${BOARD_CONFIG}")
endif()
math(EXPR NUTTX_CONFIG_INDEX "${CONFIG_ARRAY_LENGTH} - 1")
math(EXPR NUTTX_BOARD_INDEX "${CONFIG_ARRAY_LENGTH} - 3")
list(GET CONFIG_ARRAY ${NUTTX_BOARD_INDEX} NUTTX_BOARD)
list(GET CONFIG_ARRAY ${NUTTX_CONFIG_INDEX} NUTTX_CONFIG)
string(REGEX REPLACE "(.*)/(.*)/${NUTTX_CONFIG}" "\\1" NUTTX_BOARD_DIR
${NUTTX_BOARD_ABS_DIR})
set(NUTTX_DEFCONFIG ${BOARD_CONFIG}/defconfig)
else()
if(BOARD_CONFIG MATCHES "/")
set(MATCH_REGEX "/")
else()
set(MATCH_REGEX ":")
endif()
string(REPLACE ${MATCH_REGEX} ";" CONFIG_ARRAY ${BOARD_CONFIG})
list(LENGTH CONFIG_ARRAY CONFIG_ARRAY_LENGTH)
if(${CONFIG_ARRAY_LENGTH} LESS 2)
message(FATAL_ERROR "Please define correct board config : ${BOARD_CONFIG}")
endif()
list(GET CONFIG_ARRAY 0 NUTTX_BOARD)
list(GET CONFIG_ARRAY 1 NUTTX_CONFIG)
file(
GLOB NUTTX_BOARD_DIR
LIST_DIRECTORIES true
"${NUTTX_DIR}/boards/*/*/${NUTTX_BOARD}")
if(EXISTS ${NUTTX_BOARD_DIR}/configs/${NUTTX_CONFIG}/defconfig)
set(NUTTX_DEFCONFIG ${NUTTX_BOARD_DIR}/configs/${NUTTX_CONFIG}/defconfig)
endif()
endif()
if("${NUTTX_CONFIG}" STREQUAL "")
message(FATAL_ERROR "Please define correct board config : ${NUTTX_CONFIG}")
endif()
if(NOT EXISTS "${NUTTX_DEFCONFIG}")
message(FATAL_ERROR "No config file found at ${NUTTX_DEFCONFIG}")
endif()
# Generate inital .config ###################################################
# This is needed right before any other configure step so that we can source
# Kconfig variables into CMake variables
# The following commands need these variables to be passed via environment
include(nuttx_kconfig)
nuttx_export_kconfig_by_value(${NUTTX_DEFCONFIG} "CONFIG_APPS_DIR")
if(NOT CONFIG_APPS_DIR)
if(EXISTS "${NUTTX_DIR}/../apps")
set(NUTTX_APPS_DIR "${NUTTX_DIR}/../apps")
elseif(EXISTS "${NUTTX_DIR}/../nuttx-apps")
set(NUTTX_APPS_DIR "${NUTTX_DIR}/../nuttx-apps")
else()
message(
WARNING
"apps/nuttx-apps directory is not found, use dummy directory instead")
set(NUTTX_APPS_DIR "${NUTTX_DIR}/dummy")
endif()
else()
set(NUTTX_APPS_DIR ${CONFIG_APPS_DIR})
set(CONFIG_APPS_DIR)
endif()
if(NOT EXISTS "${NUTTX_APPS_DIR}")
message(FATAL_ERROR "Application directory ${NUTTX_APPS_DIR} is not found")
endif()
get_filename_component(apps_dir ${NUTTX_APPS_DIR} NAME)
set(NUTTX_APPS_BINDIR "${CMAKE_BINARY_DIR}/${apps_dir}")
# Support not having application directory
if("${apps_dir}" STREQUAL "dummy")
file(MAKE_DIRECTORY ${NUTTX_APPS_BINDIR})
file(TOUCH ${NUTTX_APPS_BINDIR}/Kconfig)
endif()
set(ENV{PYTHONPYCACHEPREFIX} ${CMAKE_BINARY_DIR})
set(ENV{APPSDIR} ${NUTTX_APPS_DIR}) # TODO: support not having apps/
set(ENV{APPSBINDIR} ${NUTTX_APPS_BINDIR}) # TODO: support not having apps/
set(ENV{BINDIR} ${CMAKE_BINARY_DIR}) # TODO: support not having apps/
set(ENV{EXTERNALDIR} dummy) # TODO
set(ENV{DRIVERS_PLATFORM_DIR} dummy) # TODO
set(ENV{HOST_LINUX} n)
set(ENV{HOST_MACOS} n)
set(ENV{HOST_WINDOWS} n)
set(ENV{HOST_OTHER} n)
if(APPLE)
set(ENV{HOST_MACOS} y)
elseif(WIN32)
set(ENV{HOST_WINDOWS} y)
elseif(UNIX)
set(ENV{HOST_LINUX} y)
set(LINUX TRUE)
else()
set(ENV{HOST_OTHER} y)
set(OTHER_OS TRUE)
endif()
include(nuttx_parse_function_args)
include(nuttx_add_subdirectory)
include(nuttx_create_symlink)
# Add apps/ to the build (if present)
if(NOT EXISTS ${NUTTX_APPS_BINDIR}/Kconfig)
add_subdirectory(${NUTTX_APPS_DIR} preapps)
endif()
nuttx_export_kconfig(${NUTTX_DEFCONFIG})
if(CONFIG_ARCH_BOARD_CUSTOM)
get_filename_component(NUTTX_BOARD_DIR ${CONFIG_ARCH_BOARD_CUSTOM_DIR}
ABSOLUTE BASE_DIR ${NUTTX_DIR})
endif()
if("${NUTTX_BOARD_DIR}" STREQUAL "")
message(FATAL_ERROR "Please define correct board : ${NUTTX_BOARD_DIR}")
endif()
if(NOT EXISTS "${NUTTX_BOARD_DIR}/CMakeLists.txt"
AND NOT EXISTS "${NUTTX_BOARD_DIR}/../common/CMakeLists.txt")
message(FATAL_ERROR "No CMakeList.txt found at ${NUTTX_BOARD_DIR}")
endif()
# Custom board ###################################################
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/boards/dummy)
if(CONFIG_ARCH_BOARD_CUSTOM)
get_filename_component(NUTTX_BOARD_ABS_DIR ${CONFIG_ARCH_BOARD_CUSTOM_DIR}
ABSOLUTE BASE_DIR ${NUTTX_DIR})
else()
set(NUTTX_BOARD_ABS_DIR ${NUTTX_BOARD_DIR})
file(TOUCH ${CMAKE_BINARY_DIR}/boards/dummy/Kconfig)
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/boards/dummy/Kconfig)
if(CONFIG_ARCH_BOARD_CUSTOM)
nuttx_create_symlink(${NUTTX_BOARD_ABS_DIR}/Kconfig
${CMAKE_BINARY_DIR}/boards/dummy/Kconfig)
else()
file(TOUCH ${CMAKE_BINARY_DIR}/boards/dummy/Kconfig)
endif()
endif()
# board platfrom driver
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/drivers)
if(EXISTS ${NUTTX_BOARD_ABS_DIR}/../drivers
AND EXISTS ${NUTTX_BOARD_ABS_DIR}/../drivers/Kconfig)
nuttx_create_symlink(${NUTTX_BOARD_ABS_DIR}/../drivers
${CMAKE_BINARY_DIR}/drivers/platform)
else()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/drivers/platform)
file(TOUCH ${CMAKE_BINARY_DIR}/drivers/platform/Kconfig)
endif()
# Custom chip ###################################################
if(CONFIG_ARCH_CHIP_CUSTOM)
get_filename_component(NUTTX_CHIP_ABS_DIR ${CONFIG_ARCH_CHIP_CUSTOM_DIR}
ABSOLUTE BASE_DIR ${NUTTX_DIR})
set(NUTTX_CHIP_ABS_DIR ${NUTTX_CHIP_ABS_DIR})
else()
set(NUTTX_CHIP_ABS_DIR
"${NUTTX_DIR}/arch/${CONFIG_ARCH}/src/${CONFIG_ARCH_CHIP}")
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/arch/dummy)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/arch/dummy)
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/arch/dummy/Kconfig)
if(CONFIG_ARCH_CHIP_CUSTOM)
nuttx_create_symlink(${NUTTX_CHIP_ABS_DIR}/Kconfig
${CMAKE_BINARY_DIR}/arch/dummy/Kconfig)
else()
file(TOUCH ${CMAKE_BINARY_DIR}/arch/dummy/Kconfig)
endif()
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/arch/${CONFIG_ARCH})
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/arch/${CONFIG_ARCH})
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/arch/${CONFIG_ARCH}/src)
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/arch/${CONFIG_ARCH}/src/chip)
nuttx_create_symlink(${NUTTX_CHIP_ABS_DIR}
${CMAKE_BINARY_DIR}/arch/${CONFIG_ARCH}/src/chip)
endif()
# Unsupport custom board/chips yet, workaround
if(NOT EXISTS ${NUTTX_APPS_BINDIR}/platform/board/Kconfig)
file(MAKE_DIRECTORY ${NUTTX_APPS_BINDIR}/platform/board)
file(TOUCH ${NUTTX_APPS_BINDIR}/platform/board/Kconfig)
endif()
# Copy board defconfig into main directory and expand TODO: do also for changes
# in board/config (by comparing stored defconfig to specified one)
if(NOT EXISTS ${CMAKE_BINARY_DIR}/.config OR NOT "${NUTTX_DEFCONFIG}" STREQUAL
"${NUTTX_DEFCONFIG_SAVED}")
message(STATUS "Initializing NuttX")
configure_file(${NUTTX_DEFCONFIG} defconfig COPYONLY)
configure_file(${NUTTX_DEFCONFIG} .config.compressed COPYONLY)
set(ENV{KCONFIG_CONFIG} ${CMAKE_BINARY_DIR}/.config.compressed)
# Do olddefconfig step to expand the abbreviated defconfig into normal config
execute_process(
COMMAND olddefconfig
OUTPUT_VARIABLE KCONFIG_OUTPUT
RESULT_VARIABLE KCONFIG_STATUS
WORKING_DIRECTORY ${NUTTX_DIR})
file(RENAME ${CMAKE_BINARY_DIR}/.config.compressed
${CMAKE_BINARY_DIR}/.config)
set(ENV{KCONFIG_CONFIG} ${CMAKE_BINARY_DIR}/.config)
# store original expanded .config
configure_file(${CMAKE_BINARY_DIR}/.config ${CMAKE_BINARY_DIR}/.config.orig
COPYONLY)
if(KCONFIG_STATUS AND NOT KCONFIG_STATUS EQUAL 0)
message(
FATAL_ERROR
"Failed to initialize Kconfig configuration: ${KCONFIG_OUTPUT}")
endif()
set(NUTTX_DEFCONFIG_SAVED
${NUTTX_DEFCONFIG}
CACHE INTERNAL "Saved defconfig path" FORCE)
# Print configuration choices
message(STATUS " Board: ${NUTTX_BOARD}")
message(STATUS " Config: ${NUTTX_CONFIG}")
message(STATUS " Appdir: ${NUTTX_APPS_DIR}")
endif()
# Include .cmake files #######################################################
# this exposes all Kconfig vars to CMake
nuttx_export_kconfig(${CMAKE_BINARY_DIR}/.config)
include(nuttx_generate_headers)
include(nuttx_generate_outputs)
include(nuttx_add_library)
include(nuttx_add_application)
include(nuttx_add_romfs)
include(nuttx_add_symtab)
include(nuttx_add_module)
include(menuconfig)
include(ExternalProject)
include(FetchContent)
set(FETCHCONTENT_QUIET OFF)
# Setup toolchain ############################################################
# This needs to happen before project() when binaries are searched for
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/arch/${CONFIG_ARCH}/src/cmake)
set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_SOURCE_DIR}/arch/${CONFIG_ARCH}/src/cmake/Toolchain.cmake")
# Define project #############################################################
# This triggers configuration
project(NuttX LANGUAGES C CXX ASM)
if(WIN32)
enable_language(ASM_MASM)
endif()
# Setup platform options (this needs to happen after project(), once the
# toolchain file has been processed)
include(platform)
# Setup main nuttx target ####################################################
add_executable(nuttx)
add_dependencies(nuttx nuttx_context)
if(WIN32)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT
nuttx)
endif()
if(CONFIG_ARCH_SIM)
# Create separate sim_head OBJECT library built as part of NuttX kernel It
# must be separated to allow for linking against the rest of NuttX libraries
add_library(sim_head OBJECT)
nuttx_add_library_internal(sim_head)
get_property(
definitions
TARGET nuttx
PROPERTY NUTTX_KERNEL_DEFINITIONS)
target_compile_definitions(sim_head PRIVATE ${definitions})
get_property(
options
TARGET nuttx
PROPERTY NUTTX_KERNEL_COMPILE_OPTIONS)
target_compile_options(sim_head PRIVATE ${options})
# We need the relocatable object to be first in the list of libraries to be
# linked against final nuttx binary
if(NOT WIN32)
target_link_libraries(nuttx PRIVATE ${CMAKE_BINARY_DIR}/nuttx.rel)
endif()
else()
# These flags apply to source files not part of the library. In sim build this
# corresponds to "host" files, so we only do this on non-sim build
target_compile_definitions(
nuttx
PRIVATE $<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_COMPILE_DEFINITIONS>>)
target_compile_options(
nuttx PRIVATE $<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_COMPILE_OPTIONS>>)
endif()
# Compiler options TODO: move elsewhere
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.9)
# force color for gcc > 4.9
add_compile_options(-fdiagnostics-color=always)
endif()
endif()
if(WIN32)
add_compile_options(
-W2
-wd4116 # unnamed type definition in parentheses
-wd4146 # unary minus operator applied to unsigned type, result still
# unsigned
-wd4244 # 'argument' : conversion from 'type1' to 'type2', possible loss of
# data
-wd4305 # 'context' : truncation from 'type1' to 'type2'
)
else()
add_compile_options(
# system wide warnings
-Wall
$<$<COMPILE_LANGUAGE:C>:-Wstrict-prototypes>
-Wshadow
-Wundef
# system wide options
$<$<COMPILE_LANGUAGE:CXX>:-nostdinc++>
$<$<COMPILE_LANGUAGE:ASM>:-D__ASSEMBLY__>)
endif()
if(NOT CONFIG_CXX_EXCEPTION)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
$<$<COMPILE_LANGUAGE:CXX>:-fcheck-new>)
endif()
if(CONFIG_STACK_CANARIES)
add_compile_options(-fstack-protector-all)
endif()
if(CONFIG_NDEBUG)
add_compile_options(-DNDEBUG)
endif()
add_definitions(-D__NuttX__)
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_KERNEL_DEFINITIONS __KERNEL__)
# Recurse subdirectories #####################################################
# Each subdirectory will generate a static library
if(CONFIG_OPENAMP)
include_directories(${CMAKE_SOURCE_DIR}/openamp/open-amp/lib/include)
endif()
add_subdirectory(openamp)
add_subdirectory(arch)
add_subdirectory(audio)
add_subdirectory(binfmt)
add_subdirectory(drivers)
add_subdirectory(fs)
add_subdirectory(graphics)
add_subdirectory(libs)
add_subdirectory(mm)
add_subdirectory(net)
add_subdirectory(sched)
add_subdirectory(syscall)
add_subdirectory(wireless)
# This picks up the chosen board (as well as common board code)
add_subdirectory(boards)
# POSTBUILD -- Perform post build operations Some architectures require the use
# of special tools and special handling AFTER building the NuttX binary.
# Make.defs files for those architectures should override the following define
# with the correct operations for that platform
if(TARGET nuttx_post_build)
add_custom_target(post_build ALL DEPENDS nuttx_post_build)
endif()
# Add apps/ to the build (if present)
if(EXISTS ${NUTTX_APPS_DIR}/CMakeLists.txt)
add_subdirectory(${NUTTX_APPS_DIR} apps)
else()
message(
STATUS "Application directory not found at ${NUTTX_APPS_DIR}, skipping")
endif()
# Link step ##################################################################
# Get linker script to use
get_property(ldscript GLOBAL PROPERTY LD_SCRIPT)
# Perform link
# Add empty source file to nuttx target since cmake requires at least one file
# and we will only be linking libraries
if(CONFIG_HAVE_CXX)
file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/empty.cxx")
target_sources(nuttx PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/empty.cxx")
else()
file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/empty.c")
target_sources(nuttx PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/empty.c")
endif()
# initialize manifest to hold all generated files
file(TOUCH ${CMAKE_BINARY_DIR}/nuttx.manifest)
get_property(nuttx_kernel_libs GLOBAL PROPERTY NUTTX_KERNEL_LIBRARIES)
if(CONFIG_BUILD_FLAT)
get_property(nuttx_system_libs GLOBAL PROPERTY NUTTX_SYSTEM_LIBRARIES)
endif()
get_property(nuttx_apps_libs GLOBAL PROPERTY NUTTX_APPS_LIBRARIES)
get_property(nuttx_extra_libs GLOBAL PROPERTY NUTTX_EXTRA_LIBRARIES)
set(nuttx_libs ${nuttx_kernel_libs} ${nuttx_system_libs} ${nuttx_apps_libs}
${nuttx_extra_libs})
if(NOT CONFIG_ARCH_SIM)
# TODO: nostart/nodefault not applicable to nuttx toolchain
target_link_libraries(
nuttx PRIVATE ${NUTTX_EXTRA_FLAGS} -Wl,--script=${ldscript}
-Wl,--start-group ${nuttx_libs} -Wl,--end-group)
# generate binary outputs in different formats (.bin, .hex, etc)
nuttx_generate_outputs(nuttx)
if(CONFIG_UBOOT_UIMAGE)
add_custom_command(
OUTPUT uImage
COMMAND
${MKIMAGE} -A ${CONFIG_ARCH} -O linux -C none -T kernel -a
${CONFIG_UIMAGE_LOAD_ADDRESS} -e ${CONFIG_UIMAGE_ENTRY_POINT} -n nuttx
-d nuttx.bin uImage
DEPENDS nuttx)
add_custom_target(nuttx-uImage ALL DEPENDS uImage)
# TODO: install? $(Q) if [ -w /tftpboot ] ; then \ cp -f uImage
# /tftpboot/uImage; \ fi
file(APPEND ${CMAKE_BINARY_DIR}/nuttx.manifest uImage)
endif()
elseif(WIN32)
target_link_options(nuttx PUBLIC /SAFESEH:NO)
set(nuttx_libs_paths)
foreach(lib ${nuttx_libs})
list(APPEND nuttx_libs_paths $<TARGET_FILE:${lib}>)
endforeach()
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/nuttx_all.lib
COMMAND ${CMAKE_AR} /OUT:${CMAKE_BINARY_DIR}/nuttx_all.lib
${nuttx_libs_paths}
DEPENDS ${nuttx_libs}
VERBATIM)
add_custom_target(nuttx_all-lib DEPENDS ${CMAKE_BINARY_DIR}/nuttx_all.lib)
add_dependencies(nuttx nuttx_all-lib)
target_link_libraries(nuttx PRIVATE $<TARGET_OBJECTS:sim_head>
${CMAKE_BINARY_DIR}/nuttx_all.lib)
else()
# On sim platform the link step is a little different. NuttX is first built
# into a partially linked relocatable object nuttx.rel with no interface to
# host OS. Then, the names of symbols that conflict with libc symbols are
# renamed. The final nuttx binary is built by linking the host-specific
# objects with the relocatable binary.
# C++ global objects are constructed before main get executed, but it isn't a
# good point for simulator because NuttX doesn't finish the kernel
# initialization yet. So we have to skip the standard facilities and do the
# construction by ourself. But how to achieve the goal? 1.Command linker
# generate the default script(-verbose) 2.Replace
# __init_array_start/__init_array_end with _sinit/_einit 3.Append
# __init_array_start = .; __init_array_end = .; Step 2 let nxtask_startup find
# objects need to construct Step 3 cheat the host there is no object to
# construct Note: the destructor can be fixed in the same way.
if(NOT APPLE)
add_custom_command(
OUTPUT nuttx.ld
COMMAND
${CMAKE_C_COMPILER} ${CMAKE_EXE_LINKER_FLAGS}
$<$<BOOL:${CONFIG_SIM_M32}>:-m32> -Wl,-verbose 2> /dev/null >
nuttx-orig.ld || true
COMMAND
cat nuttx-orig.ld | sed -e '/====/,/====/!d\;//d' -e
's/__executable_start/_stext/g' -e 's/__init_array_start/_sinit/g' -e
's/__init_array_end/_einit/g' -e 's/__fini_array_start/_sfini/g' -e
's/__fini_array_end/_efini/g' > nuttx.ld
COMMAND
echo ARGS
'__init_array_start = .\; __init_array_end = .\; __fini_array_start = .\; __fini_array_end = .\;'
>> nuttx.ld)
endif()
# conflicting symbols to rename
include(nuttx_redefine_symbols)
# TODO: do with single function call?
set(nuttx_libs_paths)
foreach(lib ${nuttx_libs})
list(APPEND nuttx_libs_paths $<TARGET_FILE:${lib}>)
endforeach()
add_custom_command(
OUTPUT nuttx.rel
COMMAND
${CMAKE_C_COMPILER} ARGS -r $<$<BOOL:${CONFIG_SIM_M32}>:-m32>
$<TARGET_OBJECTS:sim_head> $<$<NOT:$<BOOL:${APPLE}>>:-Wl,--start-group>
${nuttx_libs_paths} $<$<NOT:$<BOOL:${APPLE}>>:-Wl,--end-group> -o
nuttx.rel
COMMAND ${CMAKE_OBJCOPY} --redefine-syms=nuttx-names.dat nuttx.rel
DEPENDS ${nuttx_libs_paths} sim_head
COMMAND_EXPAND_LISTS)
add_custom_target(nuttx-rel DEPENDS nuttx.rel
$<$<NOT:$<BOOL:${APPLE}>>:nuttx.ld>)
# link the final nuttx binary
add_dependencies(nuttx nuttx-rel)
target_link_options(nuttx PUBLIC $<$<NOT:$<BOOL:${APPLE}>>:-T nuttx.ld>
$<$<BOOL:${CONFIG_SIM_M32}>:-m32>)
endif()
# TODO: if we use an install target a manifest may not be needed
if(CONFIG_ARCH_SIM)
file(APPEND ${CMAKE_BINARY_DIR}/nuttx.manifest "nuttx\n")
endif()
# Userspace portion ##########################################################
if(NOT CONFIG_BUILD_FLAT)
add_executable(nuttx_user)
get_property(nuttx_system_libs GLOBAL PROPERTY NUTTX_SYSTEM_LIBRARIES)
get_property(user_ldscript GLOBAL PROPERTY LD_SCRIPT_USER)
list(TRANSFORM user_ldscript PREPEND "-Wl,--script=")
target_link_options(
nuttx_user PRIVATE -nostartfiles -nodefaultlibs
-Wl,--entry=${CONFIG_USER_ENTRYPOINT}
-Wl,--undefined=${CONFIG_USER_ENTRYPOINT})
target_link_libraries(
nuttx_user
PRIVATE ${user_ldscript}
userspace
$<$<NOT:$<BOOL:${APPLE}>>:-Wl,--start-group>
${nuttx_system_libs}
gcc
$<$<BOOL:${CONFIG_HAVE_CXX}>:supc++>
$<$<NOT:$<BOOL:${APPLE}>>:-Wl,--end-group>)
add_custom_command(
OUTPUT User.map
COMMAND ${CMAKE_NM} nuttx_user > User.map
DEPENDS nuttx_user)
add_custom_target(usermap ALL DEPENDS User.map)
# generate binary outputs in different formats (.bin, .hex, etc)
nuttx_generate_outputs(nuttx_user)
# create merged .hex file ready to be flashed TODO: does not seem to be
# generating a functional hex file
if(CONFIG_INTELHEX_BINARY AND SREC_CAT)
add_custom_command(
OUTPUT nuttx_combined.hex
COMMAND ${SREC_CAT} nuttx.hex -intel nuttx_user.hex -intel -o
nuttx_combined.hex -intel
DEPENDS nuttx_user nuttx)
add_custom_target(nuttx-combined ALL DEPENDS nuttx_combined.hex)
endif()
# TODO: could also merge elf binaries
endif()

37
arch/CMakeLists.txt Normal file
View File

@ -0,0 +1,37 @@
# ##############################################################################
# arch/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# Declare arch library. In contrast to other user/kernel pairs built in KERNEL
# mode, on arch/ the "user" portion uses a different set of sources than the
# kernel portion. To keep things simple the naming k<lib> is not used. Instead,
# the "user" portion is named "arch_interface".
nuttx_add_kernel_library(arch)
target_include_directories(arch PRIVATE ${CMAKE_SOURCE_DIR}/sched)
if(NOT CONFIG_BUILD_FLAT)
nuttx_add_system_library(arch_interface)
target_include_directories(arch_interface PRIVATE ${CMAKE_SOURCE_DIR}/sched)
endif()
# TODO: move this higher up ifeq ($(CONFIG_SCHED_INSTRUMENTATION_SYSCALL),y)
# EXTRALINKCMDS += @$(TOPDIR)/syscall/syscall_wraps.ldcmd endif
# include corresponding arch subdirectory
add_subdirectory(${CONFIG_ARCH})

21
arch/arm/CMakeLists.txt Normal file
View File

@ -0,0 +1,21 @@
# ##############################################################################
# arch/arm/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
nuttx_add_subdirectory()

View File

@ -0,0 +1,33 @@
# ##############################################################################
# arch/arm/src/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_subdirectory(common)
add_subdirectory(${ARCH_SUBDIR})
add_subdirectory(${NUTTX_CHIP_ABS_DIR} EXCLUDE_FROM_ALL exclude_chip)
# Include directories (before system ones) as PUBLIC so that it can be exposed
# to libboard
target_include_directories(arch BEFORE PUBLIC ${NUTTX_CHIP_ABS_DIR} common
${ARCH_SUBDIR})
if(NOT CONFIG_BUILD_FLAT)
target_include_directories(arch_interface BEFORE PUBLIC ${NUTTX_CHIP_ABS_DIR}
common ${ARCH_SUBDIR})
endif()

View File

@ -0,0 +1,110 @@
# ##############################################################################
# arch/arm/src/armv7-a/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# The vector table is the "head" object, i.e., the one that must forced into the
# link in order to draw in all of the other components
set(SRCS arm_vectortab.S)
# Common assembly language files
list(APPEND SRCS arm_cpuhead.S arm_vectoraddrexcptn.S arm_vectors.S
arm_saveusercontext.S)
# Common C source files
list(
APPEND
SRCS
arm_cache.c
arm_cpuinfo.c
arm_dataabort.c
arm_doirq.c
arm_gicv2.c
arm_gicv2_dump.c
arm_initialstate.c
arm_mmu.c
arm_prefetchabort.c
arm_schedulesigaction.c
arm_sigdeliver.c
arm_syscall.c
arm_tcbinfo.c
arm_undefinedinsn.c
arm_perf.c
cp15_cacheops.c)
if(CONFIG_ARMV7A_HAVE_PTM)
list(APPEND SRCS arm_timer.c)
endif()
if(CONFIG_ARMV7A_L2CC_PL310)
list(APPEND SRCS arm_l2cc_pl310.c)
endif()
if(CONFIG_PAGING)
list(
APPEND
SRCS
arm_allocpage.c
arm_checkmapping.c
arm_pginitialize.c
arm_va2pte.c
arm_pghead.S)
else()
list(APPEND SRCS arm_head.S)
endif()
if(CONFIG_ARCH_ADDRENV)
list(APPEND SRCS arm_addrenv.c arm_addrenv_utils.c arm_addrenv_perms.c
arm_pgalloc.c)
if(CONFIG_ARCH_STACK_DYNAMIC)
list(APPEND SRCS arm_addrenv_ustack.c)
endif()
if(CONFIG_ARCH_KERNEL_STACK)
list(APPEND SRCS arm_addrenv_kstack.c)
endif()
if(CONFIG_ARCH_VMA_MAPPING)
list(APPEND SRCS arm_addrenv_shm.c)
endif()
endif()
if(CONFIG_MM_PGALLOC)
list(APPEND SRCS arm_physpgaddr.c)
if(CONFIG_ARCH_PGPOOL_MAPPING)
list(APPEND SRCS arm_virtpgaddr.c)
endif()
endif()
if(CONFIG_ARCH_FPU)
list(APPEND SRCS arm_fpucmp.c arm_fpuconfig.S)
endif()
if(CONFIG_SMP)
list(
APPEND
SRCS
arm_cpuindex.c
arm_cpustart.c
arm_cpupause.c
arm_cpuidlestack.c
arm_scu.c)
endif()
target_sources(arch PRIVATE ${SRCS})

View File

@ -0,0 +1,68 @@
# ##############################################################################
# arch/arm/src/armv7-m/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# TODO: do not use config to detect this
set(SRCS
arm_exception.S
arm_saveusercontext.S
arm_busfault.c
arm_cache.c
arm_cpuinfo.c
arm_doirq.c
arm_hardfault.c
arm_initialstate.c
arm_itm.c
arm_memfault.c
arm_perf.c
arm_schedulesigaction.c
arm_sigdeliver.c
arm_svcall.c
arm_systemreset.c
arm_tcbinfo.c
arm_trigger_irq.c
arm_usagefault.c
arm_vectors.c)
if(CONFIG_ARMV7M_SYSTICK)
list(APPEND SRCS arm_systick.c)
endif()
if(CONFIG_ARMV7M_ITMSYSLOG)
list(APPEND SRCS arm_itm_syslog.c)
endif()
if(CONFIG_ARMV7M_STACKCHECK)
list(APPEND SRCS arm_stackcheck.c)
endif()
if(CONFIG_ARCH_FPU)
list(APPEND SRCS arm_fpuconfig.c arm_fpucmp.c)
endif()
if(CONFIG_ARCH_RAMVECTORS)
list(APPEND SRCS arm_ramvec_initialize.c arm_ramvec_attach.c)
endif()
if(CONFIG_ARM_MPU OR CONFIG_ARM_MPU_EARLY_RESET)
list(APPEND SRCS arm_mpu.c)
endif()
target_sources(arch PRIVATE ${SRCS})

View File

@ -0,0 +1,69 @@
# ##############################################################################
# arch/arm/src/armv8-m/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS
arm_exception.S
arm_saveusercontext.S
arm_busfault.c
arm_cache.c
arm_cpuinfo.c
arm_doirq.c
arm_hardfault.c
arm_initialstate.c
arm_itm.c
arm_memfault.c
arm_perf.c
arm_sau.c
arm_schedulesigaction.c
arm_securefault.c
arm_secure_irq.c
arm_sigdeliver.c
arm_svcall.c
arm_systemreset.c
arm_tcbinfo.c
arm_trigger_irq.c
arm_usagefault.c
arm_vectors.c)
if(CONFIG_ARMV8M_SYSTICK)
list(APPEND SRCS arm_systick.c)
endif()
if(CONFIG_ARMV8M_ITMSYSLOG)
list(APPEND SRCS arm_itm_syslog.c)
endif()
if(CONFIG_ARMV8M_STACKCHECK)
list(APPEND SRCS arm_stackcheck.c)
endif()
if(CONFIG_ARCH_FPU)
list(APPEND SRCS arm_fpuconfig.c arm_fpucmp.c)
endif()
if(CONFIG_ARCH_RAMVECTORS)
list(APPEND SRCS arm_ramvec_initialize.c arm_ramvec_attach.c)
endif()
if(CONFIG_ARM_MPU OR CONFIG_ARM_MPU_EARLY_RESET)
list(APPEND SRCS arm_mpu.c)
endif()
target_sources(arch PRIVATE ${SRCS})

View File

@ -0,0 +1,217 @@
# ##############################################################################
# arch/arm/src/cmake/Toolchain.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# Toolchain
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
set(ARCH_SUBDIR)
if(CONFIG_ARCH_ARMV7A) # ARMv7-A
set(ARCH_SUBDIR armv7-a)
elseif(CONFIG_ARCH_ARMV7R) # ARMv7-R
set(ARCH_SUBDIR armv7-r)
elseif(CONFIG_ARCH_ARMV7M) # ARMv7-M
set(ARCH_SUBDIR armv7-m)
elseif(CONFIG_ARCH_ARMV8M) # ARMv8-M
set(ARCH_SUBDIR armv8-m)
elseif(CONFIG_ARCH_ARMV6M) # ARMv6-M
set(ARCH_SUBDIR armv6-m)
else() # ARM9, ARM7TDMI, etc.
set(ARCH_SUBDIR arm)
endif()
include(${ARCH_SUBDIR})
if(CONFIG_ARCH_TOOLCHAIN_CLANG)
set(CMAKE_ASM_COMPILER clang)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_STRIP llvm-strip --strip-unneeded)
set(CMAKE_OBJCOPY llvm-objcopy)
set(CMAKE_OBJDUMP llvm-objdump)
set(CMAKE_LINKER ld.lld)
set(CMAKE_LD ld.lld)
set(CMAKE_AR llvm-ar)
set(CMAKE_NM llvm-nm)
set(CMAKE_RANLIB llvm-ranlib)
# Since the no_builtin attribute is not fully supported on Clang disable the
# built-in functions, refer:
# https://github.com/apache/incubator-nuttx/pull/5971
add_compile_options(-fno-builtin)
else()
set(TOOLCHAIN_PREFIX arm-none-eabi)
set(CMAKE_LIBRARY_ARCHITECTURE ${TOOLCHAIN_PREFIX})
set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN_PREFIX})
set(CMAKE_CXX_COMPILER_TARGET ${TOOLCHAIN_PREFIX})
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}-strip --strip-unneeded)
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}-objcopy)
set(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}-objdump)
if(CONFIG_LTO_FULL AND CONFIG_ARCH_TOOLCHAIN_GNU)
set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_LD ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_AR ${TOOLCHAIN_PREFIX}-gcc-ar)
set(CMAKE_NM ${TOOLCHAIN_PREFIX}-gcc-nm)
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}-gcc-ranlib)
else()
set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}-ld)
set(CMAKE_LD ${TOOLCHAIN_PREFIX}-ld)
set(CMAKE_AR ${TOOLCHAIN_PREFIX}-ar)
set(CMAKE_NM ${TOOLCHAIN_PREFIX}-nm)
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}-ranlib)
endif()
endif()
# override the ARCHIVE command
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> rcs -o <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE
"<CMAKE_AR> rcs -o <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_ASM_ARCHIVE_CREATE
"<CMAKE_AR> rcs -o <TARGET> <LINK_FLAGS> <OBJECTS>")
# Architecture flags
add_link_options(--entry=__start)
add_link_options(-nostdlib)
add_compile_options(-fno-common)
add_compile_options(-Wall -Wshadow -Wundef)
add_compile_options(-nostdlib)
if(CONFIG_ARM_THUMB)
add_compile_options(-mthumb)
# GCC Manual: -mthumb ... If you want to force assembler files to be
# interpreted as Thumb code, either add a `.thumb' directive to the source or
# pass the -mthumb option directly to the assembler by prefixing it with -Wa.
add_compile_options(-Wa,-mthumb)
# Outputs an implicit IT block when there is a conditional instruction without
# an enclosing IT block.
add_compile_options(-Wa,-mimplicit-it=always)
endif()
if(CONFIG_UNWINDER_ARM)
add_compile_options(-funwind-tables -fasynchronous-unwind-tables)
endif()
if(CONFIG_DEBUG_CUSTOMOPT)
add_compile_options(${CONFIG_DEBUG_OPTLEVEL})
elseif(CONFIG_DEBUG_FULLOPT)
if(CONFIG_ARCH_TOOLCHAIN_CLANG)
add_compile_options(-Oz)
else()
add_compile_options(-Os)
endif()
endif()
if(NOT CONFIG_DEBUG_NOOPT)
add_compile_options(-fno-strict-aliasing)
endif()
if(CONFIG_FRAME_POINTER)
add_compile_options(-fno-omit-frame-pointer -fno-optimize-sibling-calls)
else()
add_compile_options(-fomit-frame-pointer)
endif()
if(CONFIG_STACK_CANARIES)
add_compile_options(-fstack-protector-all)
endif()
if(CONFIG_ARCH_COVERAGE)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()
# Optimization of unused sections
if(CONFIG_DEBUG_OPT_UNUSED_SECTIONS)
add_link_options(-Wl,--gc-sections)
add_compile_options(-ffunction-sections -fdata-sections)
endif()
if(CONFIG_ENDIAN_BIG)
add_compile_options(-mbig-endian)
endif()
# Link Time Optimization
if(CONFIG_LTO_THIN)
add_compile_options(-flto=thin)
elseif(CONFIG_LTO_FULL)
add_compile_options(-flto)
if(CONFIG_ARCH_TOOLCHAIN_GNU)
add_compile_options(-fno-builtin)
add_compile_options(-fuse-linker-plugin)
endif()
endif()
# Debug link map
if(CONFIG_DEBUG_LINK_MAP)
add_link_options(-Wl,--cref -Wl,-Map=nuttx.map)
endif()
if(CONFIG_DEBUG_SYMBOLS)
add_compile_options(-g)
endif()
set(ARCHCFLAGS "-Wstrict-prototypes")
set(ARCHCXXFLAGS "-nostdinc++")
if(CONFIG_CXX_EXCEPTION)
string(APPEND ARCHCXXFLAGS " -fno-exceptions -fcheck-new")
endif()
if(CONFIG_CXX_RTTI)
string(APPEND ARCHCXXFLAGS " -fno-rtti")
endif()
if(NOT "${CMAKE_C_FLAGS}" STREQUAL "")
string(REGEX MATCH "${ARCHCFLAGS}" EXISTS_FLAGS "${CMAKE_C_FLAGS}")
endif()
if(NOT EXISTS_FLAGS)
set(CMAKE_ASM_FLAGS
"${CMAKE_ASM_FLAGS}${ARCHCFLAGS}"
CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS}${ARCHCFLAGS}"
CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS}${ARCHCXXFLAGS}"
CACHE STRING "" FORCE)
endif()
if(CONFIG_ARCH_TOOLCHAIN_CLANG)
set(CMAKE_EXE_LINKER_FLAGS_INIT "-c")
else()
set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs")
endif()

View File

@ -0,0 +1,19 @@
# ##############################################################################
# arch/arm/src/cmake/arm.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################

View File

@ -0,0 +1,21 @@
# ##############################################################################
# arch/arm/src/cmake/armv6-m.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_compile_options(-mcpu=cortex-m0 -mthumb -mfloat-abi=soft)

View File

@ -0,0 +1,68 @@
# ##############################################################################
# arch/arm/src/cmake/armv7-a.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(PLATFORM_FLAGS)
if(CONFIG_ARCH_CORTEXA5)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a5)
elseif(CONFIG_ARCH_CORTEXA7)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a7)
elseif(CONFIG_ARCH_CORTEXA8)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a8)
elseif(CONFIG_ARCH_CORTEXA9)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-a9)
endif()
if(NOT CONFIG_ARM_DPFPU32)
set(ARCHFPUD16 -d16)
endif()
# Cortex-A5 | -mfpu=vfpv4-fp16 | -mfpu=vfpv4-d16-fp16 | -mfpu=neon-fp16
# Cortex-A7 | -mfpu=vfpv4 | -mfpu=vfpv4-d16 | -mfpu=neon-vfpv4
# Cortex-A8 | -mfpu=vfpv3 | | -mfpu=neon (alias for
# neon-vfpv3) Cortex-A9 | -mfpu=vfpv3-fp16 | -mfpu=vfpv3-d16-fp16 |
# -mfpu=neon-fp16 Cortex-A15 | -mfpu=vfpv4 | |
# -mfpu=neon-vfpv4
if(CONFIG_ARCH_FPU)
if(CONFIG_ARM_FPU_ABI_SOFT)
list(APPEND PLATFORM_FLAGS -mfloat-abi=softfp)
else()
list(APPEND PLATFORM_FLAGS -mfloat-abi=hard)
endif()
if(CONFIG_ARM_NEON)
set(ARCHNEON neon-)
endif()
if(CONFIG_ARCH_CORTEXA8)
set(ARCHFPU vfpv3)
elseif(CONFIG_ARCH_CORTEXA9)
set(ARCHFPU vfpv3)
else()
set(ARCHFPU vfpv4)
endif()
list(APPEND PLATFORM_FLAGS -mfpu=${ARCHNEON}${ARCHFPU}${ARCHFPUD16})
else()
list(APPEND PLATFORM_FLAGS -mfloat-abi=soft)
endif()
add_compile_options(${PLATFORM_FLAGS})

View File

@ -0,0 +1,93 @@
# ##############################################################################
# arch/arm/src/cmake/armv7-m.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(PLATFORM_FLAGS)
if(CONFIG_ARCH_CORTEXM4)
list(APPEND PLATFORM_FLAGS -mtune=cortex-m4 -march=armv7e-m)
if(CONFIG_ARCH_FPU)
list(APPEND PLATFORM_FLAGS -mfpu=fpv4-sp-d16)
endif()
elseif(CONFIG_ARCH_CORTEXM7)
list(APPEND PLATFORM_FLAGS -mtune=cortex-m7 -march=armv7e-m)
if(CONFIG_ARCH_FPU)
if(CONFIG_ARCH_DPFPU)
list(APPEND PLATFORM_FLAGS -mfpu=fpv5-d16)
else()
list(APPEND PLATFORM_FLAGS -mfpu=fpv5-sp-d16)
endif()
endif()
else()
list(APPEND PLATFORM_FLAGS -mtune=cortex-m3 -march=armv7-m -mfloat-abi=soft)
endif()
if(CONFIG_ARCH_FPU)
if(CONFIG_ARM_FPU_ABI_SOFT)
list(APPEND PLATFORM_FLAGS -mfloat-abi=softfp)
else()
list(APPEND PLATFORM_FLAGS -mfloat-abi=hard)
endif()
else()
list(APPEND PLATFORM_FLAGS -mfloat-abi=soft)
endif()
# Clang Configuration files
if(CONFIG_ARCH_TOOLCHAIN_CLANG)
set(ARCHFLAGS)
if(CONFIG_ARCH_CORTEXM4)
if(CONFIG_ARCH_FPU)
string(APPEND ARCHFLAGS "--config armv7em_hard_fpv4_sp_d16_nosys")
else()
string(APPEND ARCHFLAGS "--config armv7em_soft_nofp_nosys")
endif()
elseif(CONFIG_ARCH_CORTEXM7)
if(CONFIG_ARCH_FPU)
string(APPEND ARCHFLAGS "--config armv7em_hard_fpv5_d16_nosys")
else()
string(APPEND ARCHFLAGS "--config armv7em_soft_nofp_nosys")
endif()
else()
string(APPEND ARCHFLAGS "--config armv7em_soft_nofp_nosys")
endif()
if(NOT "${CMAKE_C_FLAGS}" STREQUAL "" AND NOT "${ARCHFLAGS}" STREQUAL "")
string(REGEX MATCH "${ARCHFLAGS}" EXISTS_FLAGS "${CMAKE_C_FLAGS}")
endif()
if(NOT EXISTS_FLAGS)
set(CMAKE_ASM_FLAGS
"${CMAKE_ASM_FLAGS}${ARCHFLAGS}"
CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS}${ARCHFLAGS}"
CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS}${ARCHFLAGS}"
CACHE STRING "" FORCE)
endif()
endif()
if(CONFIG_ARMV7M_STACKCHECK)
list(APPEND PLATFORM_FLAGS -finstrument-functions -ffixed-r10)
endif()
add_compile_options(${PLATFORM_FLAGS})

View File

@ -0,0 +1,42 @@
# ##############################################################################
# arch/arm/src/cmake/armv7-r.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(PLATFORM_FLAGS)
if(CONFIG_ARCH_CORTEXR4)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-r4)
elseif(CONFIG_ARCH_CORTEXR5)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-r5)
elseif(CONFIG_ARCH_CORTEXR7)
list(APPEND PLATFORM_FLAGS -mcpu=cortex-r7)
endif()
if(CONFIG_ARCH_FPU)
list(APPEND PLATFORM_FLAGS -mfpu=vfpv3-d16)
if(CONFIG_ARM_FPU_ABI_SOFT)
list(APPEND PLATFORM_FLAGS -mfloat-abi=softfp)
else()
list(APPEND PLATFORM_FLAGS -mfloat-abi=hard)
endif()
else()
list(APPEND PLATFORM_FLAGS -mfloat-abi=soft)
endif()
add_compile_options(${PLATFORM_FLAGS})

View File

@ -0,0 +1,62 @@
# ##############################################################################
# arch/arm/src/cmake/armv8-m.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(PLATFORM_FLAGS)
if(CONFIG_ARCH_CORTEXM23)
list(APPEND PLATFORM_FLAGS -mtune=cortex-m23 -march=armv8-m.main
-mfloat-abi=soft)
elseif(CONFIG_ARCH_CORTEXM33)
list(APPEND PLATFORM_FLAGS -mtune=cortex-m33 -march=armv8-m.main+dsp)
if(CONFIG_ARCH_FPU)
list(APPEND PLATFORM_FLAGS -mfpu=fpv5-sp-d16)
endif()
elseif(CONFIG_ARCH_CORTEXM35P)
list(APPEND PLATFORM_FLAGS -mtune=cortex-m35p -march=armv8-m.main+dsp)
if(CONFIG_ARCH_FPU)
list(APPEND PLATFORM_FLAGS -mfpu=fpv5-sp-d16)
endif()
elseif(CONFIG_ARCH_CORTEXM55)
list(APPEND PLATFORM_FLAGS -mtune=cortex-m55)
if(CONFIG_ARM_HAVE_MVE)
list(APPEND PLATFORM_FLAGS -march=armv8.1-m.main+mve.fp+fp.dp)
else()
list(APPEND PLATFORM_FLAGS -march=armv8.1-m.main+dsp)
endif()
if(CONFIG_ARCH_FPU)
list(APPEND PLATFORM_FLAGS -mfpu=fpv5-d16)
endif()
endif()
if(CONFIG_ARCH_FPU)
if(CONFIG_ARM_FPU_ABI_SOFT)
list(APPEND PLATFORM_FLAGS -mfloat-abi=softfp)
else()
list(APPEND PLATFORM_FLAGS -mfloat-abi=hard)
endif()
else()
list(APPEND PLATFORM_FLAGS -mfloat-abi=soft)
endif()
if(CONFIG_ARMV8M_STACKCHECK)
list(APPEND PLATFORM_FLAGS -finstrument-functions -ffixed-r10)
endif()
add_compile_options(${PLATFORM_FLAGS})

View File

@ -0,0 +1,103 @@
# ##############################################################################
# ./arch/arm/src/cmake/platform.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# configure target processor
if(CONFIG_ARCH_CORTEXM0)
set(CMAKE_SYSTEM_PROCESSOR cortex-m0)
elseif(CONFIG_ARCH_CORTEXM3)
set(CMAKE_SYSTEM_PROCESSOR cortex-m3)
elseif(CONFIG_ARCH_CORTEXM4)
set(CMAKE_SYSTEM_PROCESSOR cortex-m4)
elseif(CONFIG_ARCH_CORTEXM7)
set(CMAKE_SYSTEM_PROCESSOR cortex-m7)
elseif(CONFIG_ARCH_CORTEXM23)
set(CMAKE_SYSTEM_PROCESSOR cortex-m23)
elseif(CONFIG_ARCH_CORTEXM33)
set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
elseif(CONFIG_ARCH_CORTEXM35P)
set(CMAKE_SYSTEM_PROCESSOR cortex-m35p)
elseif(CONFIG_ARCH_CORTEXM55)
set(CMAKE_SYSTEM_PROCESSOR cortex-m55)
elseif(CONFIG_ARCH_CORTEXA5)
set(CMAKE_SYSTEM_PROCESSOR cortex-a5)
elseif(CONFIG_ARCH_CORTEXA7)
set(CMAKE_SYSTEM_PROCESSOR cortex-a7)
elseif(CONFIG_ARCH_CORTEXA8)
set(CMAKE_SYSTEM_PROCESSOR cortex-a8)
elseif(CONFIG_ARCH_CORTEXA9)
set(CMAKE_SYSTEM_PROCESSOR cortex-a9)
elseif(CONFIG_ARCH_CORTEXR4)
set(CMAKE_SYSTEM_PROCESSOR cortex-r4)
elseif(CONFIG_ARCH_CORTEXR5)
set(CMAKE_SYSTEM_PROCESSOR cortex-r5)
elseif(CONFIG_ARCH_CORTEXR7)
set(CMAKE_SYSTEM_PROCESSOR cortex-r7)
else()
message(FATAL_ERROR "CMAKE_SYSTEM_PROCESSOR not set")
endif()
get_directory_property(NUTTX_EXTRA_FLAGS DIRECTORY ${CMAKE_SOURCE_DIR}
COMPILE_OPTIONS)
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS}
--print-libgcc-file-name
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE extra_library)
if(NOT EXISTS ${extra_library} AND CONFIG_ARCH_TOOLCHAIN_CLANG)
get_filename_component(COMPILER_RT_LIB ${extra_library} NAME)
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name ${COMPILER_RT_LIB}
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE extra_library)
endif()
list(APPEND EXTRA_LIB ${extra_library})
if(NOT CONFIG_LIBM)
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libm.a
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE extra_library)
list(APPEND EXTRA_LIB ${extra_library})
endif()
if(CONFIG_LIBSUPCXX)
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libsupc++.a
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE extra_library)
list(APPEND EXTRA_LIB ${extra_library})
endif()
if(CONFIG_ARCH_COVERAGE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE extra_library)
list(APPEND EXTRA_LIB ${extra_library})
endif()
set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES ${EXTRA_LIB})

View File

@ -0,0 +1,98 @@
# ##############################################################################
# arch/arm/src/common/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_ARCH_TOOLCHAIN_IAR)
set(ARCH_TOOLCHAIN_PATH iar)
else()
set(ARCH_TOOLCHAIN_PATH gnu)
endif()
set(SRCS
arm_allocateheap.c
arm_createstack.c
arm_exit.c
arm_getintstack.c
arm_initialize.c
arm_lowputs.c
arm_modifyreg8.c
arm_modifyreg16.c
arm_modifyreg32.c
arm_nputs.c
arm_releasestack.c
arm_registerdump.c
arm_stackframe.c
arm_switchcontext.c
arm_usestack.c
arm_vfork.c
${ARCH_TOOLCHAIN_PATH}/vfork.S)
if(NOT CONFIG_ALARM_ARCH AND NOT CONFIG_TIMER_ARCH)
list(APPEND SRCS arm_mdelay.c arm_udelay.c)
endif()
if(CONFIG_STACK_COLORATION)
list(APPEND SRCS arm_checkstack.c)
endif()
if(NOT CONFIG_ARCH_IDLE_CUSTOM)
list(APPEND SRCS arm_idle.c)
endif()
if(CONFIG_BUILD_PROTECTED OR CONFIG_BUILD_KERNEL)
list(APPEND SRCS arm_task_start.c arm_pthread_start.c arm_signal_dispatch.c)
if(CONFIG_BUILD_PROTECTED)
list(APPEND SRCS ${ARCH_TOOLCHAIN_PATH}/arm_signal_handler.S)
endif()
endif()
if(CONFIG_ARM_SEMIHOSTING_SYSLOG)
list(APPEND SRCS arm_semi_syslog.c)
endif()
if(CONFIG_ARM_SEMIHOSTING_HOSTFS)
list(APPEND SRCS arm_hostfs.c)
endif()
if(CONFIG_SCHED_THREAD_LOCAL)
list(APPEND SRCS arm_tls.c)
endif()
if(CONFIG_UNWINDER_FRAME_POINTER)
list(APPEND SRCS arm_backtrace_fp.c)
endif()
if(CONFIG_UNWINDER_STACK_POINTER)
list(APPEND SRCS arm_backtrace_sp.c)
endif()
if(CONFIG_UNWINDER_ARM)
list(APPEND SRCS arm_backtrace_unwind.c)
endif()
if(CONFIG_ARCH_HAVE_TESTSET AND NOT CONFIG_ARCH_ARMV6M)
list(APPEND SRCS ${ARCH_TOOLCHAIN_PATH}/arm_testset.S)
endif()
if(CONFIG_ARCH_HAVE_FETCHADD)
list(APPEND SRCS ${ARCH_TOOLCHAIN_PATH}/arm_fetchadd.S)
endif()
target_sources(arch PRIVATE ${SRCS})

View File

@ -0,0 +1,166 @@
# ##############################################################################
# arch/arm/src/cxd56xx/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS
cxd56_farapistub.S
cxd56_allocateheap.c
cxd56_idle.c
cxd56_uid.c
cxd56_serial.c
cxd56_uart.c
cxd56_irq.c
cxd56_start.c
cxd56_timerisr.c
cxd56_pinconfig.c
cxd56_clock.c
cxd56_delay.c
cxd56_gpio.c
cxd56_pmic.c
cxd56_cpufifo.c
cxd56_icc.c
cxd56_powermgr.c
cxd56_farapi.c
cxd56_sysctl.c)
if(CONFIG_SMP)
list(APPEND SRCS cxd56_cpuidlestack.c)
list(APPEND SRCS cxd56_cpuindex.c)
list(APPEND SRCS cxd56_cpupause.c)
list(APPEND SRCS cxd56_cpustart.c)
if(CONFIG_CXD56_TESTSET)
list(APPEND SRCS cxd56_testset.c)
endif()
endif()
if(CONFIG_ARCH_USE_TEXT_HEAP)
list(APPEND SRCS cxd56_textheap.c)
endif()
if(CONFIG_CXD56_UART0)
list(APPEND SRCS cxd56_uart0.c)
endif()
if(CONFIG_CXD56_PM_PROCFS)
list(APPEND SRCS cxd56_powermgr_procfs.c)
endif()
if(CONFIG_CXD56_RTC)
list(APPEND SRCS cxd56_rtc.c)
if(CONFIG_RTC_DRIVER)
list(APPEND SRCS cxd56_rtc_lowerhalf.c)
endif()
endif()
if(CONFIG_CXD56_GPIO_IRQ)
list(APPEND SRCS cxd56_gpioint.c)
endif()
if(CONFIG_USBDEV)
list(APPEND SRCS cxd56_usbdev.c)
endif()
if(CONFIG_CXD56_SDIO)
list(APPEND SRCS cxd56_sdhci.c)
endif()
if(CONFIG_CXD56_SFC)
list(APPEND SRCS cxd56_sfc.c)
endif()
if(CONFIG_CXD56_SPH)
list(APPEND SRCS cxd56_sph.c)
endif()
if(CONFIG_CXD56_EMMC)
list(APPEND SRCS cxd56_emmc.c)
endif()
if(CONFIG_CXD56_SPI)
list(APPEND SRCS cxd56_spi.c)
endif()
if(CONFIG_CXD56_I2C)
list(APPEND SRCS cxd56_i2c.c)
endif()
if(CONFIG_I2C_BITBANG)
list(APPEND SRCS cxd56_i2c_bitbang.c)
endif()
if(CONFIG_CXD56_DMAC)
list(APPEND SRCS cxd56_dmac.c)
endif()
if(CONFIG_CXD56_PWM)
list(APPEND SRCS cxd56_pwm.c)
endif()
if(CONFIG_CXD56_GAUGE)
list(APPEND SRCS cxd56_gauge.c)
endif()
if(CONFIG_CXD56_CHARGER)
list(APPEND SRCS cxd56_charger.c)
endif()
if(CONFIG_CXD56_GE2D)
list(APPEND SRCS cxd56_ge2d.c)
endif()
if(CONFIG_CXD56_CISIF)
list(APPEND SRCS cxd56_cisif.c)
endif()
if(CONFIG_CXD56_SCU)
list(APPEND SRCS cxd56_scu.c cxd56_scufifo.c)
if(CONFIG_CXD56_ADC)
list(APPEND SRCS cxd56_adc.c)
endif()
if(CONFIG_CXD56_UDMAC)
list(APPEND SRCS cxd56_udmac.c)
endif()
endif()
if(CONFIG_CXD56_TIMER)
list(APPEND SRCS cxd56_timer.c)
endif()
if(CONFIG_CXD56_WDT)
list(APPEND SRCS cxd56_wdt.c)
endif()
if(CONFIG_CXD56_GNSS)
list(APPEND SRCS cxd56_gnss.c)
list(APPEND SRCS cxd56_cpu1signal.c)
endif()
if(CONFIG_CXD56_GEOFENCE)
list(APPEND SRCS cxd56_geofence.c)
endif()
if(CONFIG_CXD56_BACKUPLOG)
list(APPEND SRCS cxd56_backuplog.c)
endif()
if(CONFIG_CXD56_HOSTIF)
list(APPEND SRCS cxd56_hostif.c)
endif()
target_sources(arch PRIVATE ${SRCS})

View File

@ -0,0 +1,49 @@
# ##############################################################################
# arch/arm/src/imx6/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS
imx_boot.c
imx_memorymap.c
imx_clockconfig.c
imx_irq.c
imx_timerisr.c
imx_gpio.c
imx_iomuxc.c
imx_serial.c
imx_lowputc.c
imx_idle.c)
if(CONFIG_SMP)
list(APPEND SRCS imx_cpuboot.c)
endif()
if(CONFIG_IMX6_ECSPI)
list(APPEND SRCS imx_ecspi.c)
endif()
if(CONFIG_IMX6_ENET)
list(APPEND SRCS imx_enet.c)
endif()
if(CONFIG_MM_PGALLOC)
list(APPEND SRCS imx_pgalloc.c)
endif()
target_sources(arch PRIVATE ${SRCS})

View File

@ -0,0 +1,233 @@
# ##############################################################################
# arch/arm/src/stm32/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS)
list(
APPEND
SRCS
stm32_allocateheap.c
stm32_start.c
stm32_rcc.c
stm32_lse.c
stm32_lsi.c
stm32_gpio.c
stm32_exti_gpio.c
stm32_flash.c
stm32_irq.c
stm32_dma.c
stm32_lowputc.c
stm32_serial.c
stm32_spi.c
stm32_i2s.c
stm32_sdio.c
stm32_tim.c
stm32_waste.c
stm32_ccm.c
stm32_uid.c
stm32_capture.c
stm32_dfumode.c)
if(CONFIG_TIMER)
list(APPEND SRCS stm32_tim_lowerhalf.c)
endif()
if(CONFIG_STM32_TICKLESS_TIMER)
list(APPEND SRCS stm32_tickless.c)
else()
list(APPEND SRCS stm32_timerisr.c)
endif()
if(CONFIG_STM32_ONESHOT)
list(APPEND SRCS stm32_oneshot.c stm32_oneshot_lowerhalf.c)
endif()
if(CONFIG_STM32_FREERUN)
list(APPEND SRCS stm32_freerun.c)
endif()
if(CONFIG_BUILD_PROTECTED)
list(APPEND SRCS stm32_userspace.c stm32_mpuinit.c)
endif()
if(CONFIG_STM32_CCM_PROCFS)
list(APPEND SRCS stm32_procfs_ccm.c)
endif()
if(CONFIG_STM32_HAVE_IP_I2C_V1)
if(CONFIG_STM32_I2C_ALT)
list(APPEND SRCS stm32_i2c_alt.c)
elseif(CONFIG_STM32_STM32F4XXX)
list(APPEND SRCS stm32f40xxx_i2c.c)
else()
list(APPEND SRCS stm32_i2c.c)
endif()
elseif(CONFIG_STM32_HAVE_IP_I2C_V2)
list(APPEND SRCS stm32_i2c_v2.c)
endif()
if(CONFIG_USBDEV)
if(CONFIG_STM32_USB)
list(APPEND SRCS stm32_usbdev.c)
endif()
if(CONFIG_STM32_OTGFS)
list(APPEND SRCS stm32_otgfsdev.c)
endif()
if(CONFIG_STM32_OTGHS)
list(APPEND SRCS stm32_otghsdev.c)
endif()
endif()
if(CONFIG_STM32_USBHOST)
if(CONFIG_STM32_OTGFS)
list(APPEND SRCS stm32_otgfshost.c)
endif()
if(CONFIG_STM32_OTGHS)
list(APPEND SRCS stm32_otghshost.c)
endif()
if(CONFIG_USBHOST_TRACE)
list(APPEND SRCS stm32_usbhost.c)
else()
if(CONFIG_DEBUG_USB)
list(APPEND SRCS stm32_usbhost.c)
endif()
endif()
endif()
if(NOT CONFIG_ARCH_IDLE_CUSTOM)
list(APPEND SRCS stm32_idle.c)
endif()
list(APPEND SRCS stm32_pmstop.c stm32_pmstandby.c stm32_pmsleep.c)
if(NOT CONFIG_ARCH_CUSTOM_PMINIT)
list(APPEND SRCS stm32_pminitialize.c)
endif()
if(CONFIG_STM32_ETHMAC)
list(APPEND SRCS stm32_eth.c)
endif()
if(CONFIG_STM32_PWR)
list(APPEND SRCS stm32_pwr.c stm32_exti_pwr.c)
endif()
if(CONFIG_STM32_RTC)
list(APPEND SRCS stm32_rtc.c)
if(CONFIG_RTC_ALARM)
list(APPEND SRCS stm32_exti_alarm.c)
endif()
if(CONFIG_RTC_PERIODIC)
list(APPEND SRCS stm32_exti_wakeup.c)
endif()
if(CONFIG_RTC_DRIVER)
list(APPEND SRCS stm32_rtc_lowerhalf.c)
endif()
endif()
if(CONFIG_STM32_ADC)
list(APPEND SRCS stm32_adc.c)
endif()
if(CONFIG_STM32_SDADC)
list(APPEND SRCS stm32_sdadc.c)
endif()
if(CONFIG_STM32_DAC)
list(APPEND SRCS stm32_dac.c)
endif()
if(CONFIG_STM32_COMP)
list(APPEND SRCS stm32_comp.c)
endif()
if(CONFIG_STM32_OPAMP)
list(APPEND SRCS stm32_opamp.c)
endif()
if(CONFIG_STM32_HRTIM)
list(APPEND SRCS stm32_hrtim.c)
endif()
if(CONFIG_STM32_1WIREDRIVER)
list(APPEND SRCS stm32_1wire.c)
endif()
if(CONFIG_STM32_HCIUART)
list(APPEND SRCS stm32_hciuart.c)
endif()
if(CONFIG_STM32_RNG)
list(APPEND SRCS stm32_rng.c)
endif()
if(CONFIG_STM32_LTDC)
list(APPEND SRCS stm32_ltdc.c)
endif()
if(CONFIG_STM32_DMA2D)
list(APPEND SRCS stm32_dma2d.c)
endif()
if(CONFIG_STM32_PWM)
list(APPEND SRCS stm32_pwm.c)
endif()
if(CONFIG_SENSORS_QENCODER)
list(APPEND SRCS stm32_qencoder.c)
endif()
if(CONFIG_STM32_CAN)
list(APPEND SRCS stm32_can.c)
endif()
if(CONFIG_STM32_IWDG)
list(APPEND SRCS stm32_iwdg.c)
endif()
if(CONFIG_STM32_WWDG)
list(APPEND SRCS stm32_wwdg.c)
endif()
if(CONFIG_DEBUG_FEATURES)
list(APPEND SRCS stm32_dumpgpio.c)
endif()
if(CONFIG_STM32_AES)
list(APPEND SRCS stm32_aes.c)
endif()
if(CONFIG_STM32_BBSRAM)
list(APPEND SRCS stm32_bbsram.c)
endif()
if(CONFIG_STM32_FMC)
list(APPEND SRCS stm32_fmc.c)
endif()
if(CONFIG_STM32_FSMC)
list(APPEND SRCS stm32_fsmc.c)
endif()
if(CONFIG_STM32_FOC)
list(APPEND SRCS stm32_foc.c)
endif()
target_sources(arch PRIVATE ${SRCS})

View File

@ -0,0 +1,60 @@
# ##############################################################################
# arch/arm/src/stm32u5/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS
stm32_allocateheap.c
stm32_exti_gpio.c
stm32_gpio.c
stm32_irq.c
stm32_lowputc.c
stm32_rcc.c
stm32_serial.c
stm32_start.c
stm32_waste.c
stm32_uid.c
stm32_spi.c
stm32_lse.c
stm32_lsi.c
stm32_pwr.c
stm32_tim.c
stm32_flash.c
stm32_timerisr.c)
if(NOT CONFIG_ARCH_IDLE_CUSTOM)
list(APPEND SRCS stm32_idle.c)
endif()
if(CONFIG_TIMER)
list(APPEND SRCS stm32_tim_lowerhalf.c)
endif()
if(CONFIG_BUILD_PROTECTED)
list(APPEND SRCS stm32_userspace.c stm32_mpuinit.c)
endif()
if(CONFIG_DEBUG_FEATURES)
list(APPEND SRCS stm32_dumpgpio.c)
endif()
if(CONFIG_STM32U5_STM32U585XX)
list(APPEND SRCS stm32u585xx_rcc.c)
endif()
target_sources(arch PRIVATE ${SRCS})

View File

@ -0,0 +1,140 @@
# ##############################################################################
# arch/arm/src/tiva/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_ARCH_CHIP_LM)
set(ARCH_CHIP lm)
elseif(CONFIG_ARCH_CHIP_TM4C)
set(ARCH_CHIP tm4c)
elseif(CONFIG_ARCH_CHIP_CC13X0)
set(ARCH_CHIP cc13xx)
elseif(CONFIG_ARCH_CHIP_CC13X2)
set(ARCH_CHIP cc13xx)
endif()
set(SRCS)
if(NOT CONFIG_ARCH_IDLE_CUSTOM)
list(APPEND SRCS tiva_idle.c)
endif()
list(APPEND SRCS tiva_allocateheap.c tiva_irq.c tiva_lowputc.c tiva_serial.c)
list(APPEND SRCS tiva_ssi.c)
if(CONFIG_ARCH_CHIP_LM3S)
list(APPEND SRCS lmxx_tm4c_start.c lm3s_gpio.c lmxx_tm4c_gpioirq.c)
list(APPEND SRCS lm4xx_tm3c_sysctrl.c)
elseif(CONFIG_ARCH_CHIP_LM4F)
list(APPEND SRCS lmxx_tm4c_start.c lm4f_gpio.c lmxx_tm4c_gpioirq.c)
list(APPEND SRCS lm4xx_tm3c_sysctrl.c)
elseif(CONFIG_ARCH_CHIP_TM4C)
list(APPEND SRCS lmxx_tm4c_start.c tm4c_gpio.c lmxx_tm4c_gpioirq.c)
if(CONFIG_ARCH_CHIP_TM4C129)
list(APPEND SRCS tm4c129_sysctrl.c)
else()
list(APPEND SRCS lm4xx_tm3c_sysctrl.c)
endif()
elseif(CONFIG_ARCH_CHIP_CC13X0)
list(APPEND SRCS cc13xx_start.c cc13xx_prcm.c cc13xx_chipinfo.c cc13xx_gpio.c)
list(APPEND SRCS cc13xx_gpioirq.c cc13xx_enableclks.c cc13xx_enablepwr.c)
list(APPEND SRCS cc13x0_trim.c cc13x0_rom.c)
elseif(CONFIG_ARCH_CHIP_CC13X2)
list(APPEND SRCS cc13xx_start.c cc13xx_prcm.c cc13xx_chipinfo.c cc13xx_gpio.c)
list(APPEND SRCS cc13xx_gpioirq.c cc13xx_enableclks.c cc13xx_enablepwr.c)
list(APPEND SRCS cc13x2_aux_sysif.c)
if(CONFIG_ARCH_CHIP_CC13XX_V1)
list(APPEND SRCS cc13x2_v1_trim.c cc13x2_cc26x2_v1_rom.c)
else()
list(APPEND SRCS cc13x2_v2_trim.c)
endif()
endif()
if(CONFIG_DEBUG_GPIO_INFO)
list(APPEND SRCS tiva_dumpgpio.c)
endif()
if(NOT CONFIG_SCHED_TICKLESS)
list(APPEND SRCS tiva_timerisr.c)
endif()
if(CONFIG_BUILD_PROTECTED)
list(APPEND SRCS tiva_userspace.c tiva_mpuinit.c)
endif()
if(CONFIG_TIVA_I2C)
list(APPEND SRCS tiva_i2c.c)
endif()
if(CONFIG_TIVA_PWM)
list(APPEND SRCS tiva_pwm.c)
endif()
if(CONFIG_TIVA_QEI)
list(APPEND SRCS tiva_qencoder.c)
endif()
if(CONFIG_TIVA_TIMER)
list(APPEND SRCS tiva_timerlib.c)
if(CONFIG_TIVA_TIMER32_PERIODIC)
list(APPEND SRCS tiva_timerlow32.c)
endif()
endif()
if(CONFIG_TIVA_ADC)
list(APPEND SRCS tiva_adclow.c)
list(APPEND SRCS tiva_adclib.c)
endif()
if(CONFIG_TIVA_CAN)
list(APPEND SRCS tiva_can.c)
endif()
if(CONFIG_TIVA_ETHERNET)
if(CONFIG_ARCH_CHIP_LM3S)
list(APPEND SRCS lm3s_ethernet.c)
endif()
if(CONFIG_ARCH_CHIP_TM4C)
list(APPEND SRCS tm4c_ethernet.c)
endif()
endif()
if(CONFIG_TIVA_FLASH)
list(APPEND SRCS tiva_flash.c)
endif()
if(CONFIG_TIVA_EEPROM)
list(APPEND SRCS tiva_eeprom.c)
endif()
if(CONFIG_TIVA_HCIUART)
list(APPEND SRCS tiva_hciuart.c)
endif()
set(COMMON_SRCS)
foreach(src ${SRCS})
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/common/${src})
list(APPEND COMMON_SRCS common/${src})
else()
list(APPEND COMMON_SRCS ${ARCH_CHIP}/${src})
endif()
endforeach()
target_sources(arch PRIVATE ${COMMON_SRCS})

196
arch/sim/CMakeLists.txt Normal file
View File

@ -0,0 +1,196 @@
# ##############################################################################
# arch/sim/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
include_directories(include)
add_subdirectory(src)
# configure host binary ######################################################
target_include_directories(nuttx PRIVATE ${CONFIG_ARCH_CHIP})
target_compile_definitions(nuttx
PRIVATE CONFIG_USEC_PER_TICK=${CONFIG_USEC_PER_TICK})
if(APPLE)
target_compile_options(nuttx PRIVATE -Wno-deprecated-declarations)
endif()
# configure simulated nuttx ##################################################
if(NOT WIN32)
# Add -fvisibility=hidden Because we don't want export nuttx's symbols to
# shared libraries
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_COMPILE_OPTIONS -fvisibility=hidden)
# Add -fno-common because macOS "ld -r" doesn't seem to pick objects for
# common symbols.
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_COMPILE_OPTIONS -fno-common)
endif()
if(CONFIG_SIM_SANITIZE)
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_COMPILE_OPTIONS -fsanitize=address -fsanitize=undefined
-fno-omit-frame-pointer)
endif()
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_COMPILE_OPTIONS
# NuttX is sometimes built as a native target. In that case, the
# __NuttX__ macro is predefined by the compiler.
# https://github.com/NuttX/buildroot
#
# In other cases, __NuttX__ is an ordinary user-definded macro. It's
# especially the case for NuttX sim, which is a target to run the
# entire NuttX as a program on the host OS, which can be Linux,
# macOS, Windows, etc.
# https://cwiki.apache.org/confluence/display/NUTTX/NuttX+Simulation
# In that case, the host OS compiler is used to build NuttX. Thus,
# eg. NuttX sim on macOS is built with __APPLE__. We #undef
# predefined macros for those possible host OSes here because the OS
# APIs this library should use are of NuttX, not the host OS.
-U_AIX
-U_WIN32
-U__APPLE__
-U__FreeBSD__
-U__NetBSD__
-U__linux__
-U__sun__
-U__unix__
-U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
# common options #############################################################
if(X86_64 AND CONFIG_SIM_M32)
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_COMPILE_OPTIONS -m32)
target_compile_options(nuttx PRIVATE -m32)
target_link_options(nuttx PRIVATE -m32)
endif()
if(CONFIG_LIBCXX)
if(APPLE)
# macOS uses libc++abi
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_DEFINITIONS LIBCXX_BUILDING_LIBCXXABI)
else()
# Linux C++ ABI seems vary. Probably __GLIBCXX__ is the best bet. XXX what
# to do for windows?
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_DEFINITIONS __GLIBCXX__)
endif()
# Disable availability macros. The availability on Host OS is not likely
# appropriate for NuttX.
#
# Note: When compiling NuttX apps, we undefine __APPLE__. It makes libcxx
# __availability header unhappy.
# https://github.com/llvm/llvm-project/blob/2e2999cd44f6ec9a5e396fa0113497ea82582f69/libcxx/include/__availability#L258
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_DEFINITIONS _LIBCPP_DISABLE_AVAILABILITY)
endif()
# This is part of the top-level export target TODO: how to deal with in CMake?
# export_startup: board/libboard$(LIBEXT) up_head.o $(HOSTOBJS) nuttx-names.dat
# cp up_head.o $(HOSTOBJS) ${EXPORT_DIR}/startup cp nuttx-names.dat
# ${EXPORT_DIR}/libs echo main NXmain >> ${EXPORT_DIR}/libs/nuttx-names.dat
# Loadable module definitions TODO: implement modules with CMake
# -fno-pic to avoid GOT relocations
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_MODULE_COMPILE_OPTIONS -fno-pic)
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_MODULE_LINK_OPTIONS -r -e module_initialize -T
${NUTTX_DIR}/libs/libc/modlib/gnu-elf.ld)
if(CONFIG_LIBC_ARCH_ELF_64BIT)
# For amd64: It seems macOS/x86_64 loads the program text around
# 00000001_xxxxxxxx. The gcc default (-mcmodel=small) would produce
# out-of-range 32-bit relocations. Even on Linux, NuttX modules are loaded
# into the NuttX heap, which can be out of range with -mcmodel=small.
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_MODULE_COMPILE_OPTIONS -mcmodel=large)
endif()
# On Linux, we (ab)use the host compiler to compile binaries for NuttX.
# Explicitly disable features which might be default on the host while not
# available on NuttX.
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_MODULE_COMPILE_OPTIONS -fno-stack-protector)
# TODO: move to toolchain file NuttX modules are ELF binaries. Non-ELF platforms
# like macOS need to use a separate ELF toolchain. ifeq ($(CONFIG_HOST_MACOS),y)
# # eg. brew install x86_64-elf-gcc MODULECC = x86_64-elf-gcc MODULELD =
# x86_64-elf-ld MODULESTRIP = x86_64-elf-strip --strip-unneeded endif
# ELF module definitions
# -fno-pic to avoid GOT relocations
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_APP_COMPILE_OPTIONS -fno-pic)
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_APP_LINK_OPTIONS -r -e main
-T${BOARD_PATH}/scripts/gnu-elf.ld)
# TODO: move to toolchain file
if(X86_64 AND CONFIG_SIM_M32)
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_MODULE_LINK_OPTIONS -m32)
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_APP_LINK_OPTIONS -m32)
endif()

View File

@ -0,0 +1,30 @@
# ##############################################################################
# arch/sim/src/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_subdirectory(${CONFIG_ARCH_CHIP})
# Include directories (before system ones) as PUBLIC so that it can be exposed
# to libboard
target_include_directories(arch BEFORE PUBLIC ${CONFIG_ARCH_CHIP} common)
if(NOT CONFIG_BUILD_FLAT)
target_include_directories(arch_interface BEFORE PUBLIC ${CONFIG_ARCH_CHIP}
common)
endif()

View File

@ -0,0 +1,24 @@
# ##############################################################################
# arch/sim/cmake/Toolchain.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(APPLE)
find_program(CMAKE_C_ELF_COMPILER x86_64-elf-gcc)
find_program(CMAKE_CXX_ELF_COMPILER x86_64-elf-g++)
endif()

View File

@ -0,0 +1,19 @@
# ##############################################################################
# arch/sim/src/cmake/platform.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################

View File

@ -0,0 +1,228 @@
# ##############################################################################
# arch/sim/src/sim/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# Initialize empty variables to hold internal (emulated guest) and external
# (host) source files
set(SRCS)
set(HOSTSRCS)
set(HOST_INCLUDE_DIRS)
set(STDLIBS pthread)
list(APPEND HOST_DEFINITIONS -D__SIM__)
# common guest sources
list(
APPEND
SRCS
sim_initialize.c
sim_idle.c
sim_doirq.c
sim_initialstate.c
sim_createstack.c
sim_usestack.c
sim_releasestack.c
sim_stackframe.c
sim_exit.c
sim_schedulesigaction.c
sim_switchcontext.c
sim_heap.c
sim_uart.c
sim_copyfullstate.c
sim_sigdeliver.c
sim_registerdump.c
sim_saveusercontext.c
sim_textheap.c)
if(CONFIG_HOST_X86_64)
if(CONFIG_SIM_M32)
list(APPEND SRCS sim_vfork_x86.S)
else()
list(APPEND SRCS sim_vfork_x86_64.S)
endif()
elseif(CONFIG_HOST_X86)
list(APPEND SRCS sim_vfork_x86.S)
elseif(CONFIG_HOST_ARM)
list(APPEND SRCS sim_vfork_arm.S)
elseif(CONFIG_HOST_ARM64)
list(APPEND SRCS sim_vfork_arm64.S)
endif()
if(CONFIG_SCHED_BACKTRACE)
list(APPEND SRCS sim_backtrace.c)
endif()
if(CONFIG_ARCH_HAVE_VFORK AND CONFIG_SCHED_WAITPID)
list(APPEND SRCS sim_vfork.c)
endif()
if(CONFIG_ONESHOT)
list(APPEND SRCS sim_oneshot.c)
endif()
if(CONFIG_RTC_DRIVER)
list(APPEND SRCS sim_rtc.c)
endif()
if(CONFIG_SIM_LCDDRIVER)
list(APPEND SRCS sim_lcd.c)
elseif(CONFIG_SIM_FRAMEBUFFER)
list(APPEND SRCS sim_framebuffer.c)
endif()
if(CONFIG_STACK_COLORATION)
list(APPEND SRCS sim_checkstack.c)
endif()
if(CONFIG_FS_FAT)
list(APPEND SRCS sim_blockdevice.c sim_deviceimage.c)
list(APPEND STDLIBS z)
endif()
if(APPLE)
if(NOT CONFIG_LIBCXX)
list(APPEND STDLIBS c++abi)
endif()
else()
list(APPEND STDLIBS rt)
endif()
if(CONFIG_RPTUN)
list(APPEND SRCS sim_rptun.c)
endif()
if(CONFIG_SIM_SOUND_ALSA)
list(APPEND SRCS sim_alsa.c)
list(APPEND STDLIBS asound)
list(APPEND STDLIBS mad)
endif()
# host sources ###############################################################
list(
APPEND
HOSTSRCS
sim_hostirq.c
sim_hostmemory.c
sim_hostmisc.c
sim_hosttime.c
sim_hostuart.c)
if(CONFIG_SPINLOCK)
list(APPEND HOSTSRCS sim_testset.c)
endif()
if(CONFIG_SMP)
list(APPEND SRCS sim_smpsignal.c sim_cpuidlestack.c)
list(APPEND HOSTSRCS sim_hostsmp.c)
endif()
if(CONFIG_SIM_X11FB)
list(APPEND HOSTSRCS sim_x11framebuffer.c)
list(APPEND STDLIBS X11 Xext)
if(CONFIG_SIM_TOUCHSCREEN)
list(APPEND SRCS sim_touchscreen.c)
list(APPEND HOSTSRCS sim_x11eventloop.c)
elseif(CONFIG_SIM_AJOYSTICK)
list(APPEND SRCS sim_ajoystick.c)
list(APPEND HOSTSRCS sim_x11eventloop.c)
elseif(CONFIG_SIM_BUTTONS)
list(APPEND HOSTSRCS sim_x11eventloop.c)
endif()
endif()
if(CONFIG_SIM_NETDEV_TAP)
list(APPEND SRCS sim_netdriver.c)
if(NOT CYGWIN)
list(APPEND HOSTSRCS sim_tapdev.c)
else() # CYGWIN != y
list(APPEND HOSTSRCS sim_wpcap.c)
list(APPEND STDLIBS /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a)
endif() # CONFIG_WINDOWS_CYGWIN != y
elseif(CONFIG_SIM_NETDEV_VPNKIT)
list(APPEND SRCS sim_netdriver.c)
list(APPEND HOST_DEFINITIONS
CONFIG_SIM_NETDEV_VPNKIT_PATH=\"${CONFIG_SIM_NETDEV_VPNKIT_PATH}\")
list(APPEND HOSTSRCS sim_vpnkit.c vpnkit/protocol.c vpnkit/negotiate.c)
endif()
if(CONFIG_SIM_HCISOCKET)
list(APPEND HOSTSRCS sim_hcisocket_host.c)
list(APPEND SRCS sim_hcisocket.c)
endif()
if(CONFIG_SIM_NETUSRSOCK)
list(APPEND HOSTSRCS sim_usrsock_host.c)
list(APPEND SRCS sim_usrsock.c)
endif()
if(CONFIG_SIM_BTUART)
list(APPEND HOSTSRCS sim_hcisocket_host.c)
list(APPEND SRCS sim_btuart.c)
endif()
if(CONFIG_I2C_RESET)
list(APPEND HOST_DEFINITIONS CONFIG_I2C_RESET=1)
endif()
if(CONFIG_SIM_I2CBUS_LINUX)
list(APPEND HOSTSRCS sim_i2cbuslinux.c)
endif()
if(CONFIG_SIM_SPI_LINUX)
list(APPEND HOSTSRCS sim_spilinux.c)
endif()
if(CONFIG_SIM_HOSTFS)
list(APPEND HOSTSRCS sim_hostfs.c)
list(APPEND HOST_DEFINITIONS CONFIG_NAME_MAX=${CONFIG_NAME_MAX})
configure_file(${NUTTX_DIR}/include/nuttx/fs/hostfs.h
${CMAKE_CURRENT_BINARY_DIR}/hostfs.h COPYONLY)
target_include_directories(nuttx PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
endif()
target_include_directories(nuttx PRIVATE ${CMAKE_BINARY_DIR}/include/nuttx)
target_include_directories(nuttx PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_sources(sim_head PUBLIC sim_head.c sim_doirq.c)
target_sources(arch PRIVATE ${SRCS})
if(WIN32)
set(HOSTDIR win)
else()
set(HOSTDIR posix)
target_link_libraries(nuttx PUBLIC ${STDLIBS})
endif()
set(WINHOSTSRCS)
foreach(hostsrc ${HOSTSRCS})
list(APPEND WINHOSTSRCS ${HOSTDIR}/${hostsrc})
endforeach()
set(HOSTSRCS ${WINHOSTSRCS})
target_sources(nuttx PRIVATE ${HOSTSRCS})
target_compile_definitions(nuttx PRIVATE ${HOST_DEFINITIONS})

35
audio/CMakeLists.txt Normal file
View File

@ -0,0 +1,35 @@
# ##############################################################################
# audio/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_AUDIO)
nuttx_add_kernel_library(audio)
set(SRCS audio.c)
if(CONFIG_AUDIO_COMP)
list(APPEND SRCS audio_comp.c)
endif()
if(CONFIG_AUDIO_FORMAT_PCM)
list(APPEND SRCS pcm_decode.c)
endif()
target_sources(audio PRIVATE ${SRCS})
endif()

61
binfmt/CMakeLists.txt Normal file
View File

@ -0,0 +1,61 @@
# ##############################################################################
# binfmt/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS)
nuttx_add_kernel_library(binfmt)
nuttx_add_subdirectory()
list(
APPEND
SRCS
binfmt_globals.c
binfmt_initialize.c
binfmt_register.c
binfmt_unregister.c
binfmt_loadmodule.c
binfmt_unloadmodule.c
binfmt_execmodule.c
binfmt_exec.c
binfmt_copyargv.c
binfmt_dumpmodule.c
binfmt_coredump.c)
if(CONFIG_BINFMT_LOADABLE)
list(APPEND SRCS binfmt_exit.c)
endif()
if(CONFIG_LIBC_EXECFUNCS)
list(APPEND SRCS binfmt_execsymtab.c)
endif()
if(CONFIG_ELF)
list(APPEND SRCS elf.c)
endif()
# Builtin application interfaces
if(CONFIG_BUILTIN)
list(APPEND SRCS builtin.c)
endif()
target_sources(binfmt PRIVATE ${SRCS})
target_include_directories(binfmt PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -0,0 +1,51 @@
# ##############################################################################
# binfmt/libelf/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_ELF)
set(SRCS)
# ELF library
list(
APPEND
SRCS
libelf_bind.c
libelf_init.c
libelf_addrenv.c
libelf_iobuffer.c
libelf_load.c
libelf_read.c
libelf_sections.c
libelf_symbols.c
libelf_uninit.c
libelf_unload.c
libelf_verify.c)
if(CONFIG_ELF_COREDUMP)
list(APPEND SRCS libelf_coredump.c)
target_include_directories(binfmt PRIVATE ${NUTTX_DIR}/sched)
endif()
if(CONFIG_BINFMT_CONSTRUCTORS)
list(APPEND SRCS libelf_ctors.c libelf_dtors.c)
endif()
target_sources(binfmt PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,35 @@
# ##############################################################################
# binfmt/libnxflat/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_NXFLAT)
target_sources(
binfmt
PRIVATE # NXFLAT library
libnxflat_init.c
libnxflat_uninit.c
libnxflat_addrenv.c
libnxflat_load.c
libnxflat_unload.c
libnxflat_verify.c
libnxflat_read.c
libnxflat_bind.c)
endif()

65
boards/CMakeLists.txt Normal file
View File

@ -0,0 +1,65 @@
# ##############################################################################
# boards/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# Determine if there is a Kconfig file for any custom board configuration
# TODO: implement if("${CONFIG_ARCH_BOARD_CUSTOM}" STREQUAL "y") CUSTOM_DIR =
# $(patsubst "%",%,$(CONFIG_ARCH_BOARD_CUSTOM_DIR))
# if("${CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH}" STREQUAL "y") CUSTOM_KPATH =
# $(TOPDIR)$(DELIM)$(CUSTOM_DIR)$(DELIM)Kconfig else CUSTOM_KPATH =
# $(CUSTOM_DIR)$(DELIM)Kconfig endif CUSTOM_KCONFIG = $(if $(wildcard
# $(CUSTOM_KPATH)),y,) else CUSTOM_KCONFIG = endif
# ifeq ($(CUSTOM_KCONFIG),y) BOARD_KCONFIG = $(CUSTOM_KPATH) else BOARD_KCONFIG
# = $(TOPDIR)$(DELIM)configs$(DELIM)dummy$(DELIM)dummy_kconfig endif
file(WRITE ${CMAKE_BINARY_DIR}/dummy.c "")
nuttx_add_kernel_library(board ${CMAKE_BINARY_DIR}/dummy.c)
# boardctl support
if(CONFIG_BOARDCTL)
target_sources(board PRIVATE boardctl.c)
endif()
# obtain include directories exported by libarch
target_include_directories(board
PRIVATE $<TARGET_PROPERTY:arch,INCLUDE_DIRECTORIES>)
# add contents of <arch>, <soc> and <board> directories, adding common/ subdirs
# if found at each arch and soc level
if(EXISTS ${NUTTX_BOARD_ABS_DIR}/../common/CMakeLists.txt)
add_subdirectory("${NUTTX_BOARD_ABS_DIR}/../common" EXCLUDE_FROM_ALL
exclude_common)
# Create link ARCH_SRC_BOARD_BOARD_SYMLINK
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/arch/${CONFIG_ARCH}/src/board)
file(CREATE_LINK ${NUTTX_BOARD_ABS_DIR}/src
${CMAKE_BINARY_DIR}/arch/${CONFIG_ARCH}/src/board/board SYMBOLIC)
endif()
if(EXISTS ${NUTTX_BOARD_ABS_DIR}/../drivers/CMakeLists.txt)
add_subdirectory("${NUTTX_BOARD_ABS_DIR}/../drivers" EXCLUDE_FROM_ALL
exclude_drivers)
endif()
add_subdirectory(${NUTTX_BOARD_ABS_DIR} EXCLUDE_FROM_ALL exclude_board)

View File

@ -0,0 +1,183 @@
# ##############################################################################
# boards/arm/cxd56xx/common/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_ARCH_BOARD_COMMON)
set(SRCS)
list(APPEND SRCS src/cxd56_boot.c)
if(CONFIG_AUDIO_CXD56)
list(APPEND SRCS src/cxd56_audio.c)
endif()
if(CONFIG_CXD56_AUDIO)
list(APPEND SRCS src/cxd56_audio.c)
endif()
if(CONFIG_MODEM_ALTMDM)
list(APPEND SRCS src/cxd56_altmdm.c)
endif()
if(CONFIG_BOARDCTL_UNIQUEID)
list(APPEND SRCS src/cxd56_uid.c)
endif()
if(CONFIG_CXD56_BACKUPLOG)
list(APPEND SRCS src/cxd56_crashdump.c)
endif()
if(CONFIG_SENSORS)
list(APPEND SRCS src/cxd56_sensors.c)
endif()
if(CONFIG_SENSORS_AK09912)
list(APPEND SRCS src/cxd56_ak09912_i2c.c)
endif()
if(CONFIG_SENSORS_AK09912_SCU)
list(APPEND SRCS src/cxd56_ak09912_scu.c)
endif()
if(CONFIG_SENSORS_APDS9930_SCU)
list(APPEND SRCS src/cxd56_apds9930_scu.c)
endif()
if(CONFIG_SENSORS_APDS9960)
list(APPEND SRCS src/cxd56_apds9960_i2c.c)
endif()
if(CONFIG_SENSORS_BH1721FVC_SCU)
list(APPEND SRCS src/cxd56_bh1721fvc_scu.c)
endif()
if(CONFIG_SENSORS_BH1745NUC_SCU)
list(APPEND SRCS src/cxd56_bh1745nuc_scu.c)
endif()
if(CONFIG_SENSORS_BM1383GLV_SCU)
list(APPEND SRCS src/cxd56_bm1383glv_scu.c)
endif()
if(CONFIG_SENSORS_BM1422GMV_SCU)
list(APPEND SRCS src/cxd56_bm1422gmv_scu.c)
endif()
if(CONFIG_SENSORS_BMI160_I2C)
list(APPEND SRCS src/cxd56_bmi160_i2c.c)
endif()
if(CONFIG_SENSORS_BMI160_SCU)
list(APPEND SRCS src/cxd56_bmi160_scu.c)
endif()
if(CONFIG_SENSORS_BMI160_SPI)
list(APPEND SRCS src/cxd56_bmi160_spi.c)
endif()
if(CONFIG_SENSORS_BMP280)
list(APPEND SRCS src/cxd56_bmp280_i2c.c)
endif()
if(CONFIG_SENSORS_BMP280_SCU)
list(APPEND SRCS src/cxd56_bmp280_scu.c)
endif()
if(CONFIG_SENSORS_KX022_SCU)
list(APPEND SRCS src/cxd56_kx022_scu.c)
endif()
if(CONFIG_SENSORS_LT1PA01_SCU)
list(APPEND SRCS src/cxd56_lt1pa01_scu.c)
endif()
if(CONFIG_SENSORS_RPR0521RS_SCU)
list(APPEND SRCS src/cxd56_rpr0521rs_scu.c)
endif()
if(CONFIG_SENSORS_SCD41)
list(APPEND SRCS src/cxd56_scd41_i2c.c)
endif()
if(CONFIG_NETDEVICES)
list(APPEND SRCS src/cxd56_netinit.c)
endif()
if(CONFIG_WL_GS2200M)
list(APPEND SRCS src/cxd56_gs2200m.c)
endif()
if(CONFIG_LCD_ILI9340)
list(APPEND SRCS src/cxd56_ili9340.c)
endif()
if(CONFIG_LCD_LPM013M091A)
list(APPEND SRCS src/cxd56_lpm013m091a.c)
endif()
if(CONFIG_CXD56_SFC)
list(APPEND SRCS src/cxd56_flash.c)
endif()
if(CONFIG_USBMSC)
list(APPEND SRCS src/cxd56_usbmsc.c)
endif()
if(CONFIG_CXD56_I2C_DRIVER)
list(APPEND SRCS src/cxd56_i2cdev.c)
endif()
if(CONFIG_I2C_BITBANG)
list(APPEND SRCS src/cxd56_i2cdev_bitbang.c)
endif()
if(CONFIG_CXD56_SPI_DRIVER)
list(APPEND SRCS src/cxd56_spidev.c)
endif()
if(CONFIG_VIDEO_ISX012)
list(APPEND SRCS src/cxd56_isx012.c)
endif()
if(CONFIG_VIDEO_ISX019)
list(APPEND SRCS src/cxd56_isx019.c)
endif()
if(CONFIG_CXD56_IMAGEPROC)
list(APPEND SRCS src/cxd56_imageproc.c)
endif()
if(CONFIG_BCM20706)
list(APPEND SRCS src/cxd56_bcm20706.c)
endif()
if(CONFIG_CXD56_EMMC)
list(APPEND SRCS src/cxd56_emmcdev.c)
endif()
if(CONFIG_CXD56_SPISD)
list(APPEND SRCS src/cxd56_spisd.c)
endif()
if(CONFIG_BOARD_USBDEV_SERIALSTR)
list(APPEND SRCS src/cxd56_usbdevserialstr.c)
endif()
target_sources(board PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,45 @@
# ##############################################################################
# boards/arm/cxd56xx/spresense/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_subdirectory(src)
if(NOT CONFIG_BUILD_FLAT)
add_subdirectory(kernel)
set_property(
GLOBAL PROPERTY LD_SCRIPT_USER ${CMAKE_CURRENT_LIST_DIR}/scripts/memory.ld
${CMAKE_CURRENT_LIST_DIR}/scripts/user-space.ld)
endif()
ExternalProject_Add(
nuttx_post_build
SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools/cxd56
INSTALL_DIR ${CMAKE_BINARY_DIR}/tools/cxd56
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
USES_TERMINAL_CONFIGURE true
USES_TERMINAL_BUILD true
USES_TERMINAL_INSTALL true
DEPENDS nuttx)
add_custom_command(
TARGET nuttx_post_build
POST_BUILD
BYPRODUCTS nuttx.spk
COMMAND ${CMAKE_BINARY_DIR}/bin/mkspk -c2 nuttx nuttx nuttx.spk
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

View File

@ -0,0 +1,89 @@
# ##############################################################################
# boards/arm/cxd56xx/spresense/src/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS)
set(SRCS cxd56_main.c cxd56_clock.c cxd56_bringup.c)
if(CONFIG_BOARDCTL)
list(APPEND SRCS cxd56_appinit.c)
list(APPEND SRCS cxd56_power.c)
endif()
if(CONFIG_BOARDCTL_IOCTL)
list(APPEND SRCS cxd56_ioctl.c)
endif()
if(CONFIG_ARCH_LEDS)
list(APPEND SRCS cxd56_leds.c)
elseif(CONFIG_USERLED)
list(APPEND SRCS cxd56_userleds.c)
endif()
if(CONFIG_ARCH_BUTTONS)
list(APPEND SRCS cxd56_buttons.c)
endif()
if(CONFIG_CXD56_GPIO_IRQ)
list(APPEND SRCS cxd56_gpioif.c)
endif()
if(CONFIG_CXD56_PWM)
list(APPEND SRCS cxd56_pwm.c)
endif()
if(CONFIG_SPI)
list(APPEND SRCS cxd56_spi.c)
endif()
if(CONFIG_CXD56_SDIO)
list(APPEND SRCS cxd56_sdcard.c)
endif()
if(CONFIG_CXD56_SDCARD_AUTOMOUNT)
list(APPEND SRCS cxd56_automount.c)
endif()
if(CONFIG_CXD56_GAUGE)
list(APPEND SRCS cxd56_gauge.c)
endif()
if(CONFIG_CXD56_CHARGER)
list(APPEND SRCS cxd56_charger.c)
endif()
if(CONFIG_USBDEV_COMPOSITE)
list(APPEND SRCS cxd56_composite.c)
endif()
if(CONFIG_MODEM_ALT1250)
list(APPEND SRCS cxd56_alt1250_power.c)
endif()
target_sources(board PRIVATE ${SRCS})
if(CONFIG_CXD56_USE_SYSBUS)
set(LDSCRIPT ramconfig-new.ld)
else()
set(LDSCRIPT ramconfig.ld)
endif()
# TODO: make this the default and then allow boards to redefine
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/${LDSCRIPT}")

View File

@ -0,0 +1,28 @@
# ##############################################################################
# boards/arm/imx6/sabre-6quad/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_subdirectory(src)
if(NOT CONFIG_BUILD_FLAT)
add_subdirectory(kernel)
set_property(
GLOBAL PROPERTY LD_SCRIPT_USER ${CMAKE_CURRENT_LIST_DIR}/scripts/memory.ld
${CMAKE_CURRENT_LIST_DIR}/scripts/user-space.ld)
endif()

View File

@ -0,0 +1,36 @@
# ##############################################################################
# boards/arm/imx6/sabre-6quad/src/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS imx_boardinit.c imx_bringup.c)
if(CONFIG_BOARDCTL)
list(APPEND SRCS imx_appinit.c)
endif()
if(CONFIG_ARCH_LEDS)
list(APPEND SRCS imx_autoleds.c)
else()
list(APPEND SRCS imx_userleds.c)
endif()
target_sources(board PRIVATE ${SRCS})
# TODO: make this the default and then allow boards to redefine
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/dramboot.ld")

View File

@ -0,0 +1,22 @@
# ##############################################################################
# boards/arm/stm32/common/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_subdirectory(src)
target_include_directories(board PRIVATE include)

View File

@ -0,0 +1,127 @@
# ##############################################################################
# boards/arm/stm32/common/src/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS)
if(CONFIG_SENSORS_BMP180)
list(APPEND SRCS stm32_bmp180.c)
endif()
if(CONFIG_LEDS_APA102)
list(APPEND SRCS stm32_apa102.c)
endif()
if(CONFIG_WS2812)
list(APPEND SRCS stm32_ws2812.c)
endif()
if(CONFIG_SENSORS_MAX6675)
list(APPEND SRCS stm32_max6675.c)
endif()
if(CONFIG_SENSORS_VEML6070)
list(APPEND SRCS stm32_veml6070.c)
endif()
if(CONFIG_INPUT_NUNCHUCK)
list(APPEND SRCS stm32_nunchuck.c)
endif()
if(CONFIG_AUDIO_TONE)
list(APPEND SRCS stm32_tone.c)
endif()
if(CONFIG_LCD_BACKPACK)
list(APPEND SRCS stm32_lcd_backpack.c)
endif()
if(CONFIG_LCD_SSD1306)
list(APPEND SRCS stm32_ssd1306.c)
endif()
if(CONFIG_SENSORS_LM75)
list(APPEND SRCS stm32_lm75.c)
endif()
if(CONFIG_WL_NRF24L01)
list(APPEND SRCS stm32_nrf24l01.c)
endif()
if(CONFIG_SENSORS_HCSR04)
list(APPEND SRCS stm32_hcsr04.c)
endif()
if(CONFIG_SENSORS_APDS9960)
list(APPEND SRCS stm32_apds9960.c)
endif()
if(CONFIG_SENSORS_ZEROCROSS)
list(APPEND SRCS stm32_zerocross.c)
endif()
if(CONFIG_SENSORS_QENCODER)
list(APPEND SRCS stm32_qencoder.c)
endif()
if(CONFIG_SENSORS_INA219)
list(APPEND SRCS stm32_ina219.c)
endif()
if(CONFIG_SENSORS_L3GD20)
list(APPEND SRCS stm32_l3gd20.c)
endif()
if(CONFIG_SENSORS_MPL115A)
list(APPEND SRCS stm32_mpl115a.c)
endif()
if(CONFIG_SENSORS_DHTXX)
list(APPEND SRCS stm32_dhtxx.c)
endif()
if(CONFIG_SENSORS_XEN1210)
list(APPEND SRCS stm32_xen1210.c)
endif()
if(CONFIG_SENSORS_BH1750FVI)
list(APPEND SRCS stm32_bh1750.c)
endif()
if(CONFIG_SENSORS_MLX90614)
list(APPEND SRCS stm32_mlx90614.c)
endif()
if(CONFIG_SENSORS_MAX31855)
list(APPEND SRCS stm32_max31855.c)
endif()
if(CONFIG_LIS3DSH)
list(APPEND SRCS stm32_lis3dsh.c)
endif()
if(CONFIG_BOARD_STM32_IHM07M1)
list(APPEND SRCS stm32_ihm07m1.c)
endif()
if(CONFIG_BOARD_STM32_IHM08M1)
list(APPEND SRCS stm32_ihm08m1.c)
endif()
target_sources(board PRIVATE ${SRCS})

View File

@ -0,0 +1,21 @@
# ##############################################################################
# boards/arm/stm32/stm32f103-minimum/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_subdirectory(src)

View File

@ -0,0 +1,153 @@
# ##############################################################################
# boards/arm/stm32/stm32f103-minimum/src/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(CSRCS)
list(APPEND CSRCS stm32_boot.c stm32_bringup.c stm32_spi.c)
if("${CONFIG_LIB_BOARDCTL}" STREQUAL "y")
list(APPEND CSRCS stm32_appinit.c)
endif()
if("${CONFIG_ARCH_BUTTONS}" STREQUAL "y")
list(APPEND CSRCS stm32_buttons.c)
endif()
if("${CONFIG_ARCH_LEDS}" STREQUAL "y")
list(APPEND CSRCS stm32_autoleds.c)
else()
list(APPEND CSRCS stm32_userleds.c)
endif()
if("${CONFIG_ADC}" STREQUAL "y")
list(APPEND CSRCS stm32_adc.c)
endif()
if("${CONFIG_DEV_GPIO}" STREQUAL "y")
list(APPEND CSRCS stm32_gpio.c)
endif()
if("${CONFIG_PWM}" STREQUAL "y")
list(APPEND CSRCS stm32_pwm.c)
endif()
if("${CONFIG_SENSORS_ZEROCROSS}" STREQUAL "y")
list(APPEND CSRCS stm32_zerocross.c)
endif()
if("${CONFIG_LEDS_APA102}" STREQUAL "y")
list(APPEND CSRCS stm32_apa102.c)
endif()
if("${CONFIG_SENSORS_BMP180}" STREQUAL "y")
list(APPEND CSRCS stm32_bmp180.c)
endif()
if("${CONFIG_LM75_I2C}" STREQUAL "y")
list(APPEND CSRCS stm32_lm75.c)
endif()
if("${CONFIG_RGBLED}" STREQUAL "y")
list(APPEND CSRCS stm32_rgbled.c)
endif()
if("${CONFIG_MMCSD}" STREQUAL "y")
list(APPEND CSRCS stm32_mmcsd.c)
endif()
if("${CONFIG_MTD_W25}" STREQUAL "y")
list(APPEND CSRCS stm32_w25.c)
endif()
if("${CONFIG_MTD_AT24XX}" STREQUAL "y")
if("${CONFIG_STM32_I2C1}" STREQUAL "y")
list(APPEND CSRCS stm32_at24.c)
endif()
endif()
if("${CONFIG_AUDIO_TONE}" STREQUAL "y")
list(APPEND CSRCS stm32_tone.c)
endif()
if("${CONFIG_CAN_MCP2515}" STREQUAL "y")
list(APPEND CSRCS stm32_mcp2515.c)
endif()
if("${CONFIG_CL_MFRC522}" STREQUAL "y")
list(APPEND CSRCS stm32_mfrc522.c)
endif()
if("${CONFIG_SENSORS_HCSR04}" STREQUAL "y")
list(APPEND CSRCS stm32_hcsr04.c)
endif()
if("${CONFIG_SENSORS_MAX6675}" STREQUAL "y")
list(APPEND CSRCS stm32_max6675.c)
endif()
if("${CONFIG_LCD_MAX7219}" STREQUAL "y")
list(APPEND CSRCS stm32_max7219.c)
endif()
if("${CONFIG_INPUT_NUNCHUCK}" STREQUAL "y")
list(APPEND CSRCS stm32_nunchuck.c)
endif()
if("${CONFIG_LCD_SSD1306_I2C}" STREQUAL "y")
list(APPEND CSRCS stm32_ssd1306.c)
endif()
if("${CONFIG_LCD_ST7567}" STREQUAL "y")
list(APPEND CSRCS stm32_lcd.c)
endif()
if("${CONFIG_LCD_PCD8544}" STREQUAL "y")
list(APPEND CSRCS stm32_pcd8544.c)
endif()
if("${CONFIG_SENSORS_APDS9960}" STREQUAL "y")
list(APPEND CSRCS stm32_apds9960.c)
endif()
if("${CONFIG_SENSORS_QENCODER}" STREQUAL "y")
list(APPEND CSRCS stm32_qencoder.c)
endif()
if("${CONFIG_SENSORS_VEML6070}" STREQUAL "y")
list(APPEND CSRCS stm32_veml6070.c)
endif()
if("${CONFIG_WL_NRF24L01}" STREQUAL "y")
list(APPEND CSRCS stm32_nrf24l01.c)
endif()
if("${CONFIG_USBDEV}" STREQUAL "y")
list(APPEND CSRCS stm32_usbdev.c)
endif()
if("${CONFIG_USBMSC}" STREQUAL "y")
list(APPEND CSRCS stm32_usbmsc.c)
endif()
target_sources(board PRIVATE ${CSRCS})
# Configure linker script TODO: better to place this in boards/CMakeLists.txt?
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/ld.script")

View File

@ -0,0 +1,28 @@
# ##############################################################################
# boards/arm/stm32/stm32f4discovery/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_subdirectory(src)
if(NOT CONFIG_BUILD_FLAT)
add_subdirectory(kernel)
set_property(
GLOBAL PROPERTY LD_SCRIPT_USER ${CMAKE_CURRENT_LIST_DIR}/scripts/memory.ld
${CMAKE_CURRENT_LIST_DIR}/scripts/user-space.ld)
endif()

View File

@ -0,0 +1,21 @@
# ##############################################################################
# boards/arm/stm32/stm32f4discovery/kernel/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
nuttx_add_aux_library(userspace stm32_userspace.c)

View File

@ -0,0 +1,224 @@
# ##############################################################################
# boards/arm/stm32/stm32f4discovery/src/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS stm32_boot.c stm32_bringup.c stm32_spi.c)
if(CONFIG_ARCH_LEDS)
list(APPEND SRCS stm32_autoleds.c)
else()
list(APPEND SRCS stm32_userleds.c)
endif()
if(CONFIG_AUDIO_CS43L22)
list(APPEND SRCS stm32_cs43l22.c)
endif()
if(CONFIG_ARCH_BUTTONS)
list(APPEND SRCS stm32_buttons.c)
endif()
if(CONFIG_STM32_CAN_CHARDRIVER)
list(APPEND SRCS stm32_can.c)
endif()
if(CONFIG_STM32_OTGFS)
list(APPEND SRCS stm32_usb.c)
endif()
if(CONFIG_LCD_ST7567)
list(APPEND SRCS stm32_st7567.c)
endif()
if(CONFIG_ENC28J60)
list(APPEND SRCS stm32_enc28j60.c)
endif()
if(CONFIG_LPWAN_SX127X)
list(APPEND SRCS stm32_sx127x.c)
endif()
if(CONFIG_LCD_MAX7219)
list(APPEND SRCS stm32_max7219.c)
endif()
if(CONFIG_LCD_ST7032)
list(APPEND SRCS stm32_st7032.c)
endif()
if(CONFIG_PCA9635PW)
list(APPEND SRCS stm32_pca9635.c)
endif()
if(CONFIG_STM32_SDIO)
list(APPEND SRCS stm32_sdio.c)
endif()
if(CONFIG_STM32_ETHMAC)
list(APPEND SRCS stm32_ethernet.c)
endif()
if(CONFIG_LEDS_MAX7219)
list(APPEND SRCS stm32_max7219_leds.c)
endif()
if(CONFIG_RGBLED)
list(APPEND SRCS stm32_rgbled.c)
endif()
if(CONFIG_RTC_DS1307)
list(APPEND SRCS stm32_ds1307.c)
endif()
if(CONFIG_PWM)
list(APPEND SRCS stm32_pwm.c)
endif()
if(CONFIG_BOARDCTL)
list(APPEND SRCS stm32_appinit.c)
if(CONFIG_BOARDCTL_RESET)
list(APPEND SRCS stm32_reset.c)
endif()
endif()
if(CONFIG_ARCH_CUSTOM_PMINIT)
list(APPEND SRCS stm32_pm.c)
endif()
if(CONFIG_PM_BUTTONS)
list(APPEND SRCS stm32_pmbuttons.c)
endif()
if(CONFIG_ARCH_IDLE_CUSTOM)
list(APPEND SRCS stm32_idle.c)
endif()
if(CONFIG_STM32_FSMC)
list(APPEND SRCS stm32_extmem.c)
if(CONFIG_LCD_SSD1289)
list(APPEND SRCS stm32_ssd1289.c)
endif()
endif()
if(CONFIG_LCD_SSD1351)
list(APPEND SRCS stm32_ssd1351.c)
endif()
if(CONFIG_LCD_UG2864AMBAG01)
list(APPEND SRCS stm32_ug2864ambag01.c)
endif()
if(CONFIG_LCD_UG2864HSWEG01)
list(APPEND SRCS stm32_ug2864hsweg01.c)
endif()
if(CONFIG_TIMER)
list(APPEND SRCS stm32_timer.c)
endif()
if(CONFIG_STM32_HCIUART)
if(CONFIG_BLUETOOTH_UART)
list(APPEND SRCS stm32_hciuart.c)
endif()
endif()
if(CONFIG_STM32_ROMFS)
list(APPEND SRCS stm32_romfs_initialize.c)
endif()
if(CONFIG_BOARDCTL_UNIQUEID)
list(APPEND SRCS stm32_uid.c)
endif()
if(CONFIG_USBMSC)
list(APPEND SRCS stm32_usbmsc.c)
endif()
if(NOT CONFIG_STM32_ETHMAC)
if(CONFIG_NETDEVICES)
list(APPEND SRCS stm32_netinit.c)
endif()
endif()
if(CONFIG_MMCSD_SPI)
list(APPEND SRCS stm32_mmcsd.c)
endif()
if(CONFIG_WL_GS2200M)
list(APPEND SRCS stm32_gs2200m.c)
endif()
if(CONFIG_LCD_ST7789)
list(APPEND SRCS stm32_st7789.c)
endif()
target_sources(board PRIVATE ${SRCS})
# TODO: make this the default and then allow boards to redefine
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/ld.script")
# TODO:move this to apropriate arch/toolchain level
set_property(
GLOBAL APPEND
PROPERTY COMPILE_OPTIONS $<$<CONFIG:Release>:-fno-strict-aliasing
-fomit-frame-pointer>)
# TODO: see where to put pic flags set_property(TARGET nuttx APPEND PROPERTY
# NUTTX_COMPILE_OPTIONS $<$<NOT:$<COMPILE_LANGUAGE:ASM>>:-fpic -msingle-pic-base
# -mpic-register=r10>)
# ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANGL),y) ARCHCFLAGS += -nostdlib
# -ffreestanding ARCHCXXFLAGS += -nostdlib -ffreestanding else ARCHCFLAGS +=
# -funwind-tables ARCHCXXFLAGS += -fno-rtti -funwind-tables ifneq
# ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif endif
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_COMPILE_OPTIONS -funwind-tables)
set_property(GLOBAL APPEND PROPERTY COMPILE_OPTIONS -fno-strength-reduce)
# TODO: nxflat NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 =
# $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld
# -no-check-sections LDNXFLATFLAGS = -e main -s 2048
# Loadable module definitions
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_MODULE_COMPILE_OPTIONS -mlong-calls)
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_MODULE_LINK_OPTIONS -r -e module_initialize -T
${NUTTX_DIR}/libs/libc/modlib/gnu-elf.ld)
# ELF module definitions
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_APP_COMPILE_OPTIONS -mlong-calls)
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_ELF_APP_LINK_OPTIONS -r -e main
-T${NUTTX_BOARD_DIR}/scripts/gnu-elf.ld)

View File

@ -0,0 +1,28 @@
# ##############################################################################
# boards/arm/stm32u5/b-u585i-iot02a/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_subdirectory(src)
if(NOT CONFIG_BUILD_FLAT)
add_subdirectory(kernel)
set_property(
GLOBAL PROPERTY LD_SCRIPT_USER ${CMAKE_CURRENT_LIST_DIR}/scripts/memory.ld
${CMAKE_CURRENT_LIST_DIR}/scripts/user-space.ld)
endif()

View File

@ -0,0 +1,34 @@
# ##############################################################################
# boards/arm/stm32u5/b-u585i-iot02a/src/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS stm32_boot.c stm32_bringup.c stm32_spi.c)
if(CONFIG_BOARDCTL)
list(APPEND SRCS stm32_appinit.c)
endif()
if(CONFIG_ARCH_BOARD_STM32U5_CUSTOM_CLOCKCONFIG)
list(APPEND SRCS stm32_clockconfig.c)
endif()
target_sources(board PRIVATE ${SRCS})
# TODO: make this the default and then allow boards to redefine
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld")

View File

@ -0,0 +1,28 @@
# ##############################################################################
# boards/arm/tiva/lm3s6965-ek/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_subdirectory(src)
if(NOT CONFIG_BUILD_FLAT)
add_subdirectory(kernel)
set_property(
GLOBAL PROPERTY LD_SCRIPT_USER ${CMAKE_CURRENT_LIST_DIR}/scripts/memory.ld
${CMAKE_CURRENT_LIST_DIR}/scripts/user-space.ld)
endif()

View File

@ -0,0 +1,40 @@
# ##############################################################################
# boards/arm/tiva/lm3s6965-ek/src/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS lm_boot.c lm_leds.c lm_ethernet.c lm_ssi.c)
if(CONFIG_BOARDCTL)
list(APPEND SRCS lm_appinit.c)
endif()
if(CONFIG_NX_LCDDRIVER)
list(APPEND SRCS lm_oled.c)
endif()
if(CONFIG_BOARD_LATE_INITIALIZE)
list(APPEND SRCS lm_bringup.c)
elseif(CONFIG_BOARDCTL)
list(APPEND SRCS lm_bringup.c)
endif()
target_sources(board PRIVATE ${SRCS})
# TODO: make this the default and then allow boards to redefine
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/ld.script")

View File

@ -0,0 +1,21 @@
# ##############################################################################
# boards/sim/sim/sim/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
add_subdirectory(src)

View File

@ -6,7 +6,6 @@
# modifications. # modifications.
# #
# CONFIG_NSH_CMDOPT_HEXDUMP is not set # CONFIG_NSH_CMDOPT_HEXDUMP is not set
CONFIG_ALLSYMS=y
CONFIG_ARCH="sim" CONFIG_ARCH="sim"
CONFIG_ARCH_BOARD="sim" CONFIG_ARCH_BOARD="sim"
CONFIG_ARCH_BOARD_SIM=y CONFIG_ARCH_BOARD_SIM=y

View File

@ -0,0 +1,79 @@
# ##############################################################################
# boards/sim/sim/sim/src/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# CSRCS = dummy.c
if(CONFIG_BOARD_LATE_INITIALIZE)
list(APPEND SRCS sim_boot.c)
endif()
if(CONFIG_BOARDCTL)
list(APPEND SRCS sim_appinit.c)
endif()
if(CONFIG_BOARD_LATE_INITIALIZE)
list(APPEND SRCS sim_bringup.c)
if(CONFIG_LIBC_ZONEINFO_ROMFS)
list(APPEND SRCS sim_zoneinfo.c)
endif()
elseif(CONFIG_BOARDCTL)
list(APPEND SRCS sim_bringup.c)
if(CONFIG_LIBC_ZONEINFO_ROMFS)
list(APPEND SRCS sim_zoneinfo.c)
endif()
endif()
if(CONFIG_EXAMPLES_GPIO)
if(CONFIG_GPIO_LOWER_HALF)
list(APPEND SRCS sim_ioexpander.c)
else()
list(APPEND SRCS sim_gpio.c)
endif()
endif()
if(CONFIG_ARCH_BUTTONS)
list(APPEND SRCS sim_buttons.c)
endif()
if(CONFIG_MOTOR_FOC_DUMMY)
list(APPEND SRCS sim_foc.c)
endif()
target_sources(board PRIVATE ${SRCS})
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/gnu-elf.ld")
if(CONFIG_NSH_ROMFSETC AND CONFIG_NSH_ARCHROMFS)
nuttx_add_romfs(
NAME
etc
MOUNTPOINT
etc
RCSRCS
etc/init.d/rcS
etc/init.d/rc.sysinit
RCRAWS
etc/group
etc/passwd
PATH
${CMAKE_CURRENT_BINARY_DIR}/etc)
target_link_libraries(board PRIVATE romfs_etc)
endif()

115
cmake/menuconfig.cmake Normal file
View File

@ -0,0 +1,115 @@
# ##############################################################################
# cmake/menuconfig.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# menuconfig target this triggers a reconfiguration (TODO: do only if config
# changes)
set(KCONFIG_ENV
"KCONFIG_CONFIG=${CMAKE_BINARY_DIR}/.config"
"EXTERNALDIR=dummy"
"APPSDIR=${NUTTX_APPS_DIR}"
"DRIVERS_PLATFORM_DIR=dummy"
"APPSBINDIR=${NUTTX_APPS_BINDIR}"
"BINDIR=${CMAKE_BINARY_DIR}"
"HOST_LINUX=$<IF:$<BOOL:{LINUX}>,y,n>"
"HOST_MACOS=$<IF:$<BOOL:${APPLE}>,y,n>"
"HOST_WINDOWS=$<IF:$<BOOL:${WIN32}>,y,n>"
"HOST_OTHER=$<IF:$<BOOL:${OTHER_OS}>,y,n>")
# Use qconfig instead of menuconfig since PowerShell not support curses
# redirection
if(WIN32)
set(MENUCONFIG guiconfig)
else()
set(MENUCONFIG menuconfig)
endif()
add_custom_target(
menuconfig
COMMAND ${CMAKE_COMMAND} -E env ${KCONFIG_ENV} ${MENUCONFIG}
COMMAND ${CMAKE_COMMAND} -E remove -f
${CMAKE_BINARY_DIR}/include/nuttx/config.h # invalidate existing
# config
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_PARENT_LIST_FILE}
WORKING_DIRECTORY ${NUTTX_DIR}
USES_TERMINAL)
# qconfig target
add_custom_target(
qconfig
COMMAND ${CMAKE_COMMAND} -E env ${KCONFIG_ENV} guiconfig
COMMAND ${CMAKE_COMMAND} -E remove -f
${CMAKE_BINARY_DIR}/include/nuttx/config.h # invalidate existing
# config
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_PARENT_LIST_FILE}
WORKING_DIRECTORY ${NUTTX_DIR}
USES_TERMINAL)
add_custom_target(
savedefconfig
COMMAND ${CMAKE_COMMAND} -E env ${KCONFIG_ENV} savedefconfig --out
${CMAKE_BINARY_DIR}/defconfig.tmp
COMMAND grep "CONFIG_ARCH=" ${CMAKE_BINARY_DIR}/.config >>
${CMAKE_BINARY_DIR}/defconfig.tmp
COMMAND grep "^CONFIG_ARCH_CHIP_" ${CMAKE_BINARY_DIR}/.config >>
${CMAKE_BINARY_DIR}/defconfig.tmp
COMMAND grep "CONFIG_ARCH_CHIP=" ${CMAKE_BINARY_DIR}/.config >>
${CMAKE_BINARY_DIR}/defconfig.tmp
COMMAND grep "CONFIG_ARCH_BOARD=" ${CMAKE_BINARY_DIR}/.config >>
${CMAKE_BINARY_DIR}/defconfig.tmp || true
COMMAND grep "^CONFIG_ARCH_CUSTOM" ${CMAKE_BINARY_DIR}/.config >>
${CMAKE_BINARY_DIR}/defconfig.tmp || true
COMMAND grep "^CONFIG_ARCH_BOARD_CUSTOM" ${CMAKE_BINARY_DIR}/.config >>
${CMAKE_BINARY_DIR}/defconfig.tmp || true
COMMAND export LC_ALL=C && cat ${CMAKE_BINARY_DIR}/defconfig.tmp | sort | uniq
> ${CMAKE_BINARY_DIR}/sortedconfig.tmp || true
COMMAND echo "\\#" > ${CMAKE_BINARY_DIR}/warning.tmp || true
COMMAND echo "\\# This file is autogenerated: PLEASE DO NOT EDIT IT." >>
${CMAKE_BINARY_DIR}/warning.tmp
COMMAND echo "\\#" >> ${CMAKE_BINARY_DIR}/warning.tmp
COMMAND
echo
"\\# You can use make menuconfig to make any modifications to the installed .config file."
>> ${CMAKE_BINARY_DIR}/warning.tmp
COMMAND
echo
"\\# You can then do make savedefconfig or cmake -t savedefconfig to generate a new defconfig file that includes your"
>> ${CMAKE_BINARY_DIR}/warning.tmp
COMMAND echo "\\# modifications." >> ${CMAKE_BINARY_DIR}/warning.tmp
COMMAND echo "\\#" >> ${CMAKE_BINARY_DIR}/warning.tmp
COMMAND cat ${CMAKE_BINARY_DIR}/warning.tmp
${CMAKE_BINARY_DIR}/sortedconfig.tmp > ${CMAKE_BINARY_DIR}/defconfig
COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/warning.tmp
COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/defconfig.tmp
COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/sortedconfig.tmp
WORKING_DIRECTORY ${NUTTX_DIR})
# utility target to restore .config from board's defconfig
add_custom_target(
resetconfig
COMMAND ${CMAKE_COMMAND} -E copy ${NUTTX_DEFCONFIG}
${CMAKE_BINARY_DIR}/.config
COMMAND ${CMAKE_COMMAND} -E env ${KCONFIG_ENV} olddefconfig
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/.config
${CMAKE_BINARY_DIR}/.config.orig
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_PARENT_LIST_FILE}
WORKING_DIRECTORY ${NUTTX_DIR})

View File

@ -0,0 +1,192 @@
# ##############################################################################
# cmake/nuttx_add_application.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
include(nuttx_parse_function_args)
define_property(
GLOBAL
PROPERTY NUTTX_APPS_LIBRARIES
BRIEF_DOCS "NuttX application libs"
FULL_DOCS "List of all NuttX application libraries")
# nuttx_add_application
#
# Description: Declares a NuttX application as a static library. The
# corresponding target will be named apps_<NAME>. The first entry into the
# source list is assumed to be the one containing main() and will thus receive a
# -Dmain=app_main definition during build.
#
# Usage: nuttx_add_application( NAME <string> [ PRIORITY <string> ] [ STACKSIZE
# <string> ] [ COMPILE_FLAGS <list> ] [ INCLUDE_DIRECTORIES <list> ] [ DEPENDS
# <string> ] [ MODULE <string> ] [ SRCS <list> ] )
#
# Parameters: NAME : unique name of application PRIORITY :
# priority STACKSIZE : stack size COMPILE_FLAGS : compile flags SRCS :
# source files MODULE : if "m", build module (designed to received
# CONFIG_<app> value) DEPENDS : targets which this module depends on
# NO_MAIN_ALIAS : do not add a main=<app>_main alias(*)
#
# (*) This is only really needed in convoluted cases where a single .c file
# contains differently named <app>_main() entries for different <app>. This
# situation should really be changed into a separate main file per actual app
# using a shared user library.
#
# Example: nuttx_add_application( NAME test SRCS file.cpp STACKSIZE 1024 DEPENDS
# nshlib MODULE ${CONFIG_EXAMPLES_TEST} )
function(nuttx_add_application)
# parse arguments into variables
nuttx_parse_function_args(
FUNC
nuttx_add_application
ONE_VALUE
NAME
PRIORITY
STACKSIZE
MODULE
MULTI_VALUE
COMPILE_FLAGS
INCLUDE_DIRECTORIES
SRCS
DEPENDS
OPTIONS
NO_MAIN_ALIAS
REQUIRED
NAME
ARGN
${ARGN})
# create target
if(SRCS)
if(MODULE
AND ("${MODULE}" STREQUAL "m")
OR CONFIG_BUILD_KERNEL)
# create as standalone executable (loadable application or "module")
set(TARGET "${NAME}")
# Use ELF capable toolchain, by building manually and overwriting the
# non-elf output
if(NOT CMAKE_C_ELF_COMPILER)
add_library(${TARGET} ${SRCS})
add_custom_command(
TARGET ${TARGET}
POST_BUILD
COMMAND
${CMAKE_C_COMPILER}
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_ELF_APP_LINK_OPTIONS>>
$<TARGET_FILE:${TARGET}> -o ${TARGET}
COMMAND_EXPAND_LISTS)
else()
add_executable(${TARGET} ${SRCS})
target_link_options(
${TARGET} PRIVATE
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_ELF_APP_LINK_OPTIONS>>)
endif()
# easy access to final ELF, regardless of how it was created
set_property(TARGET ${TARGET}
PROPERTY ELF_BINARY ${CMAKE_CURRENT_BINARY_DIR}/${TARGET})
nuttx_add_library_internal(${TARGET})
install(TARGETS ${TARGET})
set_property(
TARGET nuttx
APPEND
PROPERTY NUTTX_LOADABLE_APPS ${TARGET})
else()
# create as library to be archived into libapps.a
set(TARGET "apps_${NAME}")
add_library(${TARGET} ${SRCS})
nuttx_add_library_internal(${TARGET})
# add to list of application libraries
set_property(GLOBAL APPEND PROPERTY NUTTX_APPS_LIBRARIES ${TARGET})
if(NOT NO_MAIN_ALIAS)
# provide main() alias
list(GET SRCS 0 MAIN_SRC)
set_property(
SOURCE ${MAIN_SRC}
APPEND
PROPERTY COMPILE_DEFINITIONS main=${NAME}_main)
endif()
endif()
# loadable build requires applying ELF flags to all applications
if(CONFIG_BUILD_LOADABLE)
target_compile_options(
${TARGET}
PRIVATE
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_ELF_APP_COMPILE_OPTIONS>>)
endif()
endif()
# store parameters into properties (used during builtin list generation)
set_target_properties(${TARGET} PROPERTIES APP_MAIN ${NAME}_main)
set_target_properties(${TARGET} PROPERTIES APP_NAME ${NAME})
if(PRIORITY)
set_target_properties(${TARGET} PROPERTIES APP_PRIORITY ${PRIORITY})
else()
set_target_properties(${TARGET} PROPERTIES APP_PRIORITY
SCHED_PRIORITY_DEFAULT)
endif()
if(STACKSIZE)
set_target_properties(${TARGET} PROPERTIES APP_STACK ${STACKSIZE})
else()
set_target_properties(${TARGET} PROPERTIES APP_STACK
${CONFIG_DEFAULT_TASK_STACKSIZE})
endif()
# compile options
if(COMPILE_FLAGS)
target_compile_options(${TARGET} PRIVATE ${COMPILE_FLAGS})
endif()
if(INCLUDE_DIRECTORIES)
foreach(inc ${INCLUDE_DIRECTORIES})
target_include_directories(${TARGET} PRIVATE ${inc})
endforeach()
endif()
# add supplied dependencies
if(DEPENDS)
# using target_link_libraries for dependencies provides linking as well as
# interface include and libraries
foreach(dep ${DEPENDS})
get_target_property(dep_type ${dep} TYPE)
# if (${dep_type} STREQUAL "STATIC_LIBRARY")
# target_link_libraries(${TARGET} PRIVATE ${dep}) else()
add_dependencies(${TARGET} ${dep})
# endif()
endforeach()
endif()
endfunction()

View File

@ -0,0 +1,177 @@
# ##############################################################################
# cmake/nuttx_add_library.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# Internal utility function
#
# Used by functions below, not to be used directly
function(nuttx_add_library_internal target)
# ensure nuttx_context is created before this
add_dependencies(${target} nuttx_context)
# add main include directories
target_include_directories(
${target} SYSTEM
PUBLIC ${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include
${CMAKE_BINARY_DIR}/include_arch)
# Set global compile options & definitions We use the "nuttx" target to hold
# these properties so that libraries added after this property is set can read
# the final value at build time. The GENEX_EVAL allows the property to hold
# generator expression itself
target_compile_options(
${target}
PRIVATE $<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_COMPILE_OPTIONS>>)
target_compile_definitions(
${target} PRIVATE $<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_DEFINITIONS>>)
target_include_directories(
${target}
PRIVATE $<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_INCLUDE_DIRECTORIES>>)
endfunction()
# Auxiliary libraries
#
# The whole purpose of this is to overcome the limitation of CMake 3.16 to set
# source file properties from directories different from the one defining the
# target where the source file is used. This auxiliary library acts as an
# intermediate target that is usually linked to the system/kernel library
# defined at a higher level.
function(nuttx_add_aux_library target)
# declare target
add_library(${target} OBJECT ${ARGN})
nuttx_add_library_internal(${target} ${ARGN})
endfunction()
# User (application) libraries
#
# An user library is a target which is defined as a collection of object files
# which is ultimately archived into the apps library
function(nuttx_add_user_library target)
# declare target
add_library(${target} OBJECT ${ARGN})
nuttx_add_library_internal(${target} ${ARGN})
# link to final libapps
target_link_libraries(apps INTERFACE ${target})
# add apps/include to include path
target_include_directories(${target} INTERFACE ${NUTTX_APPS_DIR}/include)
endfunction()
# System Libraries
#
# A system library is a library which is built into the OS but does not receive
# kernel-level flags (such as __KERNEL__). This is will be part of the userspace
# blob in kernel builds
function(nuttx_add_system_library target)
# declare target
add_library(${target} ${ARGN})
# add library to build
nuttx_add_library_internal(${target} ${ARGN})
# add to list of libraries to link to final nuttx binary
set_property(GLOBAL APPEND PROPERTY NUTTX_SYSTEM_LIBRARIES ${target})
# install to library dir
install(TARGETS ${target} DESTINATION lib)
endfunction()
# Kernel Libraries
#
# nuttx_add_kernel_library(target [SPLIT] [SAME_SOURCES] [sources ...])
#
# For non-kernel builds, this defines an OS library which will receive
# kernel-level flags (such as __KERNEL__) and will be linked into nuttx binary
# For kernel builds, the same happens unless SPLIT is specified. In this case
# both a <target> and a k<target> library will be defined, but only the latter
# having the kernel-level flags. In this case, both libraries will receive the
# same set of sources (the original <target> should be used by the user to add
# sources).
function(nuttx_add_kernel_library target)
cmake_parse_arguments(ARGS SPLIT "" "" ${ARGN})
set(SRCS ${ARGS_UNPARSED_ARGUMENTS})
if(ARGS_SPLIT AND NOT CONFIG_BUILD_FLAT)
set(kernel_target k${target})
# add non-kernel (system) library
nuttx_add_system_library(${target} ${SRCS})
else()
set(kernel_target ${target})
endif()
# add kernel library
add_library(${kernel_target} ${SRCS})
nuttx_add_library_internal(${kernel_target} ${SRCS})
set_property(GLOBAL APPEND PROPERTY NUTTX_KERNEL_LIBRARIES ${kernel_target})
# Add kernel options & definitions See note above in
# nuttx_add_library_internal() on syntax and nuttx target use
target_compile_options(
${kernel_target}
PRIVATE $<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_KERNEL_COMPILE_OPTIONS>>)
target_compile_definitions(
${kernel_target}
PRIVATE $<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_KERNEL_DEFINITIONS>>)
target_include_directories(
${kernel_target}
PRIVATE
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_KERNEL_INCLUDE_DIRECTORIES>>)
if(NOT "${target}" STREQUAL "${kernel_target}")
# The k${target} lib will have the same sources added to that ${target} lib.
# This allows to do target_sources(${target} ..) easily
target_sources(${kernel_target}
PRIVATE $<TARGET_PROPERTY:${target},SOURCES>)
# same for include directories
target_include_directories(
${kernel_target} PRIVATE $<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>)
endif()
endfunction()
include(nuttx_parse_function_args)
define_property(
GLOBAL
PROPERTY NUTTX_LIBRARIES
BRIEF_DOCS "NuttX libs"
FULL_DOCS "List of all NuttX libraries")
# =============================================================================
#
# nuttx_add_library
#
# Wrapper of cmake add_library but with nuttx platform dependencies
#
function(nuttx_add_library target)
add_library(${target} ${ARGN})
set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES ${target})
nuttx_add_library_internal(${target})
endfunction()

View File

@ -0,0 +1,57 @@
# ##############################################################################
# cmake/nuttx_add_module.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
function(nuttx_add_module target)
# Use ELF capable toolchain, by building manually and overwriting the non-elf
# output
if(CMAKE_C_ELF_COMPILER)
add_library(${target} ${ARGN})
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND
${CMAKE_C_ELF_COMPILER}
$<TARGET_PROPERTY:nuttx,NUTTX_ELF_MODULE_LINK_OPTIONS>
$<TARGET_FILE:${target}> -o ${target}
COMMAND_EXPAND_LISTS)
else()
add_executable(${target} ${ARGN})
target_link_options(
${target} PRIVATE
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_ELF_MODULE_LINK_OPTIONS>>)
endif()
set_property(TARGET ${target} PROPERTY ELF_BINARY
${CMAKE_CURRENT_BINARY_DIR}/${target})
nuttx_add_library_internal(${target})
target_compile_options(
${target}
PRIVATE
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_ELF_MODULE_COMPILE_OPTIONS>>)
target_compile_definitions(
${target}
PRIVATE $<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_ELF_MODULE_DEFINITIONS>>
$<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_KERNEL_DEFINITIONS>>)
install(TARGETS ${target})
endfunction()

158
cmake/nuttx_add_romfs.cmake Normal file
View File

@ -0,0 +1,158 @@
# ##############################################################################
# cmake/nuttx_add_romfs.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# nuttx_add_romfs Generates a ROMFS image in a C array, which is built to an
# OBJECT library.
#
# Parameters: - NAME: determines the romfs label and name of target
# (romfs_${NAME}) - HEADER: option to indicate that a .h file is to be generated
# instead of a .c - PREFIX: optional prefix to add to image name (as
# romfs_${PREFIX}.img) - NONCONST: option to indicate the array should be
# non-const - DEPENDS: list of targets that should be depended on
function(nuttx_add_romfs)
nuttx_parse_function_args(
FUNC
nuttx_add_romfs
ONE_VALUE
NAME
MOUNTPOINT
PATH
PREFIX
OPTIONS
HEADER
NONCONST
MULTI_VALUE
DEPENDS
RCSRCS
RCRAWS
REQUIRED
NAME
ARGN
${ARGN})
if(NOT PATH AND NOT FILES)
message(FATAL_ERROR "Either PATH or FILES must be specified")
endif()
foreach(rcsrc ${RCSRCS})
get_filename_component(rcpath ${rcsrc} DIRECTORY)
add_custom_command(
OUTPUT ${rcsrc}
COMMAND ${CMAKE_COMMAND} -E make_directory ${rcpath}
COMMAND
${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} -E -P -x c
-I${CMAKE_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/${rcsrc} >
${rcsrc}
DEPENDS nuttx_context ${CMAKE_CURRENT_SOURCE_DIR}/${rcsrc})
list(APPEND DEPENDS ${rcsrc})
endforeach()
foreach(rcraw ${RCRAWS})
get_filename_component(absrcraw ${rcraw} ABSOLUTE)
if(IS_DIRECTORY ${absrcraw})
file(
GLOB subdir
LIST_DIRECTORIES false
${rcraws} ${rcraw})
foreach(rcraw ${rcraws})
list(APPEND DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${rcraw})
configure_file(${rcraw} ${CMAKE_CURRENT_BINARY_DIR}/${rcraw} COPYONLY)
endforeach()
else()
list(APPEND DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${rcraw})
configure_file(${rcraw} ${CMAKE_CURRENT_BINARY_DIR}/${rcraw} COPYONLY)
endif()
endforeach()
if(HEADER)
set(EXTENSION h)
else()
set(EXTENSION c)
endif()
if(PREFIX)
set(IMGNAME ${PREFIX}.img)
else()
set(IMGNAME romfs.img)
endif()
add_custom_command(
OUTPUT romfs_${NAME}.${EXTENSION}
COMMAND ${CMAKE_COMMAND} -E make_directory romfs_${NAME}
COMMAND if \[ \"${PATH}\" != \"\" \]; then ${CMAKE_COMMAND} -E
copy_directory ${PATH} romfs_${NAME} \; fi
COMMAND genromfs -f ${IMGNAME} -d romfs_${NAME} -V ${NAME}
COMMAND xxd -i ${IMGNAME} romfs_${NAME}.${EXTENSION}
COMMAND ${CMAKE_COMMAND} -E remove ${IMGNAME}
COMMAND ${CMAKE_COMMAND} -E remove_directory romfs_${NAME}
COMMAND if ! [ -z "${NONCONST}" ]\; then sed -E -i'' -e
"s/^unsigned/const unsigned/g" romfs_${NAME}.${EXTENSION} \; fi
DEPENDS ${DEPENDS})
if(NOT HEADER)
add_custom_target(target-romfs DEPENDS ${DEPENDS})
nuttx_add_aux_library(romfs_${NAME})
target_sources(romfs_${NAME} PRIVATE romfs_${NAME}.${EXTENSION})
add_dependencies(romfs_${NAME} target-romfs)
endif()
endfunction()
# nuttx_add_cromfs Generates a CROMFS image in a C array, which is built to an
# OBJECT library.
#
# Parameters: - NAME: determines the name of target (cromfs_${NAME}) - PATH: the
# directory that will be used to create the CROMFS - FILES: paths to files to
# copy into CROMFS - DEPENDS: list of targets that should be depended on
function(nuttx_add_cromfs)
nuttx_parse_function_args(
FUNC
nuttx_add_cromfs
ONE_VALUE
NAME
MOUNTPOINT
PATH
MULTI_VALUE
DEPENDS
FILES
OPTIONS
REQUIRED
NAME
ARGN
${ARGN})
if(NOT PATH AND NOT FILES)
message(FATAL_ERROR "Either PATH or FILES must be specified")
endif()
add_custom_command(
OUTPUT cromfs_${NAME}.c
COMMAND ${CMAKE_COMMAND} -E make_directory cromfs_${NAME}
COMMAND if \[ \"${PATH}\" != \"\" \]; then ${CMAKE_COMMAND} -E
copy_directory ${PATH} cromfs_${NAME} \; fi
COMMAND if \[ \"${FILES}\" != \"\" \]; then ${CMAKE_COMMAND} -E copy
${FILES} cromfs_${NAME} \; fi
COMMAND ${CMAKE_BINARY_DIR}/bin/gencromfs cromfs_${NAME} cromfs_${NAME}.c
DEPENDS ${DEPENDS})
add_library(cromfs_${NAME} OBJECT cromfs_${NAME}.c)
nuttx_add_library_internal(cromfs_${NAME})
endfunction()

View File

@ -0,0 +1,32 @@
# ##############################################################################
# cmake/nuttx_add_subdirectory.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
function(nuttx_add_subdirectory)
file(
GLOB subdir
LIST_DIRECTORIES false
RELATIVE ${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/*/CMakeLists.txt)
foreach(dir ${subdir})
get_filename_component(dir ${dir} DIRECTORY)
add_subdirectory(${dir})
endforeach()
endfunction()

View File

@ -0,0 +1,103 @@
# ##############################################################################
# cmake/nuttx_add_symtab.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# nuttx_add_symtab Generates a symbol table of undefined symbols from a set of
# binaries
#
# Parameters: - NAME: name of symtab (output will be symtab_${NAME}.c) -
# BINARIES: list of binary target names to process (dependencies will be added
# to these targets) - PREFIX: optional prefix to add to symtab variable name -
# EXCLUDE: optional list of symbols to exclude (ie: assume they are defined)
function(nuttx_add_symtab)
nuttx_parse_function_args(
FUNC
nuttx_add_symtab
ONE_VALUE
NAME
PREFIX
OPTIONS
HEADER
MULTI_VALUE
EXCLUDE
BINARIES
REQUIRED
NAME
BINARIES
ARGN
${ARGN})
# get path to binaries
set(BINARY_PATHS)
foreach(binary ${BINARIES})
# this way of getting the path will select the actual ELF binary, even when
# this was built by means of an intermediate library on non-ELF platforms
list(APPEND BINARY_PATHS $<TARGET_PROPERTY:${binary},ELF_BINARY>)
endforeach()
if(EXCLUDE)
string(REPLACE ";" " " EXCLUDE_STRING ${EXCLUDE})
endif()
# generate list of undefined symbols
add_custom_command(
OUTPUT symtab_${NAME}.dat
COMMAND ${CMAKE_NM} ${BINARY_PATHS} | fgrep ' U ' | sed -e "s/^[ ]*//g" |
cut -d' ' -f2 | sort | uniq > symtab_${NAME}.dat
COMMAND
if [ \"${EXCLUDE}\" != \"\" ]\; then fgrep -v -x ${EXCLUDE_STRING}
symtab_${NAME}.dat > symtab_${NAME}.dat2\; mv symtab_${NAME}.dat2
symtab_${NAME}.dat\; fi
DEPENDS ${BINARIES})
add_custom_target(symtab_${NAME}_dat DEPENDS symtab_${NAME}.dat)
# generate declarations for symbols and symtab entries as headers
add_custom_command(
OUTPUT symtab_${NAME}_declarations.h symtab_${NAME}_entries.h
COMMAND sed -E 's|\(.+\)|extern void *\\1\;|g' symtab_${NAME}.dat >
symtab_${NAME}_declarations.h
COMMAND sed -E 's|\(.+\)|{ \"\\1\", \\&\\1 },|g' symtab_${NAME}.dat >
symtab_${NAME}_entries.h
DEPENDS symtab_${NAME}_dat)
# generate code which instantiates the symbol table
configure_file(${CMAKE_SOURCE_DIR}/cmake/symtab.c.in symtab_${NAME}.c @ONLY)
# define an internal library to build the symtab file on its own
add_library(symtab_${NAME} OBJECT
${CMAKE_CURRENT_BINARY_DIR}/symtab_${NAME}.c)
# Make the dependance between .c and .h explicit. This is necessary since
# using configure_file() does not seem to allow this to be automatically
# guessed by CMake
set_property(
SOURCE ${CMAKE_CURRENT_BINARY_DIR}/symtab_${NAME}.c
APPEND
PROPERTY OBJECT_DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/symtab_${NAME}_declarations.h
${CMAKE_CURRENT_BINARY_DIR}/symtab_${NAME}_entries.h)
nuttx_add_library_internal(symtab_${NAME})
if(PREFIX)
target_compile_definitions(symtab_${NAME} PRIVATE -DSYMTAB_PREFIX=${PREFIX})
endif()
endfunction()

View File

@ -0,0 +1,27 @@
# ##############################################################################
# cmake/nuttx_create_symlink.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
function(nuttx_create_symlink old new)
if(IS_DIRECTORY ${old} AND WIN32)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${old} ${new})
else()
file(CREATE_LINK ${old} ${new} COPY_ON_ERROR SYMBOLIC)
endif()
endfunction()

View File

@ -0,0 +1,149 @@
# ##############################################################################
# cmake/nuttx_generate_headers.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# setup target to generate config.h and version.h from mkconfig and mkversion
if(NOT EXISTS ${CMAKE_BINARY_DIR}/include)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/include/nuttx)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include/nuttx)
endif()
include(nuttx_mkconfig)
include(nuttx_mkversion)
# Setup symbolic link generation
if(NOT EXISTS ${CMAKE_BINARY_DIR}/include_arch/arch)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_BINARY_DIR}/include_arch/arch)
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/include_apps)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_BINARY_DIR}/include_apps)
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/include/arch)
nuttx_create_symlink(${NUTTX_DIR}/arch/${CONFIG_ARCH}/include
${CMAKE_BINARY_DIR}/include/arch)
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/include_arch/arch/board)
nuttx_create_symlink(${NUTTX_BOARD_DIR}/include
${CMAKE_BINARY_DIR}/include_arch/arch/board)
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/include_arch/arch/chip)
if(CONFIG_ARCH_CHIP_CUSTOM)
execute_process(
COMMAND ${CMAKE_COMMAND} -E copy_directory ${NUTTX_CHIP_ABS_DIR}/include
${CMAKE_BINARY_DIR}/include_arch/arch/chip)
else()
execute_process(
COMMAND
${CMAKE_COMMAND} -E copy_directory
${NUTTX_DIR}/arch/${CONFIG_ARCH}/include/${CONFIG_ARCH_CHIP}
${CMAKE_BINARY_DIR}/include_arch/arch/chip)
endif()
endif()
# Optional symbolic links
# Target used to copy include/nuttx/lib/stdarg.h. If CONFIG_ARCH_STDARG_H is
# defined, then there is an architecture specific stdarg.h header file that will
# be included indirectly from include/lib/stdarg.h. But first, we have to copy
# stdarg.h from include/nuttx/. to include/.
if(CONFIG_ARCH_STDARG_H)
nuttx_create_symlink(${NUTTX_DIR}/include/nuttx/lib/stdarg.h
${CMAKE_BINARY_DIR}/include/stdarg.h)
else()
file(REMOVE ${CMAKE_BINARY_DIR}/include/stdarg.h)
endif()
# Target used to copy include/nuttx/lib/math.h. If CONFIG_ARCH_MATH_H is
# defined, then there is an architecture specific math.h header file that will
# be included indirectly from include/math.h. But first, we have to copy math.h
# from include/nuttx/. to include/. Logic within include/nuttx/lib/math.h will
# hand the redirection to the architecture- specific math.h header file.
#
# If the CONFIG_LIBM is defined, the Rhombus libm will be built at libc/math.
# Definitions and prototypes for the Rhombus libm are also contained in
# include/nuttx/lib/math.h and so the file must also be copied in that case.
#
# If neither CONFIG_ARCH_MATH_H nor CONFIG_LIBM is defined, then no math.h
# header file will be provided. You would want that behavior if (1) you don't
# use libm, or (2) you want to use the math.h and libm provided within your
# toolchain.
if(CONFIG_ARCH_MATH_H OR CONFIG_LIBM)
set(NEED_MATH_H true)
endif()
if(NEED_MATH_H)
nuttx_create_symlink(${NUTTX_DIR}/include/nuttx/lib/math.h
${CMAKE_BINARY_DIR}/include/math.h)
else()
file(REMOVE ${CMAKE_BINARY_DIR}/include/math.h)
endif()
# The float.h header file defines the properties of your floating point
# implementation. It would always be best to use your toolchain's float.h
# header file but if none is available, a default float.h header file will
# provided if this option is selected. However there is no assurance that the
# settings in this float.h are actually correct for your platform!
if(CONFIG_ARCH_FLOAT_H)
nuttx_create_symlink(${NUTTX_DIR}/include/nuttx/lib/float.h
${CMAKE_BINARY_DIR}/include/float.h)
else()
file(REMOVE ${CMAKE_BINARY_DIR}/include/float.h)
endif()
# Target used to copy include/nuttx/lib/setjmp.h. If CONFIG_ARCH_SETJMP_H is
# defined, then there is an architecture specific setjmp.h header file that will
# be included indirectly from include/lib/setjmp.h. But first, we have to copy
# setjmp.h from include/nuttx/. to include/.
if(CONFIG_ARCH_SETJMP_H)
nuttx_create_symlink(${NUTTX_DIR}/include/nuttx/lib/setjmp.h
${CMAKE_BINARY_DIR}/include/setjmp.h)
else()
file(REMOVE ${CMAKE_BINARY_DIR}/include/setjmp.h)
endif()
# Add final context target that ties together all of the above The context
# target is invoked on each target build to assure that NuttX is properly
# configured. The basic configuration steps include creation of the the
# config.h and version.h header files in the include/nuttx directory and the
# establishment of symbolic links to configured directories.
add_custom_target(
nuttx_context
DEPENDS
${CMAKE_BINARY_DIR}/include/nuttx/config.h
${CMAKE_BINARY_DIR}/include/nuttx/version.h
$<$<BOOL:${CONFIG_ARCH_STDARG_H}>:${CMAKE_BINARY_DIR}/include/stdarg.h>
$<$<BOOL:${NEED_MATH_H}>:${CMAKE_BINARY_DIR}/include/math.h>
$<$<BOOL:${CONFIG_ARCH_FLOAT_H}>:${CMAKE_BINARY_DIR}/include/float.h>
$<$<BOOL:${CONFIG_ARCH_SETJMP_H}>:${CMAKE_BINARY_DIR}/include/setjmp.h>)

View File

@ -0,0 +1,48 @@
# ##############################################################################
# cmake/nuttx_generate_outputs.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
function(nuttx_generate_outputs target)
if(CONFIG_INTELHEX_BINARY)
add_custom_command(
OUTPUT ${target}.hex
COMMAND ${CMAKE_OBJCOPY} -O ihex ${target} ${target}.hex
DEPENDS ${target})
add_custom_target(${target}-hex ALL DEPENDS ${target}.hex)
file(APPEND ${CMAKE_BINARY_DIR}/nuttx.manifest "${target}.hex\n")
endif()
if(CONFIG_MOTOROLA_SREC)
add_custom_command(
OUTPUT ${target}.srec
COMMAND ${CMAKE_OBJCOPY} -O srec ${target} ${target}.srec
DEPENDS ${target})
add_custom_target(${target}-srec ALL DEPENDS ${target}.srec)
file(APPEND ${CMAKE_BINARY_DIR}/nuttx.manifest "${target}.srec\n")
endif()
if(CONFIG_RAW_BINARY)
add_custom_command(
OUTPUT ${target}.bin
COMMAND ${CMAKE_OBJCOPY} -O binary ${target} ${target}.bin
DEPENDS ${target})
add_custom_target(${target}-bin ALL DEPENDS ${target}.bin)
file(APPEND ${CMAKE_BINARY_DIR}/nuttx.manifest "${target}.bin\n")
endif()
endfunction(nuttx_generate_outputs)

127
cmake/nuttx_kconfig.cmake Normal file
View File

@ -0,0 +1,127 @@
# ##############################################################################
# cmake/nuttx_kconfig.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
function(nuttx_export_kconfig_by_value kconfigfile config)
file(STRINGS ${kconfigfile} ConfigContents)
foreach(NameAndValue ${ConfigContents})
string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
string(REGEX MATCH "^CONFIG[^=]+" Name ${NameAndValue})
if(Name STREQUAL ${config})
string(REPLACE "${Name}=" "" Value ${NameAndValue})
string(REPLACE "\"" "" Value ${Value})
set(${Name}
${Value}
PARENT_SCOPE)
break()
endif()
endforeach()
endfunction()
function(nuttx_export_kconfig kconfigfile)
file(STRINGS ${kconfigfile} ConfigContents)
foreach(NameAndValue ${ConfigContents})
# Strip leading spaces
string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
# Find variable name
string(REGEX MATCH "^CONFIG[^=]+" Name ${NameAndValue})
if(Name)
# Find the value
string(REPLACE "${Name}=" "" Value ${NameAndValue})
# remove extra quotes
string(REPLACE "\"" "" Value ${Value})
# Set the variable
set(${Name}
${Value}
PARENT_SCOPE)
endif()
endforeach()
# Compatibility for symbols usually user-settable (now, set via env vars)
# TODO: change usage of these symbols into the corresponding cmake variables
if(LINUX)
set(CONFIG_HOST_LINUX
true
PARENT_SCOPE)
elseif(APPLE)
set(CONFIG_HOST_MACOS
true
PARENT_SCOPE)
elseif(WIN32)
set(CONFIG_HOST_WINDOWS
true
PARENT_SCOPE)
else()
set(CONFIG_HOST_OTHER
true
PARENT_SCOPE)
endif()
endfunction()
function(nuttx_generate_kconfig)
nuttx_parse_function_args(
FUNC
nuttx_generate_kconfig
ONE_VALUE
MENUDESC
REQUIRED
ARGN
${ARGN})
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt"
OR EXISTS "${NUTTX_APPS_BINDIR}/Kconfig")
return()
endif()
set(KCONFIG_OUTPUT_FILE)
if(MENUDESC)
string(REPLACE "/" "_" KCONFIG_PREFIX ${CMAKE_CURRENT_LIST_DIR})
if(WIN32)
string(REPLACE ":" "_" KCONFIG_PREFIX ${KCONFIG_PREFIX})
endif()
string(APPEND KCONFIG_OUTPUT_FILE ${NUTTX_APPS_BINDIR} "/"
${KCONFIG_PREFIX} "_Kconfig")
file(WRITE ${KCONFIG_OUTPUT_FILE} "menu \"${MENUDESC}\"\n")
else()
set(KCONFIG_OUTPUT_FILE ${NUTTX_APPS_BINDIR}/Kconfig)
file(
GLOB subdir
LIST_DIRECTORIES false
${NUTTX_APPS_BINDIR} ${NUTTX_APPS_BINDIR}/*_Kconfig)
foreach(dir ${subdir})
file(APPEND ${KCONFIG_OUTPUT_FILE} "source \"${dir}\"\n")
endforeach()
endif()
file(
GLOB subdir
LIST_DIRECTORIES false
${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/*/Kconfig)
foreach(dir ${subdir})
file(APPEND ${KCONFIG_OUTPUT_FILE} "source \"${dir}\"\n")
endforeach()
if(MENUDESC)
file(APPEND ${KCONFIG_OUTPUT_FILE} "endmenu # ${MENUDESC}\n")
endif()
endfunction()

139
cmake/nuttx_mkconfig.cmake Normal file
View File

@ -0,0 +1,139 @@
# ##############################################################################
# cmake/nuttx_mkconfig.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(NOT EXISTS ${CMAKE_BINARY_DIR}/.config)
return()
endif()
if(NOT EXISTS ${CMAKE_BINARY_DIR}/.config.prev)
execute_process(
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/.config
${CMAKE_BINARY_DIR}/.config.prev
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} -E compare_files ${CMAKE_BINARY_DIR}/.config
${CMAKE_BINARY_DIR}/.config.prev
RESULT_VARIABLE COMPARE_RESULT
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set(CONFIG_H ${CMAKE_BINARY_DIR}/include/nuttx/config.h)
if(COMPARE_RESULT EQUAL 0 AND EXISTS ${CONFIG_H})
return()
endif()
set(DEQUOTELIST
# NuttX
"CONFIG_DEBUG_OPTLEVEL" # Custom debug level
"CONFIG_EXECFUNCS_NSYMBOLS_VAR" # Variable holding number of symbols in the
# table
"CONFIG_EXECFUNCS_SYMTAB_ARRAY" # Symbol table array used by exec[l|v]
"CONFIG_INIT_ARGS" # Argument list of entry point
"CONFIG_INIT_SYMTAB" # Global symbol table
"CONFIG_INIT_NEXPORTS" # Global symbol table size
"CONFIG_INIT_ENTRYPOINT" # Name of entry point function
"CONFIG_MODLIB_SYMTAB_ARRAY" # Symbol table array used by modlib functions
"CONFIG_MODLIB_NSYMBOLS_VAR" # Variable holding number of symbols in the
# table
"CONFIG_PASS1_BUILDIR" # Pass1 build directory
"CONFIG_PASS1_TARGET" # Pass1 build target
"CONFIG_PASS1_OBJECT" # Pass1 build object
"CONFIG_TTY_LAUNCH_ENTRYPOINT" # Name of entry point from tty launch
"CONFIG_TTY_LAUNCH_ARGS" # Argument list of entry point from tty launch
# NxWidgets/NxWM
"CONFIG_NXWM_BACKGROUND_IMAGE" # Name of bitmap image class
"CONFIG_NXWM_CALIBRATION_ICON" # Name of bitmap image class
"CONFIG_NXWM_HEXCALCULATOR_ICON" # Name of bitmap image class
"CONFIG_NXWM_MINIMIZE_BITMAP" # Name of bitmap image class
"CONFIG_NXWM_NXTERM_ICON" # Name of bitmap image class
"CONFIG_NXWM_STARTWINDOW_ICON" # Name of bitmap image class
"CONFIG_NXWM_STOP_BITMAP" # Name of bitmap image class
# apps/ definitions
"CONFIG_NSH_SYMTAB_ARRAYNAME" # Symbol table array name
"CONFIG_NSH_SYMTAB_COUNTNAME" # Name of the variable holding the
# number of symbols
)
file(WRITE ${CONFIG_H} "/* config.h -- Autogenerated! Do not edit. */\n\n")
file(APPEND ${CONFIG_H} "#ifndef __INCLUDE_NUTTX_CONFIG_H\n")
file(APPEND ${CONFIG_H} "#define __INCLUDE_NUTTX_CONFIG_H\n\n")
file(APPEND ${CONFIG_H}
"/* Used to represent the values of tristate options */\n\n")
file(APPEND ${CONFIG_H} "#define CONFIG_y 1\n")
file(APPEND ${CONFIG_H} "#define CONFIG_m 2\n\n")
file(APPEND ${CONFIG_H}
"/* General Definitions ***********************************/\n")
file(STRINGS ${CMAKE_BINARY_DIR}/.config ConfigContents)
foreach(NameAndValue ${ConfigContents})
string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue})
string(REGEX MATCH "^CONFIG[^=]+" NAME ${NameAndValue})
string(REPLACE "${NAME}=" "" VALUE ${NameAndValue})
if(NAME AND NOT "${VALUE}" STREQUAL "")
if(${VALUE} STREQUAL "y")
file(APPEND ${CONFIG_H} "#define ${NAME} 1\n")
elseif(${VALUE} STREQUAL "m")
file(APPEND ${CONFIG_H} "#define ${NAME} 2\n")
elseif(${VALUE} STREQUAL "n")
file(APPEND ${CONFIG_H} "#undef ${NAME}\n")
else()
foreach(dequote ${DEQUOTELIST})
if("${NAME}" STREQUAL "${dequote}")
if(NOT "${VALUE}" STREQUAL "\"\"")
string(REGEX REPLACE "\"" "" VALUE ${VALUE})
else()
set(VALUE)
file(APPEND ${CONFIG_H} "#undef ${NAME}\n")
endif()
break()
endif()
endforeach()
if(NOT "${VALUE}" STREQUAL "")
file(APPEND ${CONFIG_H} "#define ${NAME} ${VALUE}\n")
endif()
endif()
endif()
endforeach()
file(APPEND ${CONFIG_H}
"\n/* Sanity Checks *****************************************/\n\n")
file(APPEND ${CONFIG_H}
"/* If the end of RAM is not specified then it is assumed to be\n")
file(APPEND ${CONFIG_H} " * the beginning of RAM plus the RAM size.\n")
file(APPEND ${CONFIG_H} " */\n\n")
file(APPEND ${CONFIG_H} "#ifndef CONFIG_RAM_END\n")
file(APPEND ${CONFIG_H}
"# define CONFIG_RAM_END (CONFIG_RAM_START+CONFIG_RAM_SIZE)\n")
file(APPEND ${CONFIG_H} "#endif\n\n")
file(APPEND ${CONFIG_H} "#ifndef CONFIG_RAM_VEND\n")
file(APPEND ${CONFIG_H}
"# define CONFIG_RAM_VEND (CONFIG_RAM_VSTART+CONFIG_RAM_SIZE)\n")
file(APPEND ${CONFIG_H} "#endif\n\n")
file(APPEND ${CONFIG_H}
"/* If the end of FLASH is not specified then it is assumed to be\n")
file(APPEND ${CONFIG_H} " * the beginning of FLASH plus the FLASH size.\n")
file(APPEND ${CONFIG_H} " */\n\n")
file(APPEND ${CONFIG_H} "#ifndef CONFIG_FLASH_END\n")
file(APPEND ${CONFIG_H}
"# define CONFIG_FLASH_END (CONFIG_FLASH_START+CONFIG_FLASH_SIZE)\n")
file(APPEND ${CONFIG_H} "#endif\n\n")
file(APPEND ${CONFIG_H} "#endif /* __INCLUDE_NUTTX_CONFIG_H */\n")

110
cmake/nuttx_mkversion.cmake Normal file
View File

@ -0,0 +1,110 @@
# ##############################################################################
# cmake/nuttx_mkversion.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(VERSION_H ${CMAKE_BINARY_DIR}/include/nuttx/version.h)
if(EXISTS ${VERSION_H})
return()
endif()
execute_process(
COMMAND git -C ${NUTTX_DIR} describe --match "nuttx-*"
WORKING_DIRECTORY ${NUTTX_DIR}
OUTPUT_VARIABLE NUTTX_VERSION
RESULT_VARIABLE VERSION_STATUS)
if(${VERSION_STATUS} AND NOT ${VERSION_STATUS} EQUAL 0)
set(NUTTX_VERSION "0.0.0")
else()
string(REPLACE "-" ";" NUTTX_VERSION ${NUTTX_VERSION})
list(GET NUTTX_VERSION 1 NUTTX_VERSION)
endif()
string(REPLACE "." ";" NUTTX_CHECK_VERSION ${NUTTX_VERSION})
list(LENGTH NUTTX_CHECK_VERSION NUTTX_VERSION_LENGTH)
if(${NUTTX_VERSION_LENGTH} LESS 3)
execute_process(
COMMAND git -C ${NUTTX_DIR} -c "versionsort.suffix=-" tag --sort=v:refname
WORKING_DIRECTORY ${NUTTX_DIR}
OUTPUT_VARIABLE NUTTX_VERSION_LIST
RESULT_VARIABLE VERSION_STATUS)
if(${VERSION_STATUS} EQUAL 0)
string(REPLACE "\n" ";" NUTTX_VERSION_LIST ${NUTTX_VERSION_LIST})
foreach(version ${NUTTX_VERSION_LIST})
string(REGEX MATCH "nuttx-[0-9]+\.[0-9]+\.[0-9]+" NUTTX_CHECK_VERSION
${version})
if(NUTTX_CHECK_VERSION)
string(REPLACE "-" ";" NUTTX_VERSION ${NUTTX_CHECK_VERSION})
list(GET NUTTX_VERSION 1 NUTTX_VERSION)
endif()
endforeach()
endif()
endif()
execute_process(
COMMAND git -C ${NUTTX_DIR} log --oneline -1
WORKING_DIRECTORY ${NUTTX_DIR}
OUTPUT_VARIABLE NUTTX_VERSION_BUILD
RESULT_VARIABLE VERSION_STATUS)
if(${VERSION_STATUS} AND NOT ${VERSION_STATUS} EQUAL 0)
set(NUTTX_VERSION_BUILD)
else()
string(REPLACE " " ";" NUTTX_VERSION_BUILD ${NUTTX_VERSION_BUILD})
list(GET NUTTX_VERSION_BUILD 0 NUTTX_VERSION_BUILD)
execute_process(
COMMAND git -C ${NUTTX_DIR} diff-index --name-only HEAD
WORKING_DIRECTORY ${NUTTX_DIR}
OUTPUT_VARIABLE NUTTX_VERSION_BUILD_DIRTY)
if(NUTTX_VERSION_BUILD_DIRTY)
set(NUTTX_VERSION_BUILD ${NUTTX_VERSION_BUILD}-dirty)
endif()
endif()
file(WRITE ${VERSION_H} "/* version.h -- Autogenerated! Do not edit. */\n\n")
file(APPEND ${VERSION_H} "#ifndef __INCLUDE_NUTTX_VERSION_H\n")
file(APPEND ${VERSION_H} "#define __INCLUDE_NUTTX_VERSION_H\n\n")
file(APPEND ${VERSION_H} "#define CONFIG_VERSION_STRING \"${NUTTX_VERSION}\"\n")
string(REPLACE "." ";" NUTTX_VERSION ${NUTTX_VERSION})
list(GET NUTTX_VERSION 0 NUTTX_VERSION_MAJOR)
list(GET NUTTX_VERSION 1 NUTTX_VERSION_MINOR)
list(GET NUTTX_VERSION 2 NUTTX_VERSION_PATCH)
file(APPEND ${VERSION_H}
"#define CONFIG_VERSION_MAJOR ${NUTTX_VERSION_MAJOR}\n")
file(APPEND ${VERSION_H}
"#define CONFIG_VERSION_MINOR ${NUTTX_VERSION_MINOR}\n")
file(APPEND ${VERSION_H}
"#define CONFIG_VERSION_PATCH ${NUTTX_VERSION_PATCH}\n")
file(APPEND ${VERSION_H}
"#define CONFIG_VERSION_BUILD \"${NUTTX_VERSION_BUILD}\"\n\n")
file(
APPEND ${VERSION_H}
"#define CONFIG_VERSION ((CONFIG_VERSION_MAJOR << 16) | \\
(CONFIG_VERSION_MINOR << 8) | \\
(CONFIG_VERSION_PATCH))\n")
file(APPEND ${VERSION_H} "\n#endif /* __INCLUDE_NUTTX_VERSION_H */\n")

View File

@ -0,0 +1,84 @@
# ##############################################################################
# cmake/nuttx_parse_function_args.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# =============================================================================
#
# Defined functions in this file
#
# utility functions
#
# * nuttx_parse_function_args
#
include(CMakeParseArguments)
# =============================================================================
#
# nuttx_parse_function_args
#
# This function simplifies usage of the cmake_parse_arguments module. It is
# intended to be called by other functions.
#
# Usage: nuttx_parse_function_args( FUNC <name> [ OPTIONS <list> ] [ ONE_VALUE
# <list> ] [ MULTI_VALUE <list> ] REQUIRED <list> ARGN <ARGN>)
#
# Input: FUNC : the name of the calling function OPTIONS : boolean flags
# ONE_VALUE : single value variables MULTI_VALUE : multi value variables
# REQUIRED : required arguments ARGN : the function input arguments,
# typically ${ARGN}
#
# Output: The function arguments corresponding to the following are set:
# ${OPTIONS}, ${ONE_VALUE}, ${MULTI_VALUE}
#
# Example: function test() nuttx_parse_function_args( FUNC TEST ONE_VALUE NAME
# MULTI_VALUE LIST REQUIRED NAME LIST ARGN ${ARGN}) message(STATUS "name:
# ${NAME}") message(STATUS "list: ${LIST}") endfunction()
#
# test(NAME "hello" LIST a b c)
#
# OUTPUT: name: hello list: a b c
#
function(nuttx_parse_function_args)
cmake_parse_arguments(IN "" "FUNC"
"OPTIONS;ONE_VALUE;MULTI_VALUE;REQUIRED;ARGN" "${ARGN}")
cmake_parse_arguments(OUT "${IN_OPTIONS}" "${IN_ONE_VALUE}"
"${IN_MULTI_VALUE}" "${IN_ARGN}")
if(OUT_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "${IN_NAME}: unparsed ${OUT_UNPARSED_ARGUMENTS}")
endif()
foreach(arg ${IN_REQUIRED})
if(NOT OUT_${arg})
if(NOT "${OUT_${arg}}" STREQUAL "0")
message(
FATAL_ERROR "${IN_NAME} requires argument ${arg}\nARGN: ${IN_ARGN}")
endif()
endif()
endforeach()
foreach(arg ${IN_OPTIONS} ${IN_ONE_VALUE} ${IN_MULTI_VALUE})
set(${arg}
${OUT_${arg}}
PARENT_SCOPE)
endforeach()
endfunction()

View File

@ -0,0 +1,146 @@
# ##############################################################################
# cmake/nuttx_redefine_symbols.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(NXSYMBOLS
__cxa_atexit
abort
accept
access
atexit
backtrace
bind
calloc
chmod
chown
clock_gettime
close
closedir
connect
dlsym
dup
exit
fchmod
fchown
fclose
fcntl
fdopen
fopen
fprintf
fread
free
fseek
fstat
fsync
ftell
ftruncate
futimens
fwrite
getpeername
getsockname
getenv
getpid
getsockopt
if_nametoindex
ioctl
listen
longjmp
lseek
malloc
malloc_size
malloc_usable_size
memcpy
mkdir
mmap
mprotect
munmap
open
opendir
perror
poll
posix_memalign
pthread_attr_init
pthread_attr_setstack
pthread_attr_destroy
pthread_cond_destroy
pthread_cond_init
pthread_cond_signal
pthread_cond_wait
pthread_create
pthread_getspecific
pthread_key_create
pthread_kill
pthread_mutex_destroy
pthread_mutex_init
pthread_mutex_lock
pthread_mutex_unlock
pthread_setspecific
pthread_sigmask
puts
read
readdir
readv
realloc
recvfrom
rename
rewinddir
rmdir
sched_yield
select
sendmsg
sendto
setitimer
setbuf
setjmp
setsockopt
shutdown
sigaction
sigaddset
sigemptyset
sigfillset
sleep
socket
stat
statvfs
stderr
strcat
strchr
strerror
strlen
strtol
sysconf
syslog
tcgetattr
tcsetattr
unlink
usleep
utimensat
write
writev)
set(NXSYMBOL_RENAMES)
foreach(NXSYMBOL ${NXSYMBOLS})
if(APPLE OR (CYGWIN AND CONFIG_SIM_CYGWIN_DECORATED))
list(APPEND NXSYMBOL_RENAMES "_${NXSYMBOL} NX${NXSYMBOL}")
else()
list(APPEND NXSYMBOL_RENAMES "${NXSYMBOL} NX${NXSYMBOL}")
endif()
endforeach()
string(REPLACE ";" "\n" NXSYMBOL_RENAMES "${NXSYMBOL_RENAMES}")
file(WRITE ${CMAKE_BINARY_DIR}/nuttx-names.dat "${NXSYMBOL_RENAMES}\n")

54
cmake/symtab.c.in Normal file
View File

@ -0,0 +1,54 @@
/****************************************************************************
* cmake/symtab.c.in
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#include <nuttx/compiler.h>
#include <nuttx/symtab.h>
#define _CONCAT(x,y) x ## y
#define CONCAT(x,y) _CONCAT(x,y)
#include "symtab_@NAME@_declarations.h"
#ifndef SYMTAB_PREFIX
# if defined(CONFIG_EXECFUNCS_HAVE_SYMTAB)
const struct symtab_s CONFIG_EXECFUNCS_SYMTAB_ARRAY[] =
# elif defined(CONFIG_SYSTEM_NSH_SYMTAB)
const struct symtab_s CONFIG_NSH_SYMTAB_ARRAYNAME[] =
# else
const struct symtab_s dummy_symtab[] =
# endif
#else
const struct symtab_s CONCAT(SYMTAB_PREFIX,_exports)[] =
#endif
{
#include "symtab_@NAME@_entries.h"
};
#ifndef SYMTAB_PREFIX
# if defined(CONFIG_EXECFUNCS_HAVE_SYMTAB)
const int CONFIG_EXECFUNCS_NSYMBOLS_VAR = sizeof(CONFIG_EXECFUNCS_SYMTAB_ARRAY) / sizeof(struct symtab_s);
# elif defined(CONFIG_SYSTEM_NSH_SYMTAB)
const int CONFIG_NSH_SYMTAB_COUNTNAME = sizeof(CONFIG_NSH_SYMTAB_ARRAYNAME) / sizeof(struct symtab_s);
# else
const int dummy_nsymtabs = sizeof(dummy_symtab) / sizeof(struct symtab_s);
# endif
#else
const int CONCAT(SYMTAB_PREFIX,_nexports) = sizeof(CONCAT(SYMTAB_PREFIX,_exports)) / sizeof(struct symtab_s);
#endif

50
crypto/CMakeLists.txt Normal file
View File

@ -0,0 +1,50 @@
# ##############################################################################
# crypto/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_CRYPTO)
nuttx_add_kernel_library(crypto)
set(SRCS crypto.c testmngr.c)
# cryptodev support
if(CONFIG_CRYPTO_CRYPTODEV)
list(APPEND SRCS cryptodev.c)
endif()
# Software AES library
if(CONFIG_CRYPTO_SW_AES)
list(APPEND SRCS aes.c)
endif()
# BLAKE2s hash algorithm
if(CONFIG_CRYPTO_BLAKE2S)
list(APPEND SRCS blake2s.c)
endif()
# Entropy pool random number generator
if(CONFIG_CRYPTO_RANDOM_POOL)
list(APPEND SRCS random_pool.c)
endif()
target_sources(crypto PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,29 @@
# ##############################################################################
# drivers/1wire/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_1WIRE)
set(SRCS 1wire.c 1wire_crc.c 1wire_read.c 1wire_write.c 1wire_writeread.c)
if(CONFIG_1WIRE_DS28E17)
list(APPEND SRCS ds28e17.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

24
drivers/CMakeLists.txt Normal file
View File

@ -0,0 +1,24 @@
# ##############################################################################
# drivers/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
nuttx_add_kernel_library(drivers)
nuttx_add_subdirectory()
target_sources(drivers PRIVATE drivers_initialize.c)
target_include_directories(drivers PRIVATE ${CMAKE_CURRENT_LIST_DIR})

View File

@ -0,0 +1,100 @@
# ##############################################################################
# drivers/analog/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS)
if(CONFIG_DAC)
# Include the common DAC character driver
list(APPEND SRCS dac.c)
# Include DAC device drivers
if(CONFIG_DAC_AD5410)
list(APPEND SRCS ad5410.c)
endif()
if(CONFIG_DAC7571)
list(APPEND SRCS dac7571.c)
endif()
if(CONFIG_DAC7554)
list(APPEND SRCS dac7554.c)
endif()
if(CONFIG_MCP48XX)
list(APPEND SRCS mcp48xx.c)
endif()
endif()
# Check for COMP devices
if(CONFIG_COMP)
# Include the common COMP character driver
list(APPEND SRCS comp.c)
endif()
# Check for OPAMP devices
if(CONFIG_OPAMP)
# Include the common OPAMP character driver
list(APPEND SRCS opamp.c)
endif()
# Check for ADC devices
if(CONFIG_ADC)
# Include the common ADC character driver
list(APPEND SRCS adc.c)
# Amplifiers/multiplexers
if(CONFIG_ADC_PGA11X)
list(APPEND SRCS pga11x.c)
endif()
# Include ADC device drivers
if(CONFIG_ADC_ADS1242)
list(APPEND SRCS ads1242.c)
endif()
if(CONFIG_ADC_ADS125X)
list(APPEND SRCS ads1255.c)
endif()
if(CONFIG_ADC_ADS7828)
list(APPEND SRCS ads7828.c)
endif()
if(CONFIG_ADC_MAX1161X)
list(APPEND SRCS max1161x.c)
endif()
if(CONFIG_ADC_LTC1867L)
list(APPEND SRCS ltc1867l.c)
endif()
endif()
if(CONFIG_LMP92001)
list(APPEND SRCS lmp92001.c)
endif()
target_sources(drivers PRIVATE ${SRCS})

View File

@ -0,0 +1,88 @@
# ##############################################################################
# drivers/audio/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
#
# ##############################################################################
if(CONFIG_DRIVERS_AUDIO)
set(SRCS)
if(CONFIG_AUDIO_CXD56)
list(APPEND SRCS cxd56.c)
if(CONFIG_AUDIO_CXD56_SRC)
list(APPEND SRCS cxd56_src.c)
endif()
endif()
if(CONFIG_AUDIO_VS1053)
list(APPEND SRCS vs1053.c)
endif()
if(CONFIG_AUDIO_CS43L22)
list(APPEND SRCS cs43l22.c)
if(CONFIG_CS43L22_REGDUMP)
list(APPEND SRCS cs43l22_debug.c)
elseif(CONFIG_CS43L22_CLKDEBUG)
list(APPEND SRCS cs43l22_debug.c)
endif()
endif()
if(CONFIG_AUDIO_CS4344)
list(APPEND SRCS cs4344.c)
endif()
if(CONFIG_AUDIO_WM8994)
list(APPEND SRCS wm8994.c)
if(CONFIG_WM8994_REGDUMP)
list(APPEND SRCS wm8994_debug.c)
elseif(CONFIG_WM8994_CLKDEBUG)
list(APPEND SRCS wm8994_debug.c)
endif()
endif()
if(CONFIG_AUDIO_WM8904)
list(APPEND SRCS wm8904.c)
if(CONFIG_WM8904_REGDUMP)
list(APPEND SRCS wm8904_debug.c)
elseif(CONFIG_WM8904_CLKDEBUG)
list(APPEND SRCS wm8904_debug.c)
endif()
endif()
if(CONFIG_AUDIO_WM8776)
list(APPEND SRCS wm8776.c)
endif()
if(CONFIG_AUDIO_NULL)
list(APPEND SRCS audio_null.c)
endif()
if(CONFIG_AUDIO_TONE)
list(APPEND SRCS tone.c)
endif()
if(CONFIG_AUDIO_I2S)
list(APPEND SRCS audio_i2s.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,32 @@
# ##############################################################################
# drivers/bch/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_BCH)
target_sources(
drivers
PRIVATE bchlib_setup.c
bchlib_teardown.c
bchlib_read.c
bchlib_write.c
bchlib_cache.c
bchdev_register.c
bchdev_unregister.c
bchdev_driver.c)
endif()

View File

@ -0,0 +1,29 @@
# ##############################################################################
# drivers/can/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_CAN)
set(SRCS can.c)
if(CONFIG_CAN_MCP2515)
list(APPEND SRCS mcp2515.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,44 @@
# ##############################################################################
# drivers/clk/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_CLK)
set(SRCS)
list(
APPEND
SRCS
clk.c
clk_divider.c
clk_fixed_factor.c
clk_fractional_divider.c
clk_fixed_rate.c
clk_gate.c
clk_multiplier.c
clk_mux.c
clk_phase.c)
if(CONFIG_CLK_RPMSG)
list(APPEND SRCS clk_rpmsg.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,33 @@
# ##############################################################################
# drivers/contactless/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_DRIVERS_CONTACTLESS)
set(SRCS)
if(CONFIG_CL_MFRC522)
list(APPEND SRCS mfrc522.c)
endif()
if(CONFIG_CL_PN532)
list(APPEND SRCS pn532.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,23 @@
# ##############################################################################
# drivers/crypto/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_DEV_URANDOM AND NOT CONFIG_DEV_URANDOM_ARCH)
target_sources(drivers PRIVATE dev_urandom.c)
endif()

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,35 @@
# ##############################################################################
# drivers/eeprom/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_EEPROM)
set(SRCS)
# Include the Microchip/Atmel/ST xx25xx driver for SPI
if(CONFIG_SPI_EE_25XX)
list(APPEND SRCS spi_xx25xx.c)
endif()
# Include the Microchip/Atmel/ST xx24xx driver for I2C
if(CONFIG_I2C_EE_24XX)
list(APPEND SRCS i2c_xx24xx.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,22 @@
# ##############################################################################
# drivers/efuse/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_EFUSE)
target_sources(drivers PRIVATE efuse.c)
endif()

View File

@ -0,0 +1,44 @@
# ##############################################################################
# drivers/i2c/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# ##############################################################################
if(CONFIG_I2C)
set(SRCS i2c_read.c i2c_write.c i2c_writeread.c)
if(CONFIG_I2C_DRIVER)
list(APPEND SRCS i2c_driver.c)
endif()
if(CONFIG_I2C_BITBANG)
list(APPEND SRCS i2c_bitbang.c)
endif()
# Include the selected I2C multiplexer drivers
if(CONFIG_I2CMULTIPLEXER_PCA9540BDP)
list(APPEND SRCS pca9540bdp.c)
endif()
if(CONFIG_I2CMULTIPLEXER_TCA9548A)
list(APPEND SRCS tca9548a.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,29 @@
# ##############################################################################
# drivers/i2s/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_I2S)
set(SRCS)
if(CONFIG_AUDIO_I2SCHAR)
list(APPEND SRCS i2schar.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,104 @@
# ##############################################################################
# drivers/input/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_INPUT)
set(SRCS)
# Include the selected touchscreen drivers
if(CONFIG_INPUT_TOUCHSCREEN)
list(APPEND SRCS touchscreen_upper.c)
endif()
if(CONFIG_INPUT_UINPUT)
list(APPEND SRCS uinput.c)
endif()
if(CONFIG_INPUT_TSC2007)
list(APPEND SRCS tsc2007.c)
endif()
if(CONFIG_INPUT_FT5X06)
list(APPEND SRCS ft5x06.c)
endif()
if(CONFIG_INPUT_ADS7843E)
list(APPEND SRCS ads7843e.c)
endif()
if(CONFIG_INPUT_MAX11802)
list(APPEND SRCS max11802.c)
endif()
if(CONFIG_INPUT_MXT)
list(APPEND SRCS mxt.c)
endif()
if(CONFIG_INPUT_STMPE811)
list(APPEND SRCS stmpe811_base.c)
if(NOT CONFIG_INPUT_STMPE811_TSC_DISABLE)
list(APPEND SRCS stmpe811_tsc.c)
endif()
if(NOT CONFIG_INPUT_STMPE811_GPIO_DISABLE)
list(APPEND SRCS stmpe811_gpio.c)
endif()
if(NOT CONFIG_INPUT_STMPE811_ADC_DISABLE)
list(APPEND SRCS stmpe811_adc.c)
endif()
if(NOT CONFIG_INPUT_STMPE811_TEMP_DISABLE)
list(APPEND SRCS stmpe811_temp.c)
endif()
endif()
if(CONFIG_INPUT_CYPRESS_MBR3108)
list(APPEND SRCS cypress_mbr3108.c)
endif()
if(CONFIG_INPUT_BUTTONS)
list(APPEND SRCS button_upper.c)
if(CONFIG_INPUT_BUTTONS_LOWER)
list(APPEND SRCS button_lower.c)
endif()
endif()
if(CONFIG_INPUT_KEYBOARD)
list(APPEND SRCS keyboard_upper.c)
endif()
if(CONFIG_INPUT_DJOYSTICK)
list(APPEND SRCS djoystick.c)
endif()
if(CONFIG_INPUT_AJOYSTICK)
list(APPEND SRCS ajoystick.c)
endif()
if(CONFIG_INPUT_NUNCHUCK)
list(APPEND SRCS nunchuck.c)
endif()
if(CONFIG_INPUT_SPQ10KBD)
list(APPEND SRCS spq10kbd.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,69 @@
# ##############################################################################
# drivers/ioexpander/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# ##############################################################################
set(SRCS)
# Check if I/O expander support is enabled
if(CONFIG_IOEXPANDER)
# Include the selected I/O expander drivers
if(CONFIG_IOEXPANDER_RPMSG)
list(APPEND SRCS ioe_rpmsg.c)
endif()
if(CONFIG_IOEXPANDER_DUMMY)
list(APPEND SRCS ioe_dummy.c)
endif()
if(CONFIG_IOEXPANDER_PCA9555)
list(APPEND SRCS pca9555.c)
endif()
if(CONFIG_IOEXPANDER_PCA9538)
list(APPEND SRCS pca9538.c)
endif()
if(CONFIG_IOEXPANDER_TCA64XX)
list(APPEND SRCS tca64xx.c)
endif()
if(CONFIG_IOEXPANDER_PCF8574)
list(APPEND SRCS pcf8574.c)
endif()
if(CONFIG_IOEXPANDER_MCP23X17)
list(APPEND SRCS mcp23x17.c)
endif()
endif()
# GPIO test device driver (independent of IOEXPANDERS)
if(CONFIG_DEV_GPIO)
list(APPEND SRCS gpio.c)
if(CONFIG_GPIO_LOWER_HALF)
list(APPEND SRCS gpio_lower_half.c)
endif()
endif()
target_sources(drivers PRIVATE ${SRCS})

175
drivers/lcd/CMakeLists.txt Normal file
View File

@ -0,0 +1,175 @@
# ##############################################################################
# drivers/lcd/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS)
if(CONFIG_LCD)
# Support for the generic LCD framebuffer front-end
if(CONFIG_LCD_FRAMEBUFFER)
list(APPEND SRCS lcd_framebuffer.c)
endif()
if(CONFIG_LCD_DEV)
list(APPEND SRCS lcd_dev.c)
endif()
# Include support for Graphics LCD drivers
if(CONFIG_LCD_FT80X)
list(APPEND SRCS ft80x.c)
if(CONFIG_LCD_FT80X_SPI)
list(APPEND SRCS ft80x_spi.c)
elseif(CONFIG_LCD_FT80X_I2C)
list(APPEND SRCS ft80x_i2c.c)
endif()
endif()
if(CONFIG_LCD_LPM013M091A)
list(APPEND SRCS lpm013m091a.c)
endif()
if(CONFIG_LCD_APA102)
list(APPEND SRCS apa102.c)
endif()
if(CONFIG_LCD_P14201)
list(APPEND SRCS p14201.c)
endif()
if(CONFIG_LCD_UG2864AMBAG01)
list(APPEND SRCS ug-2864ambag01.c)
endif()
if(CONFIG_LCD_UG9664HSWAG01)
list(APPEND SRCS ug-9664hswag01.c)
endif()
if(CONFIG_LCD_SSD1306)
list(APPEND SRCS ssd1306_base.c)
endif()
if(CONFIG_LCD_SSD1306_SPI)
list(APPEND SRCS ssd1306_spi.c)
endif()
if(CONFIG_LCD_SSD1306_I2C)
list(APPEND SRCS ssd1306_i2c.c)
endif()
if(CONFIG_LCD_SSD1289)
list(APPEND SRCS ssd1289.c)
endif()
if(CONFIG_LCD_SSD1680)
list(APPEND SRCS ssd1680.c)
endif()
if(CONFIG_LCD_SSD1351)
list(APPEND SRCS ssd1351.c)
endif()
if(CONFIG_LCD_MIO283QT2)
list(APPEND SRCS mio283qt2.c)
endif()
if(CONFIG_LCD_MAX7219)
list(APPEND SRCS max7219.c)
endif()
if(CONFIG_LCD_MIO283QT9A)
list(APPEND SRCS mio283qt9a.c)
endif()
if(CONFIG_LCD_PCD8544)
list(APPEND SRCS pcd8544.c)
endif()
if(CONFIG_LCD_ST7565)
list(APPEND SRCS st7565.c)
endif()
if(CONFIG_LCD_ST7567)
list(APPEND SRCS st7567.c)
endif()
if(CONFIG_LCD_SHARP_MEMLCD)
list(APPEND SRCS memlcd.c)
endif()
if(CONFIG_LCD_ILI9225)
list(APPEND SRCS ili9225.c)
endif()
if(CONFIG_LCD_ILI9340)
list(APPEND SRCS ili9340.c)
endif()
if(CONFIG_LCD_ILI9341)
list(APPEND SRCS ili9341.c)
endif()
if(CONFIG_LCD_LCDDRV_SPIIF)
list(APPEND SRCS lcddrv_spiif.c)
endif()
if(CONFIG_LCD_RA8875)
list(APPEND SRCS ra8875.c)
endif()
if(CONFIG_LCD_ST7735)
list(APPEND SRCS st7735.c)
endif()
if(CONFIG_LCD_ST7789)
list(APPEND SRCS st7789.c)
endif()
if(CONFIG_LCD_GC9A01)
list(APPEND SRCS gc9a01.c)
endif()
endif() # CONFIG_LCD
if(CONFIG_SLCD)
# Include support for Alphanumeric/Segment LCD drivers
if(CONFIG_LCD_BACKPACK)
list(APPEND SRCS pcf8574_lcd_backpack.c)
endif()
if(CONFIG_LCD_ST7032)
list(APPEND SRCS st7032.c)
endif()
if(CONFIG_LCD_HT16K33)
list(APPEND SRCS ht16k33_14seg.c)
endif()
endif() # CONFIG_SLCD
# Other LCD-related devices
if(CONFIG_LCD_TDA19988)
list(APPEND SRCS tda19988.c)
endif()
target_sources(drivers PRIVATE ${SRCS})

View File

@ -0,0 +1,56 @@
# ##############################################################################
# drivers/leds/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# ##############################################################################
set(SRCS)
if(CONFIG_USERLED)
list(APPEND SRCS userled_upper.c)
if(CONFIG_USERLED_LOWER)
list(APPEND SRCS userled_lower.c)
endif()
endif()
if(CONFIG_LEDS_APA102)
list(APPEND SRCS apa102.c)
endif()
if(CONFIG_LEDS_MAX7219)
list(APPEND SRCS max7219.c)
endif()
if(CONFIG_RGBLED)
list(APPEND SRCS rgbled.c)
endif()
if(CONFIG_PCA9635PW)
list(APPEND SRCS pca9635pw.c)
endif()
if(CONFIG_NCP5623C)
list(APPEND SRCS ncp5623c.c)
endif()
if(CONFIG_WS2812)
list(APPEND SRCS ws2812.c)
endif()
target_sources(drivers PRIVATE ${SRCS})

View File

@ -0,0 +1,29 @@
# ##############################################################################
# drivers/loop/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(NOT CONFIG_DISABLE_MOUNTPOINT)
set(SRCS losetup.c)
if(CONFIG_DEV_LOOP)
list(APPEND SRCS loop.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,23 @@
# ##############################################################################
# drivers/math/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_MATH_CORDIC)
target_sources(drivers PRIVATE cordic.c)
endif()

View File

@ -0,0 +1,51 @@
# ##############################################################################
# drivers/misc/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS)
if(CONFIG_DEV_SIMPLE_ADDRENV)
list(APPEND SRCS addrenv.c)
endif()
if(CONFIG_DEV_NULL)
list(APPEND SRCS dev_null.c)
endif()
if(CONFIG_DEV_ZERO)
list(APPEND SRCS dev_zero.c)
endif()
if(CONFIG_LWL_CONSOLE)
list(APPEND SRCS lwl_console.c)
endif()
if(NOT CONFIG_DISABLE_MOUNTPOINT)
list(APPEND SRCS ramdisk.c)
if(CONFIG_DRVR_MKRD)
list(APPEND SRCS mkrd.c)
endif()
endif()
if(CONFIG_DRVR_WRITEBUFFER)
list(APPEND SRCS rwbuffer.c)
elseif(CONFIG_DRVR_READAHEAD)
list(APPEND SRCS rwbuffer.c)
endif()
target_sources(drivers PRIVATE ${SRCS})

View File

@ -0,0 +1,35 @@
# ##############################################################################
# drivers/mmcsd/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_MMCSD)
set(SRCS)
# Include MMC/SD drivers
if(CONFIG_MMCSD_SDIO)
list(APPEND SRCS mmcsd_sdio.c)
endif()
if(CONFIG_MMCSD_SPI)
list(APPEND SRCS mmcsd_spi.c mmcsd_debug.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,31 @@
# ##############################################################################
# drivers/modem/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_MODEM)
set(SRCS)
if(CONFIG_MODEM_U_BLOX)
list(APPEND SRCS u-blox.c)
endif()
nuttx_add_subdirectory()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,20 @@
# ##############################################################################
# drivers/motor/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
nuttx_add_subdirectory()

View File

@ -0,0 +1,22 @@
# ##############################################################################
# drivers/motor/foc/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_MOTOR_FOC)
target_sources(drivers PRIVATE foc_dev.c)
endif()

152
drivers/mtd/CMakeLists.txt Normal file
View File

@ -0,0 +1,152 @@
# ##############################################################################
# drivers/mtd/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
#
# ##############################################################################
if(CONFIG_MTD)
set(SRCS ftl.c mtd_config.c)
if(CONFIG_MTD_PARTITION)
list(APPEND SRCS mtd_partition.c)
endif()
if(CONFIG_MTD_SECT512)
list(APPEND SRCS sector512.c)
endif()
if(CONFIG_MTD_WRBUFFER)
list(APPEND SRCS mtd_rwbuffer.c)
else()
if(CONFIG_MTD_READAHEAD)
list(APPEND SRCS mtd_rwbuffer.c)
endif()
endif()
if(CONFIG_MTD_PROGMEM)
list(APPEND SRCS mtd_progmem.c)
endif()
if(CONFIG_MTD_NAND)
list(
APPEND
SRCS
mtd_nand.c
mtd_onfi.c
mtd_nandscheme.c
mtd_nandmodel.c
mtd_modeltab.c)
if(CONFIG_MTD_NAND_SWECC)
list(APPEND SRCS mtd_nandecc.c hamming.c)
endif()
endif()
if(CONFIG_RAMMTD)
list(APPEND SRCS rammtd.c)
endif()
if(CONFIG_FILEMTD)
list(APPEND SRCS filemtd.c)
endif()
if(CONFIG_MTD_AT24XX)
list(APPEND SRCS at24xx.c)
endif()
if(CONFIG_MTD_AT45DB)
list(APPEND SRCS at45db.c)
endif()
if(CONFIG_MTD_RAMTRON)
list(APPEND SRCS ramtron.c)
endif()
if(CONFIG_MTD_SST25)
list(APPEND SRCS sst25.c)
endif()
if(CONFIG_MTD_SST25XX)
list(APPEND SRCS sst25xx.c)
endif()
if(CONFIG_MTD_SST26)
list(APPEND SRCS sst26.c)
endif()
if(CONFIG_MTD_SST39FV)
list(APPEND SRCS sst39vf.c)
endif()
if(CONFIG_MTD_W25)
list(APPEND SRCS w25.c)
endif()
if(CONFIG_MTD_GD25)
list(APPEND SRCS gd25.c)
endif()
if(CONFIG_MTD_GD5F)
list(APPEND SRCS gd5f.c)
endif()
if(CONFIG_MTD_AT25)
list(APPEND SRCS at25.c)
endif()
if(CONFIG_MTD_M25P)
list(APPEND SRCS m25px.c)
endif()
if(CONFIG_MTD_MX25L)
list(APPEND SRCS mx25lx.c)
endif()
if(CONFIG_MTD_MX35)
list(APPEND SRCS mx35.c)
endif()
if(CONFIG_MTD_S25FL1)
list(APPEND SRCS s25fl1.c)
endif()
if(CONFIG_MTD_N25QXXX)
list(APPEND SRCS n25qxxx.c)
endif()
if(CONFIG_MTD_W25QXXXJV)
list(APPEND SRCS w25qxxxjv.c)
endif()
if(CONFIG_MTD_MX25RXX)
list(APPEND SRCS mx25rxx.c)
endif()
if(CONFIG_MTD_IS25XP)
list(APPEND SRCS is25xp.c)
endif()
if(CONFIG_MTD_SMART)
if(CONFIG_FS_SMARTFS)
list(APPEND SRCS smart.c)
endif()
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,83 @@
# ##############################################################################
# drivers/net/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_NET)
set(SRCS)
# Include network interface drivers
if(CONFIG_MM_IOB)
list(APPEND SRCS netdev_upperhalf.c)
endif()
if(CONFIG_NET_LOOPBACK)
list(APPEND SRCS loopback.c)
endif()
if(CONFIG_NET_RPMSG_DRV)
list(APPEND SRCS rpmsgdrv.c)
endif()
if(CONFIG_NETDEV_TELNET)
list(APPEND SRCS telnet.c)
endif()
if(CONFIG_NET_DM90x0)
list(APPEND SRCS dm90x0.c)
endif()
if(CONFIG_ENC28J60)
list(APPEND SRCS enc28j60.c)
endif()
if(CONFIG_ENCX24J600)
list(APPEND SRCS encx24j600.c)
endif()
if(CONFIG_NET_SLIP)
list(APPEND SRCS slip.c)
endif()
if(CONFIG_NET_TUN)
list(APPEND SRCS tun.c)
endif()
if(CONFIG_NET_FTMAC100)
list(APPEND SRCS ftmac100.c)
endif()
if(CONFIG_NET_LAN91C111)
list(APPEND SRCS lan91c111.c)
endif()
if(CONFIG_NET_SKELETON)
list(APPEND SRCS skeleton.c)
endif()
if(CONFIG_NET_W5500)
list(APPEND SRCS w5500.c)
endif()
if(CONFIG_ARCH_PHY_INTERRUPT)
list(APPEND SRCS phy_notify.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,34 @@
# ##############################################################################
# drivers/note/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
set(SRCS)
if(CONFIG_DRIVER_NOTE)
list(APPEND SRCS note_driver.c)
endif()
if(CONFIG_DRIVER_NOTERAM)
list(APPEND SRCS noteram_driver.c)
endif()
if(CONFIG_DRIVER_NOTECTL)
list(APPEND SRCS notectl_driver.c)
endif()
target_sources(drivers PRIVATE ${SRCS})

View File

@ -0,0 +1,21 @@
# ##############################################################################
# drivers/pipes/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
target_sources(drivers PRIVATE pipe.c fifo.c pipe_common.c)

View File

@ -0,0 +1,172 @@
# ##############################################################################
# drivers/power/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# Include power management sources
set(SRCS)
if(CONFIG_PM)
list(
APPEND
SRCS
pm_initialize.c
pm_activity.c
pm_changestate.c
pm_checkstate.c
pm_register.c
pm_unregister.c
pm_autoupdate.c
pm_governor.c
pm_lock.c)
if(CONFIG_PM_PROCFS)
list(APPEND SRCS pm_procfs.c)
endif()
# Governor implementations
if(CONFIG_PM_GOVERNOR_ACTIVITY)
list(APPEND SRCS activity_governor.c)
endif()
if(CONFIG_PM_GOVERNOR_GREEDY)
list(APPEND SRCS greedy_governor.c)
endif()
endif()
# Add switched-mode power supply support
if(CONFIG_DRIVERS_SMPS)
list(APPEND SRCS smps.c)
endif()
# Add powerled support
if(CONFIG_DRIVERS_POWERLED)
list(APPEND SRCS powerled.c)
endif()
if(CONFIG_REGULATOR)
list(APPEND SRCS regulator.c)
endif()
if(CONFIG_REGULATOR_RPMSG)
list(APPEND SRCS regulator_rpmsg.c)
endif()
if(CONFIG_REGULATOR_GPIO)
list(APPEND SRCS regulator_gpio.c)
endif()
# Add battery charger drivers
if(CONFIG_BATTERY_CHARGER)
list(APPEND SRCS battery_charger.c)
# Add the MCP73871 battery charger driver
if(CONFIG_MCP73871)
list(APPEND SRCS mcp73871.c)
endif()
# Add I2C-based battery charger drivers
if(CONFIG_I2C)
# Add the BQ2425x I2C-based battery charger driver
if(CONFIG_I2C_BQ2425X)
list(APPEND SRCS bq2425x.c)
endif()
# Add the BQ2429x I2C-based battery charger driver
if(CONFIG_I2C_BQ2429X)
list(APPEND SRCS bq2429x.c)
endif()
# Add the axp202 I2C-based battery charger driver
if(CONFIG_I2C_AXP202)
list(APPEND SRCS axp202.c)
endif()
endif()
endif()
# Add battery gauge drivers
if(CONFIG_BATTERY_GAUGE)
list(APPEND SRCS battery_gauge.c)
# Add I2C-based battery gauge drivers
if(CONFIG_I2C)
# Add the MAX1704x I2C-based battery gauge driver
if(CONFIG_I2C_MAX1704X)
list(APPEND SRCS max1704x.c)
endif()
# Add the bq27426 I2C-based battery gauge driver
if(CONFIG_BQ27426)
list(APPEND SRCS bq27426.c)
endif()
endif()
endif()
# Add battery monitor drivers
if(CONFIG_BATTERY_MONITOR)
list(APPEND SRCS battery_monitor.c)
# Add I2C-based battery monitor drivers
if(CONFIG_I2C)
# Add the BQ769x0 I2C-based battery monitor driver
if(CONFIG_I2C_BQ769X0)
list(APPEND SRCS bq769x0.c)
endif()
endif()
endif()
target_sources(drivers PRIVATE ${SRCS})

28
drivers/rc/CMakeLists.txt Normal file
View File

@ -0,0 +1,28 @@
# ##############################################################################
# drivers/rc/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_DRIVERS_RC)
set(SRCS lirc_dev.c)
if(CONFIG_RC_DUMMY)
list(APPEND SRCS dummy.c)
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

30
drivers/rf/CMakeLists.txt Normal file
View File

@ -0,0 +1,30 @@
# ##############################################################################
# drivers/rf/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_DRIVERS_RF)
set(SRCS)
if(CONFIG_SPI)
if(CONFIG_RF_DAT31R5SP)
list(APPEND SRCS dat-31r5-sp.c)
endif()
endif()
target_sources(drivers PRIVATE ${SRCS})
endif()

View File

@ -0,0 +1,31 @@
# ##############################################################################
# drivers/rptun/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_RPTUN)
set(SRCS)
list(APPEND SRCS rptun.c rptun_dump.c)
if(CONFIG_RPTUN_PING)
list(APPEND SRCS rptun_ping.c)
endif()
target_include_directories(drivers PRIVATE ${NUTTX_DIR}/openamp/open-amp/lib)
target_sources(drivers PRIVATE ${SRCS})
endif()

Some files were not shown because too many files have changed in this diff Show More