- cmake to configure the project. Minimum required version is 3.12 unless cmake presets feature is going to be used requiring at least 3.19
- conan 2.0 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. To use pip you need to install python interpreter. I highly recommend to install a python3-based version and as the result use pip3 in order to avoid unexpected results with conan
To install/upgrade conan within system's python environment for a current linux's user give the command:
$ pip3 install --user conan --upgrade
- A C++ compiler with at least C++23 support
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 default remote known by conan. We need at least conancenter repository available. To check if it already exists run the following command:
$ conan remote list
If required remote is already there you will see output alike:
$ conan remote list
conancenter: https://center.conan.io [Verify SSL: True, Enabled: True]
If it doesn't appear you should install it by running the command:
$ conan remote add conancenter https://center.conan.io
$ git clone [email protected]:dpronin/lmail.git
ℹ️ conan has profiles to predefine options and environment variables in order to not provide them any time within the command line interface. To learn more about conan available actions and parameters consult
conan --help
. Also reach out to the conan documentation
Profile default used below might look like as the following:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=13.2
os=Linux
[buildenv]
CXX=g++
CC=gcc
Suppose, you have prepared Debug mode with conan and got build/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:
$ cd lmail
$ conan install -s build_type=Debug -pr default --build=missing --update -of out/default .
$ source out/default/build/Debug/generators/conanbuild.sh
$ cmake --preset conan-debug
$ cmake --build --preset conan-debug --parallel $(nproc)
$ source out/default/build/Debug/generators/deactivate_conanbuild.sh
-DINSTALL_DEFAULT_CONF=ON
option provided tells to install default configuration file while installing. WARNING: It may rewrite already existing configuration file
-DINSTALL_EMPTY_SCHEMA_DB=ON
option provided tells to install an empty database schema with tables and their relationships. While installing cmake will run the script that would interactively with you configure your enviroment to prepare the system use this database with lmail application installed. WARNING: the script that will be run will ask you whether you like to substitute an old database (if any) by a new one, be careful, you are possible to leave that dangerous step and proceed
To enable building unit and integrational tests, provide an additional parameter -DBUILD_TESTING=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 lmail
binary. In case tests have been enabled and built you will also find lmail_test
binary alongside
To install the application in the system, run:
bash> cmake --install out/default/build/Debug --config Debug
If you need superuser rights, you need to run it under root:
bash> sudo cmake --install out/default/build/Debug --config Debug
The latter depends on what the prefix you specified while configuring the project with cmake, cmake's variable with prefix is -DCMAKE_INSTALL_PREFIX=/path/to/your/installation/directory
. This variable is set with one of the system path by default, but you always can change it what you want it to be
If you don't like bothering youself with selecting a conan configuration you could try to run cmake with the flag specifying to configure conan automatically. It will take your default conan profile and try to apply to the project. To enable this you should run the following command with preliminarily created the build directory:
bash> ...
bash> cmake --preset conan-debug -DGEN_CONAN_BUILD_INFO=ON -DINSTALL_DEFAULT_CONF=ON -DINSTALL_EMPTY_SCHEMA_DB=ON ../
bash> ...
This will try to generate conan and cmake info automatically and configure the project in Debug mode
To configure and build the project in Release mode:
$ cd lmail
$ conan install -s build_type=Debug -pr default --build=missing --update -of out/default .
$ source out/default/build/Debug/generators/conanbuild.sh
$ cmake --preset conan-debug
$ cmake --build --preset conan-debug --parallel $(nproc)
$ source out/default/build/Debug/generators/deactivate_conanbuild.sh
Release version accomplishes better performance results
Gotcha!
If you have any questions do not hesitate to ask me