How to generate cscope.files from CMakeLists.txt

对着背影说爱祢 提交于 2019-12-06 11:29:21

You could also extend Fraser's answer with a configure_file call, so the final file only changes when its content has changed.

file(WRITE
  ${CMAKE_BINARY_DIR}/cscope.files.in
  "${AllFiles}")
configure_file(
  ${CMAKE_BINARY_DIR}/cscope.files.in
  ${CMAKE_BINARY_DIR}/cscope.files
  COPYONLY)

That could help minimize incremental rebuilds if something else (a custom command) depends on the cscope.files output file. The configure_file call will only update the output file if the result is different from its current contents.

You could generate the file every time CMake runs by adding something like the following: (this assumes your current list of files are in 2 variables called SourceFiles and HeaderFiles)

set(AllFiles ${SourceFiles} ${HeaderFiles})
string(REPLACE ";" "\n" AllFiles "${AllFiles}")
file(WRITE ${CMAKE_BINARY_DIR}/cscope.files "${AllFiles}")
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!