acf2a3ab7900cad2b8bd5654deda5d56f1db296c
[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 [CAN_signaling binding](https://github.com/iotbzh/CAN_signaling)
16 which mix external libraries, binding, and html5 hybrid demo application.
17
18 Typical project architecture
19 -----------------------------
20
21 A typical project architecture would be :
22
23 * \<root-path\>/
24 * \<root-path\>/<libs>
25 * \<root-path\>/packaging
26 * \<root-path\>/packaging/wgt
27 * \<root-path\>/packaging/wgt/etc
28 * \<root-path\>/\<target\>/
29
30 | # | Parent | Description | Files |
31 | - | -------| ----------- | ----- |
32 | \<root-path\> | - | Path to your project | Hold master CMakeLists.txt and general files of your projects. |
33 | \<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. |
34 | \<target\> | \<root-path\> | A sub component between: tool, binding, html5, html5-hybrid type. | ----- |
35 | packaging | \<root-path\> | Contains folder by package type (rpms, deb, wgt...) | Directory for each packaging type. |
36 | wgt | packaging | Files used to build project widget that can be installed on an AGL target. | config.xml.in, icon.png.in files. |
37 | etc | wgt | Configuration files for your project. This will be installed in the application root directory under etc/ folder once installed by Application Framework. | specific project configuration files |
38
39 Usage
40 ------
41
42 Once installed, use them by customize depending on your project with file
43 `\<root-path\>/etc/config.cmake`.
44
45 Specify manually your targets, you should look at samples provided in this
46 repository to make yours. Then when you are ready to build, using `AGLbuild`
47 that will wrap CMake build command:
48
49 ```bash
50 `./AGLBuild` package
51 ```
52
53 Or with the classic way :
54
55 ```bash
56 mkdir -p build && cd build
57 cmake .. && make
58 ```
59
60 ### Create a CMake target
61
62 For each target part of your project, you need to use ***PROJECT_TARGET_ADD***
63 to include this target to your project, using it make available the cmake
64 variable ***TARGET_NAME*** until the next ***PROJECT_TARGET_ADD*** is invoked
65 with a new target name. Be aware that ***populate_widget*** macro will also use
66 ***PROJECT_TARGET_ADD*** so ***TARGET_NAME*** will change after using
67 ***populate_widget*** macro.
68
69 So, typical usage defining a target is:
70
71 ```cmake
72 PROJECT_TARGET_ADD(SuperExampleName) --> Adding target to your project
73
74 add_executable/add_library(${TARGET_NAME}.... --> defining your target sources
75
76 SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES.... --> fit target properties for macros usage
77
78 INSTALL(TARGETS ${TARGET_NAME}....
79
80 populate_widget() --> add target to widget tree depending upon target properties
81 ```
82
83 ### Build a widget using provided macros
84
85 To leverage all macros features, you have to specify ***properties*** on your
86 targets. Some macros will not works without specifying which is the target type.
87 As the type is not always specified for some custom target, like an ***HTML5***
88 application, macros make the difference using ***LABELS*** property.
89
90 ```cmake
91 SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
92                 LABELS "HTDOCS"
93                 OUTPUT_NAME dist.prod
94         )
95 ```
96
97 If your target output is not named as the ***TARGET_NAME***, you need to specify
98 ***OUTPUT_NAME*** property that will be used by the ***populate_widget*** macro.
99
100 Use the ***populate_widget*** macro as latest statement of your target
101 definition. Then at the end of your project definition you should use the macro
102 ***build_widget*** that make an archive from the populated widget tree using the
103 `wgtpkg-pack` Application Framework tools.
104
105 Macro reference
106 ----------------
107
108 ### PROJECT_TARGET_ADD
109
110 Typical usage would be to add the target to your project using macro
111 `PROJECT_TARGET_ADD` with the name of your target as parameter. Example:
112
113 ```cmake
114 PROJECT_TARGET_ADD(low-can-demo)
115 ```
116
117 This will make available the variable `${TARGET_NAME}` set with the specificied
118 name.
119
120 ### search_targets
121
122 This macro will search in all subfolder any `CMakeLists.txt` file. If found then
123 it will be added to your project. This could be use in an hybrid application by
124 example where the binding lay in a sub directory.
125
126 Usage :
127
128 ```cmake
129 search_targets()
130 ```
131
132 ### populate_widget
133
134 Macro use to populate widget tree. To make this works you have to specify some properties to your target :
135
136 - LABELS : specify *BINDING*, *HTDOCS*, *EXECUTABLE*, *DATA*
137 - PREFIX : must be empty **""** when target is a *BINDING* else default prefix *lib* will be applied
138 - OUTPUT_NAME : Name of the output file generated, useful when generated file name is different from `${TARGET_NAME}`
139
140 Always specify  `populate_widget()` macro as the last statement, especially if
141 you use ${TARGET_NAME} variable. Else variable will be set at wrong value with
142 the **populate_** target name.
143
144 Usage :
145
146 ```cmake
147 populate_widget()
148 ```
149
150 ### build_widget
151
152 Use at project level, to gather all populated targets in the widget tree plus
153 widget specifics files into a **WGT** archive. Generated under your `build`
154 directory :
155
156 Usage :
157
158 ```cmake
159 build_widget()
160 ```