]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: Add simple recursive ctags target for Ceph source only 14334/head
authorDan Mick <dan.mick@redhat.com>
Tue, 4 Apr 2017 02:28:10 +0000 (19:28 -0700)
committerKefu Chai <kchai@redhat.com>
Thu, 6 Apr 2017 05:27:12 +0000 (13:27 +0800)
Excludes submodules and random JavaScript.

Signed-off-by: Dan Mick <dan.mick@redhat.com>
Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt
cmake/modules/CTags.cmake [new file with mode: 0644]

index 2d3c11e2290eb5a532a8e86db39dff9e300ed801..044d868e9781f16d5eb043d652968494410553f2 100644 (file)
@@ -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 (file)
index 0000000..7b0d9d0
--- /dev/null
@@ -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)