Build Library or Executable from AUTOSAR Adaptive Model
As part of generating code for an AUTOSAR adaptive model, you can generate a
CMakeLists.txt file for building a static or shared library or an
AUTOSAR Adaptive | CMake toolchain generates the
CMakeLists.txt file following modular CMake patterns. You can link
the resulting library against a
main.cpp file or combine it with other
model files in an integration environment.
Building the library file from
CMakeLists.txt requires running CMake
To build a static or shared library:
Open a component model that is configured for the AUTOSAR adaptive target
Open the Configuration Parameters dialog box and select Code Generation. Under Toolchain settings:
Set Toolchain to
AUTOSAR Adaptive | CMake.
Set Build configuration to
Set CMake Target Type to
Static(for a static library) or
Shared(for a shared library).
In the Include Directories, Link Libraries, and Library Paths fields, specify libraries and header files that must be generated in
CMakeLists.txtto support compilation. For example, set Include Directories to the string
modelNameis the name of the adaptive model.
Build the model. The build generates C++ code, ARXML files, and a
In the model build folder, open
CMakeLists.txtand verify that it is configured for static or shared library generation. For example, check that:
add_library(modelName SHARED...) % for shared library
add_library(modelName STATIC...) % for static library
The specifications for
link_directoriesinclude the values specified in Toolchain settings.
Go to the model build folder outside MATLAB. To build the static or shared library file, enter these commands:
cmake CMakeLists.txt; make all;
The make generates a library file for the adaptive model (for example,
modelName.so) in the model build
folder. You can link the library against a
main.cpp file or combine it
with other model files in an integration environment.
To build an executable, do one of the following:
AUTOSAR Adaptive | CMaketoolchain. Follow the same procedure as for libraries, but set CMake Target Type to
To generate a standalone executable, use the
AUTOSAR Adaptive Linux Executabletoolchain. For more information, see Build Out of the Box Linux Executable from AUTOSAR Adaptive Model.