UseEcos — CMake 4.1.4 Documentation

# UseEcos

This module defines variables and provides commands required to build an eCos application.

Load this module in CMake project with:

    include(UseEcos)

## Commands

This module provides the following commands:

### Building an eCos Application

ecos_add_include_directories

  Adds the eCos include directories for the current `CMakeLists.txt` file:

      ecos_add_include_directories()

ecos_adjust_directory

  Adjusts the paths of given source files:

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

  This command modifies the paths of the source files `<sources>...` to make them suitable for use with `ecos_add_executable()`, and stores them in the variable `<var>`.

  `<var>`

    Result variable name holding a new list of source files with adjusted paths.

  `<sources>...`

    A list of relative or absolute source files to adjust their paths.

  Use this command when the actual sources are located one level upwards. A `../` has to be prepended in front of every source file that is given as a relative path.

ecos_add_executable

  Creates an eCos application executable:

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

  `<name>`

    The name of the executable.

  `<sources>...`

    A list of all source files, where the path has been adjusted beforehand by calling the `ecos_adjust_directory()`.

  This command also sets the `ECOS_DEFINITIONS` local variable, holding some common compile definitions.

### Selecting the Toolchain

ecos_use_arm_elf_tools

  Enables the ARM ELF toolchain for the directory where it is called:

      ecos_use_arm_elf_tools()

  Use this command, when compiling for the xscale processor.

ecos_use_i386_elf_tools

  Enables the i386 ELF toolchain for the directory where it is called:

      ecos_use_i386_elf_tools()

ecos_use_ppc_eabi_tools

  Enables the PowerPC toolchain for the directory where it is called:

      ecos_use_ppc_eabi_tools()

## Variables

This module also defines the following variables:

`ECOSCONFIG_EXECUTABLE`

  Cache variable that contains a path to the `ecosconfig` executable (the eCos configuration program).

`ECOS_CONFIG_FILE`

  A local variable that defaults to `ecos.ecc`. If eCos configuration file has a different name, adjust this variable before calling the `ecos_add_executable()`.

## Examples

The following example demonstrates defining an eCos executable target in a project that follows the common eCos convention of listing source files in a `ProjectSources.txt` file, located one directory above the current `CMakeLists.txt`:

`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})