1option(BUILD_CLANG_FORMAT_VS_PLUGIN "Build clang-format VS plugin" OFF)
2if (BUILD_CLANG_FORMAT_VS_PLUGIN)
3  add_custom_target(clang_format_exe_for_vsix
4      ${CMAKE_COMMAND} -E copy_if_different
5      "${LLVM_TOOLS_BINARY_DIR}/clang-format.exe"
6      "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/clang-format.exe"
7      DEPENDS clang-format)
8
9  add_custom_target(clang_format_license
10      ${CMAKE_COMMAND} -E copy_if_different
11      "${CLANG_SOURCE_DIR}/LICENSE.TXT"
12      "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/license.txt")
13
14  if (NOT CLANG_FORMAT_VS_VERSION)
15    set(CLANG_FORMAT_VS_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
16  endif()
17
18  configure_file("source.extension.vsixmanifest.in"
19      "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest")
20
21  add_custom_target(clang_format_vsix ALL
22      devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release
23      DEPENDS clang_format_exe_for_vsix "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest"
24      COMMAND ${CMAKE_COMMAND} -E copy_if_different
25      "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
26      "${LLVM_TOOLS_BINARY_DIR}/ClangFormat.vsix"
27      DEPENDS clang_format_exe_for_vsix clang_format_license)
28endif()
29