]> vaikene.ee Git - evaf/blob - www/pswgen08.html
Warning fixes and copyright update.
[evaf] / www / pswgen08.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html lang="et" xmlns="http://www.w3.org/1999/xhtml" xml:lang="et">
3
4 <head>
5 <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8" />
6 <title>eVaf Tutorial - 08 - Building Storage Module</title>
7 <meta name="Author" content="Enar Väikene" />
8 <meta name="description" content="eVaf Tutorial" />
9 <meta name="keywords" content="evaf c++ application development framework tutorial password generator" />
10 <link rel="StyleSheet" href="evaf.css" type="text/css" media="all" />
11 <link rel="StyleSheet" href="highlight.css" type="text/css" media="all" />
12 </head>
13
14 <body>
15
16 <p>Next: <a href="pswgen09.html">09 - GUI Module</a>, Previous: <a href="pswgen07.html">07 - Storage Module</a></p>
17
18 <h1>eVaf Tutorial</h1>
19
20 <h2>08 - Buiding Storage Module</h2>
21
22 <h3>CMakeLists.txt</h3>
23
24 <p>Copy an existing <tt>CMakeLists.txt</tt> file from the <tt>Generator</tt> module:</p>
25
26 <pre>evaf/src/apps/PswGen/Storage $ <code>cp ../Generator/CMakeLists.txt .</code></pre>
27
28 <p>We only need to modify the <tt>TARGET</tt> variable and set <tt>QT_USE_QTSQL</tt> to <tt>TRUE</tt>:</p>
29
30 <pre class="hl"><span class="hl com"># Name of the target</span>
31 <span class="hl kwa">set</span><span class="hl opt">(</span>TARGET PswStorage<span class="hl opt">)</span>
32
33 <span class="hl com"># Qt modules</span>
34 <span class="hl kwa">set</span><span class="hl opt">(</span>QT_USE_QTSQL TRUE<span class="hl opt">)</span></pre>
35
36 <p>Here is the final <tt>CMakeLists.txt</tt> file:</p>
37
38 <pre class="hl"><span class="hl com"># src/apps/PswGen/Storage/CMakeLists.txt</span>
39
40 <span class="hl com"># Name of the target</span>
41 <span class="hl kwa">set</span><span class="hl opt">(</span>TARGET PswStorage<span class="hl opt">)</span>
42
43 <span class="hl com"># Qt modules</span>
44 <span class="hl kwa">set</span><span class="hl opt">(</span>QT_USE_QTSQL TRUE<span class="hl opt">)</span>
45 <span class="hl kwa">set</span><span class="hl opt">(</span>QT_DONT_USE_QTGUI TRUE<span class="hl opt">)</span>
46 <span class="hl kwa">include</span><span class="hl opt">(</span><span class="hl kwd">${QT_USE_FILE}</span><span class="hl opt">)</span>
47
48 <span class="hl com"># Include directories</span>
49 <span class="hl kwa">include_directories</span><span class="hl opt">(</span><span class="hl kwd">${eVaf_INCLUDE}<span class="hl opt">)</span>
50
51 <span class="hl com"># Required eVaf libraries</span>
52 <span class="hl kwa">set</span><span class="hl opt">(</span>eVaf_LIBRARIES CommonLib PluginsLib<span class="hl opt">)</span>
53
54 <span class="hl com"># Source files</span>
55 <span class="hl kwa">set</span><span class="hl opt">(</span>SRCS
56 module.cpp
57 <span class="hl opt">)</span>
58
59 <span class="hl com"># Header files for the Qt meta-object compiler</span>
60 <span class="hl kwa">set</span><span class="hl opt">(</span>MOC_HDRS
61 module.h
62 <span class="hl opt">)</span>
63
64 <span class="hl com"># Version info resource file for Windows builds</span>
65 <span class="hl kwa">if</span><span class="hl opt">(</span><span class="hl kwb">WIN32</span><span class="hl opt">)</span>
66 <span class="hl kwa">set</span><span class="hl opt">(</span>SRCS <span class="hl kwd">${SRCS}</span> version.rc<span class="hl opt">)</span>
67 <span class="hl kwa">endif</span><span class="hl opt">(</span><span class="hl kwb">WIN32</span><span class="hl opt">)</span>
68
69 <span class="hl com"># Run the Qt meta-object compiler</span>
70 <span class="hl kwd">qt4_wrap_cpp</span><span class="hl opt">(</span>MOC_SRCS <span class="hl kwd">${MOC_HDRS}</span><span class="hl opt">)</span>
71
72 <span class="hl com"># Compile the module</span>
73 <span class="hl kwa">add_library</span><span class="hl opt">(</span><span class="hl kwd">${TARGET}</span> <span class="hl kwb">SHARED</span> <span class="hl kwd">${SRCS} ${MOC_SRCS}</span><span class="hl opt">)</span>
74
75 <span class="hl com"># Link the module</span>
76 <span class="hl kwa">target_link_libraries</span><span class="hl opt">(</span><span class="hl kwd">${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}</span><span class="hl opt">)</span></pre>
77
78 <p>Open the <tt>CMakeLists.txt</tt> file in the parent directory and add the command to include the <tt>Storage</tt>
79 sub-directory:</p>
80
81 <pre class="hl"><span class="hl com"># src/apps/PswGen/CMakeLists.txt</span>
82 <span class="hl com"># ...</span>
83 <span class="hl kwa">add_subdirectory</span><span class="hl opt">(</span>Storage<span class="hl opt">)</span></pre>
84
85 <h3>Building the module</h3>
86
87 <p>Go to the previously made <tt>build</tt> directory and build the module:</p>
88
89 <pre>evaf $ <code>cd build</code>
90 evaf/build $ <code>make PswStorage</code></pre>
91
92 <p>Check the <tt>bin</tt> directory, which should now contain a new library:</p>
93
94 <pre>evaf/build $ <code>ls bin</code>
95 libCommonLib.so* libPluginsLib.so* libPswGen.so* <b>libPswStorage.so*</b>
96 evaf/build $</pre>
97
98 <p>In the next section <a href="pswgen09.html">09 - GUI Module</a> we write the Graphical User Interface Module.</p>
99
100 </body>
101 </html>