4 Files used to build an application, or binding, project with the
5 AGL Application Framework.
7 To build your AGL project using these templates, you have to install
8 them within your project and adjust compilation option in `config.cmake`.
9 For technical reasons, you also have to specify **cmake** target in
10 sub CMakeLists.txt installed. Make a globbing search to find source files
11 isn't recommended now to handle project build especially in a multiuser
12 project because CMake will not be aware of new or removed source files.
14 You'll find simple usage example for different kind of target under the
15 `examples` folder. More advanced usage can be saw with the
16 [low-level-can-service](https://gerrit.automotivelinux.org/gerrit/apps/low-level-can-service)
17 which mix external libraries, binding.
19 Typical project architecture
20 ---------------------------------
22 A typical project architecture would be :
32 │ │ │ │ └── autobuild.sh
34 │ │ │ │ └── autobuild.sh
36 │ │ │ └── autobuild.bat
38 │ │ │ ├── config.cmake.sample
40 │ │ │ └── macros.cmake
42 │ │ │ └── config.deb.in
44 │ │ │ └── config.spec.in
47 │ │ ├── config.xml.in.sample
48 │ │ ├── icon-default.png
49 │ │ ├── icon-html5.png
50 │ │ ├── icon-native.png
52 │ │ └── icon-service.png
66 | # | Parent | Description |
67 | - | -------| ----------- |
68 | \<root-path\> | - | Path to your project. Hold master CMakeLists.txt and general files of your projects. |
69 | conf.d | \<root-path\> | Git submodule to app-templates AGL repository which provides CMake helpers macros library, and build scripts. config.cmake is a copy of config.cmake.sample configured for the projects. |
70 | app-templates | conf.d | Holds examples files and cmake macros used to build packages |
71 | packaging | conf.d | Contains output files used to build packages. |
72 | autobuild | conf.d | Scripts used to build packages the same way for differents platforms. |
73 | \<libs\> | \<root-path\> | External dependencies libraries. This isn't to be used to include header file but build and link statically specifics libraries. | Library sources files. Can be a decompressed library archive file or project fork. |
74 | \<target\> | \<root-path\> | A target to build, typically library, executable, etc. |
79 To use these templates files on your project just install the reference files using
80 **git submodule** then use `config.cmake` file to configure your project specificities :
83 git submodule add https://gerrit.automotivelinux.org/gerrit/apps/app-templatesconf.d/app-templates
86 Specify manually your targets, you should look at samples provided in this
87 repository to make yours. Then when you are ready to build, using `autobuild`
88 that will wrap CMake build command:
91 ./conf.d/app-templates/autobuild/agl/autobuild.mk package
94 Or with the classic way :
102 ### Create a CMake target
104 For each target part of your project, you need to use ***PROJECT_TARGET_ADD***
105 to include this target to your project, using it make available the cmake
106 variable ***TARGET_NAME*** until the next ***PROJECT_TARGET_ADD*** is invoked
107 with a new target name. Be aware that ***populate_widget*** macro will also use
108 ***PROJECT_TARGET_ADD*** so ***TARGET_NAME*** will change after using
109 ***populate_widget*** macro.
111 So, typical usage defining a target is:
114 PROJECT_TARGET_ADD(SuperExampleName) --> Adding target to your project
116 add_executable/add_library(${TARGET_NAME}.... --> defining your target sources
118 SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES.... --> fit target properties
121 INSTALL(TARGETS ${TARGET_NAME}....
123 populate_widget() --> add target to widget tree depending upon target properties
128 #### config.xml.in file
130 To build a widget you need to configure file _config.xml_. This repo
131 provide a simple default file _config.xml.in_ that will be configured using the
132 variable set in _config.cmake_ file.
134 > ***CAUTION*** : The default file is only meant to be use for a
135 > simple widget app, more complicated ones which needed to export
136 > their api, or ship several app in one widget need to use the provided
137 > _config.xml.in.sample_ which had all new Application Framework
138 > features explained and examples.
140 #### Using cmake template macros
142 To leverage all macros features, you have to specify ***properties*** on your
143 targets. Some macros will not works without specifying which is the target type.
145 As the type is not always specified for some custom targets, like an ***HTML5***
146 application, macros make the difference using ***LABELS*** property.
151 SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
153 OUTPUT_NAME dist.prod
157 If your target output is not named as the ***TARGET_NAME***, you need to specify
158 ***OUTPUT_NAME*** property that will be used by the ***populate_widget*** macro.
160 Use the ***populate_widget*** macro as latest statement of your target
161 definition. Then at the end of your project definition you should use the macro
162 ***build_widget*** that make an archive from the populated widget tree using the
163 `wgtpkg-pack` Application Framework tools.
168 ### PROJECT_TARGET_ADD
170 Typical usage would be to add the target to your project using macro
171 `PROJECT_TARGET_ADD` with the name of your target as parameter.
176 PROJECT_TARGET_ADD(low-can-demo)
179 > ***NOTE***: This will make available the variable `${TARGET_NAME}`
180 > set with the specificied name. This variable will change at the next call
183 ### project_subdirs_add
185 This macro will search in all subfolder any `CMakeLists.txt` file. If found then
186 it will be added to your project. This could be use in an hybrid application by
187 example where the binding lay in a sub directory.
192 project_subdirs_add()
195 You also can specify a globbing pattern as argument to filter which folders
198 To filter all directories that begin with a number followed by a dash the
202 project_subdirs_add("[0-9]-*")
205 ### project_targets_populate
207 Macro use to populate widget tree. To make this works you have to specify some
208 properties to your target :
210 * LABELS : specify *BINDING*, *HTDOCS*, *EXECUTABLE*, *DATA*
211 * PREFIX : must be empty **""** when target is a *BINDING* else default prefix
212 *lib* will be applied
213 * OUTPUT_NAME : Name of the output file generated, useful when generated file
214 name is different from `${TARGET_NAME}`
216 Always specify `populate_widget()` macro as the last statement, especially if
217 you use ${TARGET_NAME} variable. Else variable will be set at wrong value with
218 the **populate_** target name.
223 project_targets_populate()
226 ### project_package_build
228 Use at project level, to gather all populated targets in the widget tree plus
229 widget specifics files into a **WGT** archive. Generated under your `build`
235 project_package_build()
238 ### project_closing_message
240 Will display the closing message configured in `config.cmake` file. Put it at
241 the end of your project CMake file.