CMake: Advanced Topics (2024-06-11)¶
Day 1¶
Basics¶
From CMake: Introduction
Exercise: Build It!¶
Add CMake build to existing source code in https://github.com/jfasch/2024-06-11/tree/main/exercises/straightforward
Bringing CMake Information Into C/C++¶
Day 2¶
Morning Awakening¶
Someone to show how WSL can be used.
Continue discussion from yesterday: how do I include file from the local directory?
#include "file.h"
#include <file.h>
⟶
target_include_directories(... INTERFACE ...)
More About Dependencies¶
Much More … (Various Kinds Of Dependencies)¶
Demo project: https://github.com/jfasch/2024-06-11/tree/main/livecoding/kinds-of-dependencies
Various kinds of property propagation (
PUBLIC
,PRIVATE
,INTERFACE
)add_library()
variationsSHARED
: b/CMakeLists.txtINTERFACE
: c/CMakeLists.txt
Aggregating static libraries into shared libraries
Static library as position independent code: d/CMakeLists.txt
Shared library depends on static library: b/CMakeLists.txt
The CMake Language¶
From The Language
Exercise
Write a CMake script (see Scripts) that receives as input parameters
A directory name
INPUT_DIR
A filename
OUTPUT_FILE
It reads all directory entries from
INPUT_DIR
, transforms those names into their filename-only part (e.g./a/b/c.txt
->c.txt
), and writes those names toOUTPUT_FILE
Day 3¶
Morning Awakening¶
Recap https://github.com/jfasch/2024-06-11/tree/main/exercises/ausbaufaehig
Create build directory and all that
Graph
Include paths (
make VERBOSE=1
)Remember building a shared library from a subgraph?
The CMake Language, Continued¶
From The Language …
One example of a function …
External Dependencies¶
From CMake: Advanced Topics …