]> vaikene.ee Git - evaf/blobdiff - www/pswgen08.html
Added more tutorial sections.
[evaf] / www / pswgen08.html
diff --git a/www/pswgen08.html b/www/pswgen08.html
new file mode 100644 (file)
index 0000000..761927a
--- /dev/null
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html lang="et" xmlns="http://www.w3.org/1999/xhtml" xml:lang="et">
+
+    <head>
+        <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8" />
+        <title>eVaf Tutorial - 08 - Building Storage Module</title>
+        <meta name="Author" content="Enar Väikene" />
+        <meta name="description" content="eVaf Tutorial" />
+        <meta name="keywords" content="evaf c++ application development framework tutorial password generator" />
+        <link rel="StyleSheet" href="evaf.css" type="text/css" media="all" />
+        <link rel="StyleSheet" href="highlight.css" type="text/css" media="all" />
+    </head>
+
+    <body>
+
+        <h1>eVaf Tutorial</h1>
+
+        <h2>08 - Buiding Storage Module</h2>
+
+        <h3>CMakeLists.txt</h3>
+
+        <p>Copy an existing <tt>CMakeLists.txt</tt> file from the <tt>Generator</tt> module:</p>
+
+        <pre>evaf/src/apps/PswGen/Storage $ <code>cp ../CMakeLists.txt .</code></pre>
+
+        <p>We only need to modify the <tt>TARGET</tt> variable and set <tt>QT_USE_QTSQL</tt> to <tt>TRUE</tt>:</p>
+
+        <pre class="hl"><span class="hl com"># Name of the target</span>
+<span class="hl kwa">set</span><span class="hl opt">(</span>TARGET PswStorage<span class="hl opt">)</span>
+
+<span class="hl com"># Qt modules</span>
+<span class="hl kwa">set</span><span class="hl opt">(</span>QT_USE_QTSQL TRUE<span class="hl opt">)</span></pre>
+
+        <p>Here is the final <tt>CMakeLists.txt</tt> file:</p>
+
+<pre class="hl"><span class="hl com"># src/apps/PswGen/Storage/CMakeLists.txt</span>
+
+<span class="hl com"># Name of the target</span>
+<span class="hl kwa">set</span><span class="hl opt">(</span>TARGET PswStorage<span class="hl opt">)</span>
+
+<span class="hl com"># Qt modules</span>
+<span class="hl kwa">set</span><span class="hl opt">(</span>QT_USE_QTSQL TRUE<span class="hl opt">)</span>
+<span class="hl kwa">set</span><span class="hl opt">(</span>QT_DONT_USE_QTGUI TRUE<span class="hl opt">)</span>
+<span class="hl kwa">include</span><span class="hl opt">(</span><span class="hl kwd">${QT_USE_FILE}</span><span class="hl opt">)</span>
+
+<span class="hl com"># Include directories</span>
+<span class="hl kwa">include_directories</span><span class="hl opt">(</span><span class="hl kwd">${eVaf_INCLUDE}<span class="hl opt">)</span>
+
+<span class="hl com"># Required eVaf libraries</span>
+<span class="hl kwa">set</span><span class="hl opt">(</span>eVaf_LIBRARIES CommonLib PluginsLib<span class="hl opt">)</span>
+
+<span class="hl com"># Source files</span>
+<span class="hl kwa">set</span><span class="hl opt">(</span>SRCS
+    module.cpp
+<span class="hl opt">)</span>
+
+<span class="hl com"># Header files for the Qt meta-object compiler</span>
+<span class="hl kwa">set</span><span class="hl opt">(</span>MOC_HDRS
+    module.h
+<span class="hl opt">)</span>
+
+<span class="hl com"># Version info resource file for Windows builds</span>
+<span class="hl kwa">if</span><span class="hl opt">(</span><span class="hl kwb">WIN32</span><span class="hl opt">)</span>
+    <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>
+<span class="hl kwa">endif</span><span class="hl opt">(</span><span class="hl kwb">WIN32</span><span class="hl opt">)</span>
+
+<span class="hl com"># Run the Qt meta-object compiler</span>
+<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>
+
+<span class="hl com"># Compile the module</span>
+<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>
+
+<span class="hl com"># Link the module</span>
+<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>
+
+        <p>Open the <tt>CMakeLists.txt</tt> file in the parent directory and add the command to include the <tt>Storage</tt>
+        sub-directory:</p>
+
+        <pre class="hl"><span class="hl com"># src/apps/PswGen/CMakeLists.txt</span>
+<span class="hl com"># ...</span>
+<span class="hl kwa">add_subdirectory</span><span class="hl opt">(</span>Storage<span class="hl opt">)</span></pre>
+
+        <h3>Building the module</h3>
+
+        <p>Go to the previously made <tt>build</tt> directory and build the module:</p>
+
+        <pre>evaf $ <code>cd build</code>
+evaf/build $ <code>make PswStorage</code></pre>
+
+        <p>Check the <tt>bin</tt> directory, which should now contain a new library:</p>
+
+        <pre>evaf/build $ <code>ls bin</code>
+libCommonLib.so*  libPluginsLib.so*  libPswGen.so*  <b>libPswStorage.so*</b>
+evaf/build $</pre>
+
+        <p>In the next section <a href="pswgen09.html">09 - GUI Module</a> we write the Graphical User Interface Module.</p>
+
+    </body>
+</html>