X-Git-Url: https://vaikene.ee/gitweb/gitweb.cgi?p=evaf;a=blobdiff_plain;f=www%2Fpswgen05.html;fp=www%2Fpswgen05.html;h=bc6b5d6545d1b5d70f1065cce92d414c537efd85;hp=0000000000000000000000000000000000000000;hb=368818c22af812ac35f5ff69423522dbd54d37ed;hpb=3352f7acc232104985807b9f470cb12bcb2b47c2 diff --git a/www/pswgen05.html b/www/pswgen05.html new file mode 100644 index 0000000..bc6b5d6 --- /dev/null +++ b/www/pswgen05.html @@ -0,0 +1,173 @@ + + + +
+ +eVaf uses CMake as its build system and needs a file called CMakeLists.txt + in the src/apps/PswGen/Generator directory. Create the file and start editing it.
+ +We use the TARGET variable to set the name of the module. This makes it easier to re-use the CMakeLists.txt + file in other modules and applications.
+ +set(TARGET PswGen)+ +
Then we include Qt include files and libraries. We also specify, that we do not want to include the QtGui module as this + module does not any classes from the QtGui module. By removing the QtGui module, we remove any graphical libraries as + dependencies for this module and it can be used in headless systems.
+ +set(QT_DONT_USE_QTGUI TRUE) +include(${QT_USE_FILE})+ +
The next line adds the PSWGEN_GENERATOR_LIBRARY definition to the compiler (remember the lib.h file and + the PSWGEN_GENERATOR_EXPORT macro in the igeneraror.h file?): + +
add_definitions(-DPSWGEN_GENERATOR_LIBRARY)+ +
Add all the eVaf include directories to the compiler. The variable eVaf_INCLUDE contains all the eVaf include + directories and is already initialized with proper values when this CMakeLists.txt file is processed.
+ +include_directories(${eVaf_INCLUDE})+ +
Then we initialize a variable with the names of all the eVaf modules that this module needs to be linked with. We only + need to specify the names of libraries without prefixes or suffixes like ".dll" or ".so". These libraries also become dependencies + of this module and will be built whenever we build this module.
+ +set(eVaf_LIBRARIES CommonLib PluginsLib)+ +
Collect all the source files that needs to be compiled:
+ +set(SRCS + module.cpp +)+ +
Collect header files that need to be processed with the Qt meta-object compiler. Any header file that contains + class declarations with the Q_OBJECT keyword and/or signals and slots, needs to be included here. To avoid warnings + during the build, do not include here any other header files.
+ +set(MOC_HDRS + igenerator.h + module.h +)+ +
The following line adds the Windows version info resource file to the list of source files:
+if(WIN32) + set(SRCS ${SRCS} version.rc) +endif(WIN32)+ +
Process specified header files with the Qt meta-object compiler:
+ +qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS})+ +
Put it all together and compile the module:
+ +add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS})+ +
Finally, link the module:
+ +target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES})+ +
And the final CMakeLists.txt file looks the following:
+ +# src/apps/PswGen/Generator/CMakeLists.txt + +# Name of the target +set(TARGET PswGen) + +# Qt modules +set(QT_DONT_USE_QTGUI TRUE) +include(${QT_USE_FILE}) + +# Needed for exporting symbols from this library +add_definitions(-DPSWGEN_GENERATOR_LIBRARY) + +# Include directories +include_directories(${eVaf_INCLUDE}) + +# Required eVaf libraries +set(eVaf_LIBRARIES CommonLib PluginsLib) + +# Source files +set(MOC_HDRS + igenerator.h + module.h +) + +# Header files for the Qt meta-object compiler +set(MOC_HDRS + igenerator.h + module.h +) + +# Version info resource file for Windows builds +if(WIN32) + set(SRCS ${SRCS} version.rc) +endif(WIN32) + +# Run the Qt meta-object compiler +qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) + +# Compile the module +add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) + +# Link the module +target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES})+ +
We also need CMakeLists.txt files in parent directory src/apps/PswGen. + In this file we add the PswGen directory to the list of include directories, which makes it possible to use + +
# src/apps/PswGen/CMakeLists.txt +set(eVaf_INCLUDE ${eVaf_INCLUDE} ${SMAKE_SOURCE_DIR}/src/apps/PswGen) +add_subdirectory(Generator)+ +
Modify the CMakeLists.txt file in the src/apps directory and include the PswGen application:
+ +# src/apps/CMakeLists.txt +# ... +add_subdirectory(PswGen)+ +
Now our module is included in the build system and we can try to compile it. Go to the eVaf root directory and create + a build directory:
+ +evaf $+ +mkdir build
+evaf $cd build
In the build directory, run cmake:
+ +evaf/build $ cmake ..
+
+ If cmake finishes without errors, build the module with the make command:
+ +evaf/build $ make PswGen
+
+ If you get compiler errors during the build, fix them. If the build finishes without errors, check the content of the + bin directory:
+ +evaf/build $ ls bin
+libCommonLib.so* libPluginsLib.so* libPswGen.so*
+evaf/build $
+
+ As you can see, there are three libraries now. The libPswGen.so is our module and others are eVaf libraries + that our module needs in order to be run.
+ +In the next section 06 - Storage Module we write the Storage module. + + +