在cmake和make中运行shell命令(ctags) [英] run a shell command (ctags) in cmake and make
问题描述
我在vim中编写一个c ++项目。
我想运行一个 ctags
命令( ctags -R --c ++ - kinds = + p --fields = + iaS --extra = + q。
)来生成引用。 >
我认为这样做的方法是使用 add_custom_command
,但我很困惑如何将它集成到CMakeLists.txt。
最基本的方法是:
set_source_files_properties(tags PROPERTIES GENERATED true)
add_custom_command(OUTPUT tags
COMMAND ctags -R --c ++ - kinds = + p --fields = + iaS --extra = q。
WORKING_DIRECTORY $ {CMAKE_SOURCE_DIR})
add_executable(MyProjectOutput tags)
第一行告诉 CMake
将生成标签
。 add_custom_command
是 CMake
将在需要时生成标记
最后,一些目标需要依赖标签
。默认工作目录在构建树中,因此必须将 WORKING_DIRECTORY
设置为源树。这相当于Makefile条目:
标签:
ctags -R --c ++ - kinds = fields = + iaS -extra = + q。
MyProjectOutput:tags
#Whatever here ...
I'm coding a c++ project in vim.
I'd like to run a ctags
command (ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
) to generate references when I run make.
I think the way to do it is to use add_custom_command
but I get confused on how to integrate it into CMakeLists.txt .
The most basic way to do this is:
set_source_files_properties( tags PROPERTIES GENERATED true)
add_custom_command ( OUTPUT tags
COMMAND ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} )
add_executable ( MyProjectOutput tags )
The first line tells CMake
that tags
will be generated. The add_custom_command
is CMake
will generate tags
when needed, and finally, some target needs to depend on tags
. The default working directory is in the build tree, so WORKING_DIRECTORY
must be set to your source tree. This is equivalent a Makefile entry:
tags:
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
MyProjectOutput: tags
# Whatever here...
这篇关于在cmake和make中运行shell命令(ctags)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!