Installation
As previously mentioned throughout this documentation, Safe DDS is a C++ library characterized by its strong emphasis on portability. It is important to highlight that Safe DDS has no external dependencies, which significantly simplifies the integration process. Additionally, the library has minimal system requirements, making it suitable for a wide variety of environments.
The installation method described in the following sections targets systems that meet the aforementioned requirements. However, it should be noted that there are alternative possibilities for porting the library to other types of platforms and toolchains, enabling Safe DDS to adapt to various scenarios and meet diverse platform requirements.
Minimum Requirements
In order to successfully build Safe DDS, there are certain minimum requirements that must be fulfilled. These requirements include:
CMake 3.5 or higher, although it should be noted that the build process is not limited to this particular build system and can be accomplished with other alternatives.
A C++11 compliant compiler, ensuring compatibility with the necessary features and standards.
A subset of the C++ standard library, providing essential functionalities for the library’s operation.
Note
It is possible to port Safe DDS to platforms that do not satisfy these requirements; however, the process for doing so falls beyond the scope of this document.
Build and install the library
Note
To obtain a copy of Safe DDS please contact support@eProsima.com
In order to build and install Safe DDS, the standard CMake procedure is employed, as detailed below:
cmake "$SAFEDDS_PATH" \
-B"$BUILD_SAFEDDS_FOLDER" \
-DCMAKE_INSTALL_PREFIX="$INSTALL_SAFEDDS_FOLDER"
cmake --build "$BUILD_SAFEDDS_FOLDER" --target install
Upon completion of the installation process, a libsafedds.a
file and an include
directory can be located within the specified installation directory.
This enables users to seamlessly integrate Safe DDS into their projects by linking the library and including the necessary header files.
Cross-compiling Safe DDS
To cross-compile Safe DDS, the utilization of the standard CMake toolchain method is recommended.
Below a sample of a basic toolchain for building the library targeting the Cortex-M3 architecture can be found:
# Example Safe DDS CMake Toolchain file for Cortex-M3
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
# Set the toolchain path
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
# Set the common ARM Cortex M3 flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-m3 -mthumb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=cortex-m3 -mthumb")
# Ensure that the compiler works
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)
# Set the Safe DDS platform and transport to none
set(SAFEDDS_PLATFORM "none" CACHE STRING "Force no platform" FORCE)
set(SAFEDDS_TRANSPORT "none" CACHE STRING "Force no transport" FORCE)
This example provides a starting point for configuring the toolchain settings to cross-compile Safe DDS for the Cortex-M3 platform. Mind that adjusting the toolchain settings according to the specific platform and requirements may be required.
Once the toolchain file is ready, the library can be cross-compiled by invoking CMake as follows:
cmake "$SAFEDDS_PATH" \
-Bbuild \
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" \
-DCMAKE_INSTALL_PREFIX="$SAFEDDS_INSTALL_FOLDER"
cmake --build build --target install
Override C++ Standard Library
As mentioned in the Portable module section, Safe DDS’ dependency on the C++ standard library is both limited and encapsulated.
To facilitate customization, it is possible to override the contents of the include/portable
folder, allowing for modifications or replacements of any headers found within this directory.
This enables the utilization of a custom C++ standard library or a tailored implementation to suit specific requirements.
To illustrate this process, consider the example of overriding the usage of std::array
.
This can be accomplished by rewriting the file include/portable/Array.hpp
as include_overrides/safedds/portable/Array.hpp
and subsequently incorporating it into the toolchain as follows:
# Add the custom include folder to override library headers
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include_overrides)
By employing this method, it is possible to adapt Safe DDS to utilize alternative C++ standard libraries or bespoken implementations as needed, offering flexibility and versatility for varying project requirements.
CMake options
Safe DDS incorporates a variety of CMake options, which serve to enhance the customization of the build process. The following options are available:
Option |
Description |
Possible values |
Default |
---|---|---|---|
|
Builds unit tests suite |
|
|
|
Builds module tests suite |
|
|
|
Builds system tests suite |
|
|
|
Builds examples |
|
|
|
Builds tests with coverage support |
|
|
|
Builds tests with address sanitizer support |
|
|
|
Adds custom compile options |
|
|
|
Sets the target platform |
|
|
|
Sets the transport to use |
|
|