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">
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" />
16 <p>Next:
<a href=
"pswgen09.html">09 - GUI Module
</a>, Previous:
<a href=
"pswgen07.html">07 - Storage Module
</a></p>
18 <h1>eVaf Tutorial
</h1>
20 <h2>08 - Buiding Storage Module
</h2>
22 <h3>CMakeLists.txt
</h3>
24 <p>Copy an existing
<tt>CMakeLists.txt
</tt> file from the
<tt>Generator
</tt> module:
</p>
26 <pre>evaf/src/apps/PswGen/Storage $
<code>cp ../Generator/CMakeLists.txt .
</code></pre>
28 <p>We only need to modify the
<tt>TARGET
</tt> variable and set
<tt>QT_USE_QTSQL
</tt> to
<tt>TRUE
</tt>:
</p>
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>
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>
36 <p>Here is the final
<tt>CMakeLists.txt
</tt> file:
</p>
38 <pre class=
"hl"><span class=
"hl com"># src/apps/PswGen/Storage/CMakeLists.txt
</span>
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>
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>
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>
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>
54 <span class=
"hl com"># Source files
</span>
55 <span class=
"hl kwa">set
</span><span class=
"hl opt">(
</span>SRCS
57 <span class=
"hl opt">)
</span>
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
62 <span class=
"hl opt">)
</span>
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>
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>
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>
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>
78 <p>Open the
<tt>CMakeLists.txt
</tt> file in the parent directory and add the command to include the
<tt>Storage
</tt>
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>
85 <h3>Building the module
</h3>
87 <p>Go to the previously made
<tt>build
</tt> directory and build the module:
</p>
89 <pre>evaf $
<code>cd build
</code>
90 evaf/build $
<code>make PswStorage
</code></pre>
92 <p>Check the
<tt>bin
</tt> directory, which should now contain a new library:
</p>
94 <pre>evaf/build $
<code>ls bin
</code>
95 libCommonLib.so* libPluginsLib.so* libPswGen.so*
<b>libPswStorage.so*
</b>
98 <p>In the next section
<a href=
"pswgen09.html">09 - GUI Module
</a> we write the Graphical User Interface Module.
</p>