Symlink Compile_commandsjson in Cmake

1
2
3
4
5
6
7
add_custom_command(TARGET targetname
	COMMENT "Symlinking compile_commands.json for LSP convenience"
	DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json"
	POST_BUILD 
	COMMAND ${CMAKE_COMMAND} -E create_symlink 
	  "${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json"
	  "${PROJECT_SOURCE_DIR}/compile_commands.json")