bash> git clone git@github.com:dpronin/mtfind.git
-
cmake to configure the project. Minimum required version is 3.16
-
conan to download all the dependencies of the application and configure with a certain set of parameters. You can install conan by giving a command to pip:
bash> pip install --user conan
To use pip you need to install python interpreter. I highly recommend to install python3-based versions in order to avoid unexpected results with conan
-
A C++ compiler with C++20, boost-1.78, gtest-1.11, google-benchmark-1.6 support
The package has been successfully tested on compilation with gcc-10.3 (g++ with libstdc++11), llvm-clang-12.0 (clang++ with libc++)
First you need to set conan's remote list to be able to download packages prescribed in the conanfile.py
as requirements (dependencies). You need at least one remote known by conan. We need conancenter repository available. To check if it already exists run the following command:
bash> conan remote list
If required remote is already there you will see output alike:
bash> conan remote list
conancenter: https://center.conan.io [Verify SSL: True]
If one doesn't appear you should set it by running the command:
bash> conan remote add conancenter https://center.conan.io
Since now you're ready to perform conan installation.
WARNING: if you have variables CC or/and CXX set in your environment you need to unset them before executing next commands, otherwise, if conan decides to build a dependency on host the compiler selected from parameters and compiler from CC/CXX may contradict, as the result some cmake configuring processes while bulding dependencies may fail
If you have resolved all the possible issues described above, you can start installation with conan. Below there is installed a conan's environment with making use of gcc-10.3, libstdc++11, architecture x86_64. If something does not correspond to your environment (for example, gcc is a lower version), change it. Installation with gcc-10.3, libstdc++11, x86_64, Debug mode:
bash> cd mtfind
bash> conan install . -if debug/ -s arch=x86_64 -s arch_build=x86_64 -s compiler=gcc -s compiler.version=10.3 -s compiler.libcxx=libstdc++11 -s build_type=Debug --build missing
All the parameters provided to conan are vital. By using them conan determines whether it can download already built binary package from a remote or it must build a dependency up on the host by itself (if --build missing
parameter is passed)
By the time the command has finished you will have got debug
directory in the root of the project
To install prerequisites for Release mode leaving other parameters untouched, use the following command:
bash> conan install . -if release/ -s arch=x86_64 -s arch_build=x86_64 -s compiler=gcc -s compiler.version=10.3 -s compiler.libcxx=libstdc++11 -s build_type=Release --build missing
As just the command has worked out release
directory will appear in the root of the project
You can vary conan's parameters according to your needs. For instance, if you like to build a package with gcc-6.5 provide the -s compiler.version=6.5
leaving all the rest parameters untouched
To learn more about conan available actions and parameters consult conan --help
Suppose, you have prepared Debug mode with conan and got debug
directory.
WARNING: Before configuring make sure you don't have CC/CXX environment variables set, otherwise they may contradict with those having been configured by conan
To configure the project with cmake
run the commands:
bash> cd debug
bash> cmake -DCMAKE_BUILD_TYPE=Debug ../
The project is configured. To built it run:
bash> cmake --build .
To enable building unit and integrational tests, provide an additional parameter -DBUILD_TESTING=OFF
to cmake while configuring
To enable building benchmarks, provide an additional parameter -DENABLE_BENCH=ON
to cmake while configuring
There are more parameters you can provide to cmake
If the compilation's finished successfully, in the directory ${project_root}/debug/bin/
you will find mtfind
binary. In case tests have been enabled and built you will also find mtfind_test
binary alongside
To configure project in Release mode provide -DCMAKE_BUILD_TYPE=Release
instead of -DCMAKE_BUILD_TYPE=Debug
Release version accomplishes better performance results
Run the application with the example given in the task.txt located in the root of the project:
bash> cd ${project_root}/debug/bin/
bash> ./mtfind ../../input.txt "?ad"
3
5 5 bad
6 6 mad
7 6 had
Gotcha!
If you have any questions do not hesitate to ask me