7.1.1. C/C++ Setup
To set up your environment for C++ development with eCAL, you will need:
A C++ compiler (e.g., GCC, Clang, or MSVC) compatible with C++14 or newer.
CMake (version 3.16 or higher) for project configuration and build management.
An installed eCAL SDK, as described in the general installation instructions.
Optionally, additional libraries such as Protobuf, Cap’n Proto, or FlatBuffers if you plan to use those features.
7.1.1.1. Including eCAL in CMake Projects
For a basic integration, find_package(eCAL REQUIRED)
needs to be called.
CMake locates libraries using the find_package
command, which searches for installed packages and their configuration files.
When installing eCAL via PPA, Debian package, or the Windows installer, the necessary CMake configuration files are placed in standard system locations.
This means that find_package(eCAL REQUIRED)
should work out of the box, and CMake will automatically find eCAL without requiring manual path configuration.
Furthermore, the eCAL::core
target needs to be linked in order to be able to create binary publishers and subscribers.
The CMakeLists.txt
looks as follows:
7.1.1.2. Protobuf entity integration
When using special serialization protocols like Protobuf, a few more steps are necessary for a proper CMake integration.
In addition to the previous example, you will need to call find_package(Protobuf REQUIRED)
.
Furthermore you want to handle the generation of the protobuf headers for your language.
Tip
The PROTOBUF_TARGET_CPP
function is a convenience function from eCAL.
If you have already worked with Protobuf and CMake, you may be more familiar with the following code, which basically does the same thing:
include_directories(${CMAKE_CURRENT_BINARY_DIR})
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${protobuf_files})
add_executable(${PROJECT_NAME} ${source_files} ${PROTO_SRCS} ${PROTO_HDRS})
7.1.1.3. Common CMake targets
Below, please find an overview of the different CMake targets that are available for eCAL.
CMake target |
Description |
---|---|
|
C++ core functionality |
|
C core functionality |
|
C++ |
|
C++ protobuf publisher/subscriber/client/server extension (implicitly links |
|
C++ capnproto publisher/subscriber extension (implicitly links |
|
C++ flatbuffers publisher/subscriber extension (implicitly links |
|
read/write binary eCAL measurements |
|
read/write eCAL measurements with string (implicitly links |
|
read/write eCAL measurements with protobuf (implicitly links |
|
read/write eCAL measurements with capnproto (implicitly links |
|
read/write eCAL measurements with flatbuffers (implicitly links |