Use CMake to run a C++ program post-build

筅森魡賤 提交于 2019-12-03 15:47:19

You say you want to run the file after your build. execute_process() runs at CMake-time, not at build time. What you're looking for would be add_custom_command():

add_executable(LicenseStamper stamper.cpp)

add_custom_command(
  OUTPUT stamped_file.lic
  COMMAND LicenseStamper any other arguments
  DEPENDS any/dependency.file
  COMMENT "Stamping the license"
  VERBATIM
)

add_custom_target(
  StampTheLicense ALL
  DEPENDS stamped_file.lic
)

The custom command will run the executable (and build it first, if necessary). The custom target will drive the custom command - it depends on the command's output, so when the target is built, it will require its dependency to be built, causing the custom command to run.

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