UseEcos

此模块定义了构建eCos应用程序所需的变量并提供了相关命令。

在 CMake 项目中加载此模块,使用

include(UseEcos)

命令

本模块提供以下命令

构建eCos应用程序

ecos_add_include_directories

为当前CMakeLists.txt文件添加eCos包含目录

ecos_add_include_directories()
ecos_adjust_directory

调整给定源文件的路径

ecos_adjust_directory(<var> <sources>...)

此命令修改源文件<sources>...的路径,使其适用于ecos_add_executable(),并将其存储在变量<var>中。

<var>

保存调整后源文件新列表的结果变量名。

<sources>...

要调整路径的相对或绝对源文件列表。

当实际源文件位于上一级目录时使用此命令。对于作为相对路径给出的每个源文件,必须在前面加上../

ecos_add_executable

创建一个eCos应用程序可执行文件

ecos_add_executable(<name> <sources>...)
<name>

可执行文件的名称。

<sources>...

所有源文件的列表,其路径已通过调用ecos_adjust_directory()预先调整。

此命令还会设置本地变量ECOS_DEFINITIONS,其中包含一些常见的编译定义。

选择工具链

ecos_use_arm_elf_tools

在其被调用的目录中启用ARM ELF工具链

ecos_use_arm_elf_tools()

当为xscale处理器编译时使用此命令。

ecos_use_i386_elf_tools

在其被调用的目录中启用i386 ELF工具链

ecos_use_i386_elf_tools()
ecos_use_ppc_eabi_tools

在其被调用的目录中启用PowerPC工具链

ecos_use_ppc_eabi_tools()

变量

此模块还定义了以下变量

ECOSCONFIG_EXECUTABLE

缓存变量,包含ecosconfig可执行文件(eCos配置程序)的路径。

ECOS_CONFIG_FILE

一个默认为ecos.ecc的局部变量。如果eCos配置文件有不同的名称,请在调用ecos_add_executable()之前调整此变量。

示例

以下示例演示了在一个遵循常见eCos约定(将源文件列在位于当前CMakeLists.txt上一级目录的ProjectSources.txt文件中)的项目中定义eCos可执行目标

CMakeLists.txt
include(UseEcos)

# Add the eCos include directories.
ecos_add_include_directories()

# Include the file with the eCos sources list. This file, for example, defines
# a list of eCos sources:
#   set(sources file_1.cxx file_2.cxx file_3.cxx)
include(../ProjectSources.txt)

# When using such directory structure, relative source paths must be adjusted:
ecos_adjust_directory(adjusted_sources ${sources})

# Create eCos executable.
ecos_add_executable(ecos_app ${adjusted_sources})