+
Skip to content

CMake cangen function #453

Open
Open
@BlakeFreer

Description

@BlakeFreer

Improve the cangen-cmake interface.

Currently we use the include command to effectively "copy and paste" the contents of firmware/cmake/cangen.cmake into the project's CMakeLists.

# TMS/CMakeLists.txt
include("${CMAKE_SOURCE_DIR}/cmake/cangen.cmake")
target_sources(main PRIVATE main.cc)

This is a pretty rough interface. A better solution would wrap the existing cangen.cmake logic inside a cmake function and call this function in each project. Thus the project's CMakelists would look something like

# updated TMS/CMakeLists.txt
cangen_generate()
target_sources(main PRIVATE main.cc)

Task

  1. Create a function as above.
  2. To bring the function into scope, include the cmake/cangen.cmake file in the top-level CMakeLists, as is done for functions.cmake here/

    This does not call the function, it only makes it available for calling later.

  3. Add a comments at the top of the function's file describing how and where to use it (should just be a sentence or two).

    Is there a standard CMake documentation / docstring format? Like something that would show your comment when you hover over it in the editor.

  4. Update each project's CMakeLists to replace the existing include with your function call

Considerations

The existing code defines a generated_can target and links it to main. It still must do this, but your function should clearly document the name of this target since some projects (namely Demo/TestCangen) need to use it explicitly

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载