]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Adding support for ctags generation during cmake generation.
authorJacob Alexander <haata@kiibohd.com>
Sat, 28 Jun 2014 20:48:49 +0000 (13:48 -0700)
committerJacob Alexander <haata@kiibohd.com>
Sat, 28 Jun 2014 20:48:49 +0000 (13:48 -0700)
- Added executable detection script
- Build will still work fine if ctags isn't installed

Lib/CMake/FindCtags.cmake [new file with mode: 0644]
Lib/CMake/modules.cmake

diff --git a/Lib/CMake/FindCtags.cmake b/Lib/CMake/FindCtags.cmake
new file mode 100644 (file)
index 0000000..c66f378
--- /dev/null
@@ -0,0 +1,40 @@
+# The module defines the following variables:
+#   CTAGS_EXECUTABLE - path to ctags command line client
+#   CTAGS_FOUND - true if the command line client was found
+#   CTAGS_VERSION_STRING - the version of ctags found (since CMake 2.8.8)
+# Example usage:
+#   find_package( Ctags )
+#   if( CTAGS_FOUND )
+#     message("ctags found: ${CTAGS_EXECUTABLE}")
+#   endif()
+
+find_program( CTAGS_EXECUTABLE
+       NAMES ctags
+       DOC "ctags executable"
+)
+mark_as_advanced( CTAGS_EXECUTABLE )
+
+if( CTAGS_EXECUTABLE )
+       execute_process(COMMAND ${CTAGS_EXECUTABLE} --version
+               OUTPUT_VARIABLE ctags_version
+               ERROR_QUIET
+               OUTPUT_STRIP_TRAILING_WHITESPACE
+       )
+
+       if( ctags_version MATCHES "^Exuberant Ctags [0-9]" )
+               string( REPLACE "Exuberant Ctags " "" CTAGS_VERSION_STRING "${ctags_version}" )
+               string( REGEX REPLACE ",.*$" "" CTAGS_VERSION_STRING ${CTAGS_VERSION_STRING} )
+       endif()
+
+       unset( ctags_version )
+endif()
+
+# Handle the QUIETLY and REQUIRED arguments and set CTAGS_FOUND to TRUE if
+# all listed variables are TRUE
+
+include( FindPackageHandleStandardArgs )
+find_package_handle_standard_args( Ctags
+       REQUIRED_VARS CTAGS_EXECUTABLE
+       VERSION_VAR CTAGS_VERSION_STRING
+)
+
index f39e1c9fc184d996ab1d88ce6c86ac8bf24c0f95..59eedde6d5d16e5c8e61578e923dad374797a2d1 100644 (file)
@@ -7,6 +7,13 @@
 ###
 
 
+###
+# CMake Custom Modules Path
+#
+
+set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/Lib/CMake/" )
+
+
 
 ###
 # Module Overrides (Used in the buildall.bash script)
@@ -237,6 +244,30 @@ ModuleCompatibility( ${DebugModulePath}  ${DebugModuleCompatibility}  )
 # CMake Module Checking
 #
 find_package( Git REQUIRED )
+find_package( Ctags ) # Optional
+
+
+###
+# ctag Generation
+#
+
+if( CTAGS_EXECUTABLE )
+       # Populate list of directories for ctags to parse
+       # NOTE: Doesn't support dots in the folder names...
+       foreach( filename ${SRCS} )
+               string( REGEX REPLACE "/[a-zA-Z0-9_-]+.c$" "" pathglob ${filename} )
+               file( GLOB filenames "${pathglob}/*.c" )
+               set( CTAG_PATHS ${CTAG_PATHS} ${filenames} )
+               file( GLOB filenames "${pathglob}/*.h" )
+               set( CTAG_PATHS ${CTAG_PATHS} ${filenames} )
+       endforeach()
+
+       # Generate the ctags
+       execute_process( COMMAND ctags ${CTAG_PATHS}
+               WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+       )
+endif()
+
 
 
 ###