UseEcos¶
此模块定义了构建 eCos 应用程序所需的变量和命令。
在 CMake 项目中加载此模块,使用
include(UseEcos)
命令¶
本模块提供以下命令
构建 eCos 应用程序¶
- ecos_add_include_directories¶
为当前的
CMakeLists.txt文件添加 eCos include 目录。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})