CMake: Advanced Topics (2024-07-01)

Day 1

Basics

From CMake: Introduction

../../../../_images/hello-graph.png

Cross Development

Day 2

Exercise: Build It!

Add CMake build to existing source code in https://github.com/jfasch/2024-07-01/tree/main/exercises/straightforward

../../../../_images/exercise-1.png

Dependencies, Dependencies, Properties, …

The CMake Language

From The Language

Day 3

Morning Awakening

External Dependencies

From CMake: Advanced Topics

Composite

MQTT

Dependencies in our project

../../../../_images/composite.png ../../../../_images/mqtt.png ../../../../_images/graph-mqtt-sqlite.png

Code Generators

Wrong way to generate code: generate at CMake run time

⟶ triggers unnecessary rebuilds everytime a CMakeLists.txt is changed.

# -----------------------------
# THIS IS NOT THE WAY TO DO IT!
# -----------------------------

execute_process(
  COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config-generator.py
          ${CMAKE_CURRENT_SOURCE_DIR}/2024-07-03.conf
       ${CMAKE_CURRENT_BINARY_DIR}/2024-07-03-do-not-use.cpp
)

add_executable(
  data-logger-deeply-embedded-2024-07-03-do-not-use

  data-logger-deeply-embedded.cpp
  ${CMAKE_CURRENT_BINARY_DIR}/2024-07-03-do-not-use.cpp
)
target_include_directories(data-logger-deeply-embedded-2024-07-03-do-not-use PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(data-logger-deeply-embedded-2024-07-03-do-not-use data-logger-lib base-lib)

See https://github.com/jfasch/2024-07-01/blob/main/exercises/1/firmware/CMakeLists.txt

Unit Tests