3 title: Configuring AGL CMake Templates
5 https://git.automotivelinux.org/src/cmake-apps-module/plain/docs/dev_guide/configuring-cmake.md?h=master
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/devguides/master/cmake-apps-module-guides-devguides-book.yml -->
10 # Configuring AGL CMake Templates
12 Configuration consists of editing the `config.cmake` file for your
15 ## Creating Your `config.cmake` File
17 First, you need to create a `confd/cmake` file in your CMake project
24 Next, use one of the following commands to copy a `cmake.sample` file to
25 your `config.cmake` file.
26 The first command applies if you have the SDK installed, while the
27 second command applies if you installed the modules on your native Linux system.
29 **NOTE:** The `OECORE_NATIVE_SYSROOT` variable is defined once you have
30 a project folder, the AGL SDK source files, and the CMake modules installed.
34 # From the SDK sysroot >= RC2 of the 7.0.0 Guppy release
35 cp ${OECORE_NATIVE_SYSROOT}/usr/share/doc/CMakeAfbTemplates/samples.d/config.cmake.sample conf.d/cmake/config.cmake
36 # From a native installation
37 cp /usr/share/doc/CMakeAfbTemplates/samples.d/config.cmake.sample conf.d/cmake/config.cmake
40 Once you have created your `config.cmake` file, you need to make the changes
41 specific to your project.
43 ## Creating Your `CMakeLists.txt` File
45 To create this file, use the example in the **cmake module**.
46 Use one of the following two commands to create your file.
47 The first command applies if you have the SDK installed, while the
48 second command applies if you installed the modules on your native Linux system.
50 **NOTE:** The `OECORE_NATIVE_SYSROOT` variable is defined once you have
51 a project folder, the AGL SDK source files, and the CMake modules installed.
54 # From the SDK sysroot >= RC2 of the 7.0.0 Guppy release
55 cp ${OECORE_NATIVE_SYSROOT}/usr/share/doc/CMakeAfbTemplates/samples.d/CMakeLists.txt.sample CMakeLists.txt
56 # From a native installation
57 cp /usr/share/doc/CMakeAfbTemplates/samples.d/CMakeLists.txt.sample CMakeLists.txt
60 ## Creating Your CMake Targets
62 Creating a CMake target is the result of editing your `CMakeLists.txt` file.
64 For each target that is part of your project, you need to use the
65 ***PROJECT_TARGET_ADD*** statement.
66 Using this statement includes the target in your project.
68 Using the ***PROJECT_TARGET_ADD*** statement makes the CMake ***TARGET_NAME***
69 variable available until the next ***PROJECT_TARGET_ADD*** statement is
70 encountered that uses a new target name.
72 Following is typical use within the `CMakeLists.txt` file to create a target:
75 PROJECT_TARGET_ADD(target_name) --> Adds *target_name* to the project.
76 *target_name* is a sub-folder in the CMake project.
78 add_executable/add_library(${TARGET_NAME}.... --> Defines the target sources.
80 SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES.... --> Configures the target properties
81 so they can be used by macros.
83 INSTALL(TARGETS ${TARGET_NAME}....
88 Target properties are used to determine the nature of the
89 target and where the target is stored within the package being built.
91 Use the **LABELS** property to specify the target type that you want
92 included in the widget package.
93 You can choose the following target types:
97 - **BINDING**: A shared library loaded by the AGL Application Framework.
98 - **BINDINGV2**: A shared library loaded by the AGL Application Framework.
99 This library must be accompanied by a JSON file named similar to the
100 *${OUTPUT_NAME}-apidef* of the target, which describes the API with OpenAPI
101 syntax (e.g: *mybinding-apidef*).
102 Alternatively, you can choose the name without the extension using the
103 **set_openapi_filename** macro.
104 If you use C++, you must set **PROJECT_LANGUAGES** through *CXX*.
105 - **BINDINGV3**: A shared library loaded by the AGL Application Framework.
106 This library must be accompanied by a JSON file named similar to the
107 *${OUTPUT_NAME}-apidef* of the target, which describes the API with OpenAPI
108 syntax (e.g: *mybinding-apidef*).
109 Alternatively, you can choose the name without the extension using the
110 **set_openapi_filename** macro.
111 If you use C++, you must set **PROJECT_LANGUAGES** through *CXX*.
112 - **PLUGIN**: A shared library meant to be used as a binding plugin, which
113 would load the library as a plugin consequently extending its
115 You should name the binding using a special extension that you choose
116 with `SUFFIX cmake target property`.
117 If you do not use the special extension, it defaults to **.ctlso**.
118 - **HTDOCS**: The root directory of a web application.
119 This target has to build its directory and puts its files in the
120 **${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}**.
121 - **DATA**: Resources used by your application.
122 This target has to build its directory and puts its files in the
123 **${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}**.
124 - **EXECUTABLE**: The entry point of your application executed by the AGL
125 Application Framework.
126 - **LIBRARY**: An external third-party library bundled with the binding.
127 The library is bundled in this manner because the platform does not
129 - **BINDING-CONFIG**: Any files used as configuration by your binding.
131 **TIP:** you should use the prefix _afb-_ (**Application Framework Binding**)
132 with your *BINDING* targets.
134 Following is an example that uses the **BINDINGV3** property:
137 SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
140 OUTPUT_NAME "file_output_name")
143 **CAUTION**: You do not need to specify an **INSTALL** command for these
145 Installation is performed by the template.
146 Targets are installed in the **${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}**