Files
build-cpp-cmkr/docs/examples/custom-command.md
T
2026-04-14 15:06:53 +02:00

1.8 KiB

layout, title, permalink, parent, nav_order
layout title permalink parent nav_order
default Tests add_custom_command and add_custom_target support /examples/custom-command Examples 12

Tests add_custom_command and add_custom_target support

[project]
name = "custom-command"
description = "Tests add_custom_command and add_custom_target support"

[target.custom-command]
type = "executable"
sources = ["src/main.cpp"]
include-directories = ["${CMAKE_CURRENT_BINARY_DIR}/generated"]

[[target.custom-command.custom-command]]
outputs = ["${CMAKE_CURRENT_BINARY_DIR}/generated/generated.cpp"]
byproducts = ["${CMAKE_CURRENT_BINARY_DIR}/generated/generated.hpp"]
depends = ["cmake/generate_source.cmake"]
command = [
    "${CMAKE_COMMAND}",
    "-DOUTPUT_CPP=${CMAKE_CURRENT_BINARY_DIR}/generated/generated.cpp",
    "-DOUTPUT_HPP=${CMAKE_CURRENT_BINARY_DIR}/generated/generated.hpp",
    "-P",
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/generate_source.cmake",
]
comment = "Generate source files"
verbatim = true

[[target.custom-command.custom-command]]
build-event = "post-build"
command = [
    "${CMAKE_COMMAND}",
    "-E",
    "touch",
    "${CMAKE_CURRENT_BINARY_DIR}/custom-command-post-build.stamp",
]
byproducts = ["${CMAKE_CURRENT_BINARY_DIR}/custom-command-post-build.stamp"]
comment = "Create a post-build stamp file"
verbatim = true

[target.custom-codegen]
type = "custom"
all = true
command = [
    "${CMAKE_COMMAND}",
    "-E",
    "touch",
    "${CMAKE_CURRENT_BINARY_DIR}/custom-target.stamp",
]
byproducts = ["${CMAKE_CURRENT_BINARY_DIR}/custom-target.stamp"]
comment = "Run custom target"
verbatim = true

This page was automatically generated from tests/custom-command/cmake.toml.