CMake helper modules#
CCCL’s cmake/ directory holds the helper modules, script templates, and the vendored
CPM package manager that drive the build. Library CMakeLists.txt files include these
modules to add executables, generate header tests, expand architecture lists, wire install
rules, and fetch dependencies. Each entry covers the module’s purpose and the functions or
macros it provides.
Helper modules#
File |
Purpose |
Key functions / macros |
|---|---|---|
|
Add an executable with standard CCCL configuration, optional CTest registration, metatargets, and clang-tidy. |
|
|
Pull the CCCL libraries into the build as in-tree subprojects via |
(calls |
|
Standardizes project/subproject behavior when included with |
|
|
clang-tidy integration: global, per-subproject, and per-source analysis targets. |
|
|
Build the |
|
|
Expand the special |
|
|
Enable |
(script; no public functions) |
|
Apply common target properties: disable extensions, set and require the C++/CUDA standard, propagate dialect compile features, set output directories. |
|
|
Enforce supported developer-build configuration: require matching |
|
|
Create the dot-path metatarget hierarchy so |
|
|
Generate per-header compilation tests from a template to verify headers are self-contained, plus a link-check executable that catches missing |
|
|
Fetch external and in-tree dependencies via |
|
|
Mark Catch2, CPM, FetchContent, and LLVM cache variables advanced to keep them out of the default cache view. |
(script; |
|
Generate header and CMake-config install rules per project, gated by a |
|
|
Parse |
|
|
Shared utilities: non-fatal process execution, CPM-consumption compile tests, and expected-failure compile tests. |
|
|
Append a compiler flag to a list only if a |
|
|
Vendored CPM.cmake package manager. Used by |
|
Install rule files#
cmake/install/ holds one file per installable project. Each calls
cccl_generate_install_rules() with that project’s header subdirectories and packaging
options.
Adding an executable#
cccl_add_executable() is the entry point most test and example CMakeLists.txt files
use. It calls cccl_configure_target() for standard properties, registers metatargets via
cccl_ensure_metatargets(), and adds a clang-tidy target via cccl_tidy_add_target().
cccl_add_executable(cub.test.device_reduce
SOURCES test_device_reduce.cu
ADD_CTEST
)
ADD_CTEST registers a CTest that runs the executable with no arguments. NO_METATARGETS
and NO_CLANG_TIDY opt out of those integrations. METATARGET_PATH overrides the dot-path
(default: the target name). DIALECT forces a C++ standard for this target.
Architecture-flag expansion is covered in Architecture flags.