Skip to content

Latest commit

 

History

History
117 lines (95 loc) · 5.21 KB

GeneratedProjectWalkthrough.md

File metadata and controls

117 lines (95 loc) · 5.21 KB

Generated CMake Project Walkthrough

This documetation page contains detailed information on what is being generated by the commsdsl2comms utility. Please open one of the generated example projects, such as cc.demo1.generated in a separate browser tab or clone the project to your PC and follow the description below.

Folders

The generated CMake project has multiple folders.

Protocol Definition

The protocol definition itself is headers only library which can be found in the include folder.

The common fields which can be referenced by multiple messages reside in the field folder / namespace.

All the message classes are defined in the message folder / namespace.

All the available transport frames are defined in the frame folder / namespace.

The various generated input messages bundles reside in the input folder / namespace.

All the available auxiliary switch statement based message dispatch functions are defined in various files in the dispatch folder / namespace.

All the available compile time configuration options of the protocol reside in the options folder / namespace.

All the available auxiliary switch statement based message factory classes (suitable for the replacement of the comms::MsgFactory) are defined in various files in the factory folder / namespace.

Protocol Documentation

The configuration of the doxygen documentation resides in the doc folder.

CMake Configuration.

Please open the main CMakeLists.txt file. It should list all the available options and configuration variables, something like this:

option (OPT_REQUIRE_COMMS_LIB "Require COMMS library, find it and set as dependency to the protocol library" ON)

# Other parameters:
# OPT_CMAKE_EXPORT_NAMESPACE - Set namespace for a protocol library
#     exported via generated *Config.cmake file. Defaults to "cc".
# OPT_CMAKE_EXPORT_CONFIG_NAME - Override default name "test1" of the cmake generated config file export
#     (test1Config) with provided new name.

The generated protocol code requires COMMS Library. By default the cmake configuration process will try to locate it using

find_package(LibComms REQUIRED)

The build process (which is just copying relevant files to the install directory) does not really require presence of the COMMS Library. If the client code is going to provide relevant include directories by other means, then it is possible to suppress the requirement for the presence of the COMMS Library during cmake execution.

cmake -DOPT_REQUIRE_COMMS_LIB=OFF ...

Also note that if search for the COMMS Library is NOT excluded, it's directory should be listed in CMAKE_PREFIX_PATH variable

cmake -DCMAKE_PREFIX_PATH=/path/to/comms/install/dir ...

Building Documentation

In addition to protocols headers installation, the CMake project also contains target doc_<proj_name> to build doxygen documentation of the protocol. For example for cc.demo1.generated it is doc_demo1:

$> make doc_demo1

CMake Import

When built and installed the project exports and installs the cmake target definition of the protocol library in <install_dir>/lib/<protocol_name>/<protocol_name>Config.cmake file, that can be imported in some other project that uses CMake as its build system.

list (APPEND CMAKE_PREFIX_PATH "/path/to/protocol/install/dir")
find_package (demo1 REQUIRED NO_MODULE)
target_link_libraries (my_proj cc::demo1)

Note, that cc:: is a default namespace for exported project. It is possible to change it using OPT_CMAKE_EXPORT_NAMESPACE cmake variable described earlier.

Also note that in case of excluding COMMS Library lookup during the protocol build process it needs to be found separately and used inside target_link_libraries() invocation.

list (APPEND CMAKE_PREFIX_PATH "/path/to/cc_tools_qt/install/dir")
find_package (LibComms REQUIRED NO_MODULE)
target_link_libraries (my_proj cc::demo1 cc::comms)

Please also read doc/CMake.md documentation page of the COMMS Library project for the overview on how to import the latter in other CMake projects.