很抱歉后来的回答,但工作很疯狂。所以在我阅读了@Th.Thielemann 和@squareskittles 的评论后,我重新阅读了 cmake 文档并找到了我的解决方案。下面的代码是cmake/3.0.0
很久以前写的:
add_custom_command(
OUTPUT some_header.h
COMMAND cat ${BISON_HEADER} other_header.h | awk -f some_wak_file.awk > some_header.h
DEPENDS ${BISON_HEADER}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(
custom_command
ALL
DEPENDS some_header.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "[INFO] CMake generating special *.h file from custom command magic."
)
在再次阅读文档后,cmake/3.13
很明显它可以以更简单的形式编写:
add_custom_target(
timex_utilities_hash
ALL
COMMAND cat ${BISON_HEADER} other_header.h | awk -f some_wak_file.awk > some_header.h
DEPENDS ${BISON_HEADER}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
再次感谢@Th。Thielemann 和@squareskittles 让患者和 inut 再次检查!