ADTF related CMake

This guide covers how CMake and ADTF play together:

What is CMake?

CMake is a cross-platform, free and open-source software for managing the build process of software using a compiler-independent method. It supports directory hierarchies and applications that depend on multiple libraries. It is used in conjunction with native build environments such as make, Apple's Xcode, and Microsoft Visual Studio. It has minimal dependencies, requiring only a C++ compiler on its own build system. (Wikipedia)
CMakeLists.txt files are used to declare which directories should be included in the CMake process and what to do with the files in the included directories.

CMake basics

Create a new file called CMakeLists.txt in the directory of the source files you want to include in the Visual Studio solution. Now open the file in an editor.

First of all we can store information in variables using following command:

set (EXAMPLE_VARIABLE_NAME example_variable_value)
        

We can then access the value using:

${EXAMPLE_VARIABLE_NAME}
        

If we need empty files (e.g header, source files) we can create them using this CMakeLists.txt. First we want to check whether the files we want to create already exist. If the files do not exist yet, we create them. Note that the path in the if condition has to be absolute. When creating files the path may be relative.

if(NOT EXISTS "PATH/TO/EXAMPLE/HEADER/FILE/example.h")
  file(WRITE example.h)
endif()
if(NOT EXISTS "PATH/TO/EXAMPLE/SOURCE/FILE/example.cpp")
  file(WRITE example.cpp})
endif()
      

Used default CMake macros

Used ADTF CMake macros

Create a Visual Studio solution:

Add your project to the ADTF examples

ADTF comes with several examples in place which are build with CMake. You can find these examples in the folder src/examples/src of the ADTF installation directory. If we use this directory to create a new project folder and add our new CMakeLists.txt file into it, we can tell the existing ADTF example build process about our new project. This approach has the advantage that the CE looks up plugins inside src/examples/bin by default. So you don't have to tell the ADTF Configuration Editor where to look for your newly created Filter, Streaming Source, Streaming Sink. All we have to do is step one folder up in the file system hierarchy and add the add_subdirectory macro to the existing CMakeLists.txt file. CMake will automatically look for a CMakeLists.txt file inside the given folder and process the instructions found in it:

add_subdirectory(PATH/TO/OUR/CMAKELISTS/FILE)
            

Congratulations! Now you know are ready to dive into the ADTF SDK.

Where to go next?

Have a look at My first Filter to learn about the basic ADTF Filter mechanics.