Don't ship config.xml to packaging dir. Useless
[staging/xdg-launcher.git] / README.md
1 AGL CMake template
2 ==================
3
4 Files used to build an application, or binding, project with the
5 AGL Application Framework.
6
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.
13
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.
17
18 Typical project architecture
19 ---------------------------------
20
21 A typical project architecture would be :
22
23 ```tree
24 <project-root-path>
25
26 ├── conf.d/
27 │   ├── default/
28 │   │   ├── cmake/
29 │   │   │   ├── config.cmake.sample
30 │   │   │   ├── export.map
31 │   │   │   └── macros.cmake
32 │   │   ├── deb/
33 │   │   │   └── config.deb.in
34 │   │   ├── rpm/
35 │   │   │   └── config.spec.in
36 │   │   └── wgt/
37 │   │       ├── config.xml.in
38 │   │       ├── config.xml.in.sample
39 │   │       ├── icon-default.png
40 │   │       ├── icon-html5.png
41 │   │       ├── icon-native.png
42 │   │       ├── icon-qml.png
43 │   │       └── icon-service.png
44 │   ├── packaging/
45 │   │   ├── config.xml
46 │   │   ├── config.spec
47 │   │   └── config.deb
48 │   ├── autobuild/
49 │   │   ├── agl
50 │   │   │   └── autobuild.sh
51 │   │   ├── linux
52 │   │   │   └── autobuild.sh
53 │   │   └── windows
54 │   │       └── autobuild.bat
55 │   ├── README.md
56 │   └── config.cmake
57 ├── <libs>
58 ├── <target>
59 ├── <target>
60 └── <target>
61 ```
62
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. |
72
73 Usage
74 ------
75
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 :
77
78 ```bash
79 git submodule add https://gerrit.automotivelinux.org/gerrit/apps/app-templates conf.d/default
80 ```
81
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:
85
86 ```bash
87 ./conf.d/default/autobuild/agl/autobuild.mk package
88 ```
89
90 Or with the classic way :
91
92 ```bash
93 mkdir -p build
94 cd build
95 cmake .. && make
96 ```
97
98 ### Create a CMake target
99
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.
106
107 So, typical usage defining a target is:
108
109 ```cmake
110 PROJECT_TARGET_ADD(SuperExampleName) --> Adding target to your project
111
112 add_executable/add_library(${TARGET_NAME}.... --> defining your target sources
113
114 SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES.... --> fit target properties for macros usage
115
116 INSTALL(TARGETS ${TARGET_NAME}....
117
118 populate_widget() --> add target to widget tree depending upon target properties
119 ```
120
121 ### Build a widget
122
123 #### config.xml.in file
124
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.
128
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.
134
135 #### Using cmake template macros
136
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.
139
140 As the type is not always specified for some custom targets, like an ***HTML5***
141 application, macros make the difference using ***LABELS*** property.
142
143 Example:
144
145 ```cmake
146 SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
147                 LABELS "HTDOCS"
148                 OUTPUT_NAME dist.prod
149         )
150 ```
151
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.
154
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.
159
160 Macro reference
161 --------------------
162
163 ### PROJECT_TARGET_ADD
164
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.
167
168 Example:
169
170 ```cmake
171 PROJECT_TARGET_ADD(low-can-demo)
172 ```
173
174 > ***NOTE***: This will make available the variable `${TARGET_NAME}` 
175 > set with the specificied name. This variable will change at the next call
176 > to this macros.
177
178 ### project_subdirs_add
179
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.
183
184 Usage :
185
186 ```cmake
187 project_subdirs_add()
188 ```
189
190 You also can specify a globbing pattern as argument to filter which folders will be looked for.
191
192 To filter all directories that begin with a number followed by a dash the anything:
193
194 ```cmake
195 project_subdirs_add("[0-9]-*")
196 ```
197
198 ### project_targets_populate
199
200 Macro use to populate widget tree. To make this works you have to specify some properties to your target :
201
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}`
205
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.
209
210 Usage :
211
212 ```cmake
213 project_targets_populate()
214 ```
215
216 ### project_package_build
217
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`
220 directory :
221
222 Usage :
223
224 ```cmake
225 project_package_build()
226 ```
227
228 ### project_closing_message
229
230 Will display the closing message configured in `config.cmake` file. Put it at the end of your project CMake file.