美文网首页
cmake add_custom_command使用

cmake add_custom_command使用

作者: 咖喱鸡蛋 | 来源:发表于2020-01-14 20:57 被阅读0次

参考

cmake 宏定义

https://blog.csdn.net/bytxl/article/details/50634868

add_custom_command使用

https://www.jianshu.com/p/e6552ac81a7f

https://blog.csdn.net/qq_38410730/article/details/102797448

https://www.cnblogs.com/JoyPoint/p/11629521.html

set(TEST_FILE "log.txt")

1、方法1

add_custom_command(OUTPUT  ${TEST_FILE}

  COMMAND echo "Generating log.txt file..."

  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_FILE} ${TEST_FILE}

  COMMENT  "This is a test"

)

add_custom_target(Test1 ALL DEPENDS ${TEST_FILE})

2、方法2

add_custom_target(CopyTask

COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/config ${CMAKE_CURRENT_SOURCE_DIR}/etc

COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/log.txt ${CMAKE_CURRENT_SOURCE_DIR}/etc

)

add_custom_command(TARGET Test1

PRE_BUILD

COMMAND echo "executing a fake command"

COMMENT "This command will be executed before building target Test1"

)

相关文章

网友评论

      本文标题:cmake add_custom_command使用

      本文链接:https://www.haomeiwen.com/subject/qttzactx.html