grovelight.cxx: add grovelight sample code
[contrib/upm.git] / docs / building.md
1 Building UPM                         {#building}
2 ============
3
4 UPM uses cmake in order to make compilation relatively painless. Cmake runs
5 build out of tree so the recommended way is to clone from git and make a build/
6 directory.
7
8 UPM will attempt to build all directories inside src/ and they must contain
9 individual CMakeLists.txt files.
10
11 ~~~~~~~~~~~~~{.sh}
12 mkdir build
13 cd build
14 cmake ..
15 make
16 ~~~~~~~~~~~~~
17
18 Our cmake configure has a number of options, `cmake -i` will ask you all sorts
19 of interesting questions, you can disable swig modules, build documentation
20 etc...
21
22 Few recommended options:
23 Changing install path from /usr/local to /usr
24 -DCMAKE_INSTALL_PREFIX:PATH=/usr
25
26 Building debug build:
27 -DCMAKE_BUILD_TYPE=DEBUG
28
29 Using clang instead of gcc:
30  -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang
31
32 Often developers are only interested in building one module or even just the
33 python/node module to do some quick testing using scripting. In order to do
34 this you need to use the target name for the python or node module you want to
35 rebuild. For example the lcd module target name is i2clcd. Therfore the python
36 module target name will be prefixed by _pyupm_. Just do the following to build
37 only that module. Modules not using the UPM cmake macros may have different
38 naming.
39
40 ~~~~~~~~~~~~~
41 make _pyupm_i2clcd
42 ~~~~~~~~~~~~~
43
44 Sometimes you want to build a small C++ example against an installed library.
45 This is fairly easy if installed systemwide. Just link against the correct
46 librar (in this case libupm-tm1637) and then add /usr/include/upm to the loader
47 path:
48
49 ~~~~~~~~~~~~
50 g++ test.cxx -lupm_tm1637 -I/usr/include/upm
51 ~~~~~~~~~~~~
52
53 You can also use pkg-config to return the information to you, which is
54 considered the correct way if including UPM in a build system like cmake or
55 autotools on linux.
56
57 ~~~~~~~~~~~
58 pkg-config --cflags --libs upm-tm1637
59 ~~~~~~~~~~~