0Pricing
C++ Academy · Lesson

Targets Linking and Visibility PUBLIC PRIVATE

Define targets, link libraries, and use PUBLIC, PRIVATE, INTERFACE visibility correctly.

Targets are the Unit of Build

Modern CMake centers on targets — executables, libraries, or interface-only sets. Properties attach to targets and propagate via linkage.

Adding Targets

Use add_executable, add_library, or add_library(... INTERFACE).

add_executable(myapp src/main.cpp)
add_library(mylib STATIC src/lib.cpp)
add_library(headers INTERFACE)

All lessons in this course

  1. CMake Project Layout and CMakeLists.txt
  2. Targets Linking and Visibility PUBLIC PRIVATE
  3. Using vcpkg and Conan for Dependencies
  4. Generating IDE Files and Cross-Platform Builds
← Back to C++ Academy