run a shell command (ctags) in cmake and make

前端 未结 3 592
我在风中等你
我在风中等你 2020-12-29 07:55

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 referen

3条回答
  •  臣服心动
    2020-12-29 08:40

    New solution:

    I think CMake changed since the previous answer was given.
    Here is the lines I added in my CMakeLists.txt (tested with version 2.8.12):

    # Add "tags" target and make my_project depending on this target.
    set_source_files_properties(tags PROPERTIES GENERATED true)
    add_custom_target(tags
        COMMAND ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
    add_dependencies(my_project tags)
    

    And it works perfectly now!

提交回复
热议问题