diff Lib/CMake/build.cmake @ 428:b5746c43904e

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)
author Jacob Alexander <haata@kiibohd.com>
date Fri, 04 Mar 2016 00:23:48 -0800
parents 39f84a603350
children 1a2fb67b0237
line wrap: on
line diff
--- a/Lib/CMake/build.cmake	Thu Mar 03 20:40:01 2016 -0800
+++ b/Lib/CMake/build.cmake	Fri Mar 04 00:23:48 2016 -0800
@@ -135,3 +135,23 @@
 	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 ()
+