Fixing clang compilation and supporting clang-tidy

- clang.c includes necessary functions to make clang compiler work (tested on teensy 3.1)
- Added support code to generate a compile_commands.json for clang-tidy
  * Updates the symlink whenever cmake or make is called (Unix OSs only)
This commit is contained in:
Jacob Alexander 2016-03-04 00:23:48 -08:00
parent c5aed6cb17
commit 0102d05c86
6 changed files with 117 additions and 8 deletions

View file

@ -1,6 +1,6 @@
###| CMAKE Kiibohd Controller |###
#
# Jacob Alexander 2011-2014
# Jacob Alexander 2011-2016
# Due to this file's usefulness:
#
# Released into the Public Domain
@ -111,6 +111,13 @@ set( COMPILER_SRCS
Lib/delay.c
)
#| Clang needs a few more functions for linking
if ( "${COMPILER}" MATCHES "clang" )
set( COMPILER_SRCS ${COMPILER_SRCS}
Lib/clang.c
)
endif ()
message( STATUS "Compiler Source Files:" )
message( "${COMPILER_SRCS}" )

View file

@ -135,3 +135,23 @@ elseif ( DEFINED TEENSY )
endif()
endif()
###
# Compiler Command Generation
#
#| Generate list of compiler commands for clang-tidy usage
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )
#| Make sure symlink exists (for convenience)
if ( UNIX )
# Make sure symlink is created immediately
execute_process ( COMMAND ln -sfn ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_SOURCE_DIR}/. )
# Also update before each build
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
COMMAND ln -sfn ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_SOURCE_DIR}/.
)
endif ()