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 `examples` folder.
15 More advanced usage can be saw with the [low-level-can-service](https://gerrit.automotivelinux.org/gerrit/apps/low-level-can-service)
16 which mix external libraries, binding.
18 Typical project architecture
19 ---------------------------------
21 A typical project architecture would be :
29 │ │ │ ├── config.cmake.sample
31 │ │ │ └── macros.cmake
33 │ │ │ └── config.deb.in
35 │ │ │ └── config.spec.in
38 │ │ ├── config.xml.in.sample
39 │ │ ├── icon-default.png
40 │ │ ├── icon-html5.png
41 │ │ ├── icon-native.png
43 │ │ └── icon-service.png
50 │ │ │ └── autobuild.sh
52 │ │ │ └── autobuild.sh
63 | # | Parent | Description |
64 | - | -------| ----------- |
65 | \<root-path\> | - | Path to your project. Hold master CMakeLists.txt and general files of your projects. |
66 | 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. |
67 | default | conf.d | Holds examples files and cmake macros used to build packages |
68 | packaging | conf.d | Contains output files used to build packages. |
69 | autobuild | conf.d | Scripts used to build packages the same way for differents platforms. |
70 | \<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. |
71 | \<target\> | \<root-path\> | A target to build, typically library, executable, etc. |
76 To use these templates files on your project just install the reference files using **git submodule** then use `config.cmake` file to configure your project specificities :
79 git submodule add https://gerrit.automotivelinux.org/gerrit/apps/app-templates conf.d/default
82 Specify manually your targets, you should look at samples provided in this
83 repository to make yours. Then when you are ready to build, using `autobuild`
84 that will wrap CMake build command:
87 ./conf.d/default/autobuild/agl/autobuild.mk package
90 Or with the classic way :
98 ### Create a CMake target
100 For each target part of your project, you need to use ***PROJECT_TARGET_ADD***
101 to include this target to your project, using it make available the cmake
102 variable ***TARGET_NAME*** until the next ***PROJECT_TARGET_ADD*** is invoked
103 with a new target name. Be aware that ***populate_widget*** macro will also use
104 ***PROJECT_TARGET_ADD*** so ***TARGET_NAME*** will change after using
105 ***populate_widget*** macro.
107 So, typical usage defining a target is:
110 PROJECT_TARGET_ADD(SuperExampleName) --> Adding target to your project
112 add_executable/add_library(${TARGET_NAME}.... --> defining your target sources
114 SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES.... --> fit target properties for macros usage
116 INSTALL(TARGETS ${TARGET_NAME}....
118 populate_widget() --> add target to widget tree depending upon target properties
123 #### config.xml.in file
125 To build a widget you need to configure file _config.xml_. This repo
126 provide a simple default file _config.xml.in_ that will be configured using the
127 variable set in _config.cmake_ file.
129 > ***CAUTION*** : The default file is only meant to be use for a
130 > simple widget app, more complicated ones which needed to export
131 > their api, or ship several app in one widget need to use the provided
132 > _config.xml.in.sample_ which had all new Application Framework
133 > features explained and examples.
135 #### Using cmake template macros
137 To leverage all macros features, you have to specify ***properties*** on your
138 targets. Some macros will not works without specifying which is the target type.
140 As the type is not always specified for some custom targets, like an ***HTML5***
141 application, macros make the difference using ***LABELS*** property.
146 SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
148 OUTPUT_NAME dist.prod
152 If your target output is not named as the ***TARGET_NAME***, you need to specify
153 ***OUTPUT_NAME*** property that will be used by the ***populate_widget*** macro.
155 Use the ***populate_widget*** macro as latest statement of your target
156 definition. Then at the end of your project definition you should use the macro
157 ***build_widget*** that make an archive from the populated widget tree using the
158 `wgtpkg-pack` Application Framework tools.
163 ### PROJECT_TARGET_ADD
165 Typical usage would be to add the target to your project using macro
166 `PROJECT_TARGET_ADD` with the name of your target as parameter.
171 PROJECT_TARGET_ADD(low-can-demo)
174 > ***NOTE***: This will make available the variable `${TARGET_NAME}`
175 > set with the specificied name. This variable will change at the next call
178 ### project_subdirs_add
180 This macro will search in all subfolder any `CMakeLists.txt` file. If found then
181 it will be added to your project. This could be use in an hybrid application by
182 example where the binding lay in a sub directory.
187 project_subdirs_add()
190 You also can specify a globbing pattern as argument to filter which folders will be looked for.
192 To filter all directories that begin with a number followed by a dash the anything:
195 project_subdirs_add("[0-9]-*")
198 ### project_targets_populate
200 Macro use to populate widget tree. To make this works you have to specify some properties to your target :
202 * LABELS : specify *BINDING*, *HTDOCS*, *EXECUTABLE*, *DATA*
203 * PREFIX : must be empty **""** when target is a *BINDING* else default prefix *lib* will be applied
204 * OUTPUT_NAME : Name of the output file generated, useful when generated file name is different from `${TARGET_NAME}`
206 Always specify `populate_widget()` macro as the last statement, especially if
207 you use ${TARGET_NAME} variable. Else variable will be set at wrong value with
208 the **populate_** target name.
213 project_targets_populate()
216 ### project_package_build
218 Use at project level, to gather all populated targets in the widget tree plus
219 widget specifics files into a **WGT** archive. Generated under your `build`
225 project_package_build()
228 ### project_closing_message
230 Will display the closing message configured in `config.cmake` file. Put it at the end of your project CMake file.