How to Run a Basic `add_custom_command` in CMake

百般思念 提交于 2019-12-13 18:32:13

问题


I'm just trying to get a basic CMake example up and running that can run some basic command line commands. I've been researching this for a while and I haven't had any luck. Am I completely using this wrong? Any and all input would be greatly appreciated.

cmake_minimum_required(VERSION 3.0)

add_custom_command(
  OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/test.txt
  COMMAND echo "Hello world"
  COMMENT "This is a comment. But it's not printed during the build?"
)

return() 

Edit: Using:

add_custom_target(run ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test.txt)

does not work either, as has been suggested in other posts.

来源:https://stackoverflow.com/questions/47333826/how-to-run-a-basic-add-custom-command-in-cmake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!