register_imported_project

Explicitly references an external project file from an Advanced CMake project.

Syntax

register_imported_project(
    NAME <name>
    PATH <project file path>
    LEVEL <level>
)

Overview

The register_imported_project statement is created by VisualGDB when importing projects from other formats (e.g. IAR, Keil, STM32CubeIDE). It explicitly marks the project as imported, so that VisualGDB can check the original file for changes and suggest updating the CMake files when needed. It also creates the <NAME>_LOCATION variable that is used in add_bsp_based_executable and target_include_directories to avoid hardcoding the project path.

VisualGDB stores a snapshot of the imported project structure in the <NAME>.importedproj file that should be checked into source control to allow detecting and applying project changes.

Parameters

NAME
Specifies an internal name for the imported project. It should match the executable name that was created from the project using the add_bsp_based_executable statement. The name will be used to define the <NAME>_LOCATION variable and to locate the <NAME>.importedproj file.

PATH
Specifies the path to the project file. Can be absolute or relative to the current source directory.

LEVEL
Optional. Specifies how far up the <NAME>_LOCATION variable should point. If LEVEL is 1, the <NAME>_LOCATION variable will point to the directory of the project file specified via PATH. If LEVEL is 2, it will point to its parent directory. Each subsequent LEVEL will go one directory up.

Examples

The following example registers a basic imported project:

register_imported_project(NAME ImportedProject
                          PATH c:/project/EWARM/Project.ewp
                          LEVEL 2)

add_bsp_based_executable(NAME ImportedProject
                         SOURCES ${ImportedProject_LOCATION}/Src/main.c)

target_include_directories(ImportedProject PRIVATE
                           ${ImportedProject_LOCATION}/Inc)

In this example the LEVEL is set to 2, so ImportedProject_LOCATION will point to c:/project. The project will contain the c:/project/Src/main.c file and search for headers in the c:/project/Inc directory.

See also

Auxiliary Statements, add_embedded_resource, bsp_configure_code_coverage, embed_target_output,