I have following problem:
In my cmake project I create for each target custom command, that will write its includes in file.
set(TARGET_INCLUDES $<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>)
set(INCL_FILE "project_includes/${target}_includes.txt")
set( INC_WRITER_FLAGS --include-path ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} ${TARGET_INCLUDES}
--output ${CMAKE_BINARY_DIR}/${INCL_FILE} )
message("!!!!!!!!!!!!! generating rule for ${CMAKE_BINARY_DIR}/${INCL_FILE}")
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/${INCL_FILE}
COMMAND ${Python3_EXECUTABLE} ${INCLUDE_WRITER_PATH} ${INC_WRITER_FLAGS}
VERBATIM)
I see this debug message for each of my targets, so I assume, that it is created. Then for each target I create script that depends on all *_includes.txt of its dependencies.
But in my resulting build.ninja there is no command for creating *_includes.txt for about quarter of my targets and build fails as second script cannot find neither its dependencies nor rules to create them. Currently I have no idea, what targets for those add_custom_command didn’t do anything have in common, maybe someone have idea, under what circumstances can such effect be possible?
Cmake 3.18.5
0
Add custom command is only run if output is used. When output is not used, it is not run.
See add custom target.
2