mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
By specifying CODEGEN as an argument to add_custom_command the custom command will be added to a codegen build target. The intent is to provide a convenient way for users to get their generated files without having to build the whole project. This can be helpful for code analysis tools which can be useful for IDEs and CI.
17 lines
546 B
CMake
17 lines
546 B
CMake
add_custom_target(foobar
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/generated.h
|
|
)
|
|
|
|
add_custom_command(
|
|
OUTPUT generated.hpp
|
|
# This test will fail if DEPENDS isn't accounted for in the codegen build graph
|
|
DEPENDS foobar
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/generated.h
|
|
${CMAKE_CURRENT_BINARY_DIR}/generated.hpp
|
|
CODEGEN
|
|
)
|
|
|
|
add_custom_target(hpp_creator ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp)
|