From 3681683df71d273a3e86c176cdc78562cbedac3e Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Mon, 3 Apr 2017 19:28:10 -0700 Subject: [PATCH] cmake: Add simple recursive ctags target for Ceph source only Excludes submodules and random JavaScript. Signed-off-by: Dan Mick Signed-off-by: Kefu Chai --- CMakeLists.txt | 1 + cmake/modules/CTags.cmake | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 cmake/modules/CTags.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d3c11e2290..044d868e978 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -613,3 +613,4 @@ if(WITH_SYSTEMD) add_subdirectory(systemd) endif() +include(CTags) diff --git a/cmake/modules/CTags.cmake b/cmake/modules/CTags.cmake new file mode 100644 index 00000000000..7b0d9d0a9ea --- /dev/null +++ b/cmake/modules/CTags.cmake @@ -0,0 +1,27 @@ +find_program(CTAGS_EXECUTABLE ctags) +if(CTAGS_EXECUTABLE) + set(src_dir "src") + set(tag_file ${src_dir}/tags) + execute_process( + COMMAND git config --file .gitmodules --get-regexp path + COMMAND awk "/${src_dir}/ { print $2 }" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE submodules + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REPLACE "\n" " " submodules ${submodules}) + string(REPLACE "${src_dir}/" "--exclude=" excludes ${submodules}) + # cmake will quote any embedded spaces when expanding ${excludes} + # in the command below, so, turn ${excludes} into a cmake List (separated + # by semicolons) to let the expansion below simply replace them with spaces + # again. + separate_arguments(excludes UNIX_COMMAND ${excludes}) + add_custom_target(ctags + COMMAND ${CTAGS_EXECUTABLE} -R --c++-kinds=+p --fields=+iaS --extra=+q --exclude=*.js ${excludes} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${src_dir} + COMMENT "Building ctags file ${tag_file} (no submodules)" + VERBATIM) + add_custom_target(tags + DEPENDS ctags) + set_source_files_properties(${CMAKE_SOURCE_DIR}/${tag_file} PROPERTIES + GENERATED true) +endif(CTAGS_EXECUTABLE) -- 2.39.5