]> vaikene.ee Git - evaf/blob - www/pswgen08.html
Added more information about shared data objects.
[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 <h1>eVaf Tutorial</h1>
17
18 <h2>08 - Buiding Storage Module</h2>
19
20 <h3>CMakeLists.txt</h3>
21
22 <p>Copy an existing <tt>CMakeLists.txt</tt> file from the <tt>Generator</tt> module:</p>
23
24 <pre>evaf/src/apps/PswGen/Storage $ <code>cp ../CMakeLists.txt .</code></pre>
25
26 <p>We only need to modify the <tt>TARGET</tt> variable and set <tt>QT_USE_QTSQL</tt> to <tt>TRUE</tt>:</p>
27
28 <pre class="hl"><span class="hl com"># Name of the target</span>
29 <span class="hl kwa">set</span><span class="hl opt">(</span>TARGET PswStorage<span class="hl opt">)</span>
30
31 <span class="hl com"># Qt modules</span>
32 <span class="hl kwa">set</span><span class="hl opt">(</span>QT_USE_QTSQL TRUE<span class="hl opt">)</span></pre>
33
34 <p>Here is the final <tt>CMakeLists.txt</tt> file:</p>
35
36 <pre class="hl"><span class="hl com"># src/apps/PswGen/Storage/CMakeLists.txt</span>
37
38 <span class="hl com"># Name of the target</span>
39 <span class="hl kwa">set</span><span class="hl opt">(</span>TARGET PswStorage<span class="hl opt">)</span>
40
41 <span class="hl com"># Qt modules</span>
42 <span class="hl kwa">set</span><span class="hl opt">(</span>QT_USE_QTSQL TRUE<span class="hl opt">)</span>
43 <span class="hl kwa">set</span><span class="hl opt">(</span>QT_DONT_USE_QTGUI TRUE<span class="hl opt">)</span>
44 <span class="hl kwa">include</span><span class="hl opt">(</span><span class="hl kwd">${QT_USE_FILE}</span><span class="hl opt">)</span>
45
46 <span class="hl com"># Include directories</span>
47 <span class="hl kwa">include_directories</span><span class="hl opt">(</span><span class="hl kwd">${eVaf_INCLUDE}<span class="hl opt">)</span>
48
49 <span class="hl com"># Required eVaf libraries</span>
50 <span class="hl kwa">set</span><span class="hl opt">(</span>eVaf_LIBRARIES CommonLib PluginsLib<span class="hl opt">)</span>
51
52 <span class="hl com"># Source files</span>
53 <span class="hl kwa">set</span><span class="hl opt">(</span>SRCS
54 module.cpp
55 <span class="hl opt">)</span>
56
57 <span class="hl com"># Header files for the Qt meta-object compiler</span>
58 <span class="hl kwa">set</span><span class="hl opt">(</span>MOC_HDRS
59 module.h
60 <span class="hl opt">)</span>
61
62 <span class="hl com"># Version info resource file for Windows builds</span>
63 <span class="hl kwa">if</span><span class="hl opt">(</span><span class="hl kwb">WIN32</span><span class="hl opt">)</span>
64 <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>
65 <span class="hl kwa">endif</span><span class="hl opt">(</span><span class="hl kwb">WIN32</span><span class="hl opt">)</span>
66
67 <span class="hl com"># Run the Qt meta-object compiler</span>
68 <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>
69
70 <span class="hl com"># Compile the module</span>
71 <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>
72
73 <span class="hl com"># Link the module</span>
74 <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>
75
76 <p>Open the <tt>CMakeLists.txt</tt> file in the parent directory and add the command to include the <tt>Storage</tt>
77 sub-directory:</p>
78
79 <pre class="hl"><span class="hl com"># src/apps/PswGen/CMakeLists.txt</span>
80 <span class="hl com"># ...</span>
81 <span class="hl kwa">add_subdirectory</span><span class="hl opt">(</span>Storage<span class="hl opt">)</span></pre>
82
83 <h3>Building the module</h3>
84
85 <p>Go to the previously made <tt>build</tt> directory and build the module:</p>
86
87 <pre>evaf $ <code>cd build</code>
88 evaf/build $ <code>make PswStorage</code></pre>
89
90 <p>Check the <tt>bin</tt> directory, which should now contain a new library:</p>
91
92 <pre>evaf/build $ <code>ls bin</code>
93 libCommonLib.so* libPluginsLib.so* libPswGen.so* <b>libPswStorage.so*</b>
94 evaf/build $</pre>
95
96 <p>In the next section <a href="pswgen09.html">09 - GUI Module</a> we write the Graphical User Interface Module.</p>
97
98 </body>
99 </html>