如何从CMakeLists.txt生成cscope.files [英] How to generate cscope.files from CMakeLists.txt
问题描述
我使用CMake来构建我的代码。 CMakeLists.txt包含所有.C或.CPP文件和所有include目录的列表。
I'm using CMake to build my code. CMakeLists.txt contains the list of all the .C or .CPP files and all the include directories.
如何实现CMakeLists.txt,以便我可以有一个 make
选项为我生成cscope.files包含所有.C和.CPP(或.CXX)文件的列表,以及包含目录中的所有.h文件它?
How can I implement CMakeLists.txt so that I can have a make
option that generates cscope.files for me containing the list of all the .C and .CPP (or .CXX) files and also all the .h files from the include directories in it?
例如我应该能够运行 make cscopefiles
,它会为我生成cscope.files。
For e.g. I should be able to run make cscopefiles
and it will generate cscope.files for me.
这样的选项?
推荐答案
您还可以通过configure_file调用扩展Fraser的答案,已变更。
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)
如果别的东西(一个自定义命令)依赖于cscope.files输出文件,这可以帮助最小化增量重建。 configure_file调用只会在输出文件的结果与当前内容不同时更新输出文件。
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.
这篇关于如何从CMakeLists.txt生成cscope.files的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!