Skip to content

Compilation and installation options

Yun Wu edited this page Aug 26, 2020 · 2 revisions

Custom installation directory

By default, the make install command will install the library globally in your system (/usr/lib for example).

You can change that location by using a dedicated cmake option:

cmake -DCMAKE_INSTALL_PREFIX=/destination/path ..

Enable logging

By default, all lines of code related to logging are suppressed at the preprocessing step.

This is done to provide higher performance by avoiding the execution of unnecessary lines of code related to logging even though no logger has been configured.

If you wish to enable logging, you have to disable that default behavior by setting the CMake variable LOGGING_ENABLED.

# Enable logging
cmake .. -DLOGGING_ENABLED=1

Custom socket read size

# Change the read size used to read data from sockets (default value: 4096)
cmake .. -DREAD_SIZE=4096

Custom number of io_service workers

The io_service is multithreaded: multiple workers are in charged of IO operations and call the underlying read and write callbacks.

You can configure the number of workers assigned to the io_service by setting the IO_SERVICE_NB_WORKERS CMake variable.

# Change the default number of io_service workers (default value: 1)
cmake .. -DIO_SERVICE_NB_WORKERS=1

To learn more about tacopie io_service, please refer to the dedicated wiki page.

Windows Runtime Library configuration

By default, cpp_redis is compiled using the /MT Runtime Library configuration.

You can use the MSVC_RUNTIME_LIBRARY_CONFIG Cmake variable to override this setting and choose the Runtime Library of your choice (/MT, /MD, ...).

cmake .. -DMSVC_RUNTIME_LIBRARY_CONFIG=/MD

Building tests

cmake .. -DBUILD_TESTS=true

Building examples

cmake .. -DBUILD_EXAMPLES=true

Use your custom TCP client instead of tacopie

cmake .. -DUSE_CUSTOM_TCP_CLIENT=true

Please refer to Custom Network Module wiki page for more information about how to use your own TCP client library in place of tacopie.

Configure tacopie select timeout

By default, select() timeout is set to NULL (unlimited timeout) in the implementation of the tacopie io_service, meaning that select will sleep indefinitely until a notification is received.

If this behavior is not desirable, you can configure the select() timeout at runtime by using the CMake variable SELECT_TIMEOUT and setting it with a micro-seconds duration.

Of course, this configuration only makes sense if you are using tacopie as the networking library (or any other libraries supporting the SELECT_TIMEOUT define).

# Configure select timeout to 1 second
cmake .. -DSELECT_TIMEOUT=1000000L