[PATCH] CMake: enable building the clang-format vs plugin

Hans Wennborg hans at chromium.org
Mon Dec 2 16:30:49 PST 2013


Hi rnk, klimek,

Here's take two on http://llvm-reviews.chandlerc.com/D2248

This patch makes it possible to build the clang-format vs plugin from the cmake build. It is a hack, because it shells out to "devenv" to actually built it, but it's hidden away in a corner behind a flag, and it provides a convenient way of building the plug-in from the command-line together with the rest of clang.

What do you think?

http://llvm-reviews.chandlerc.com/D2310

Files:
  tools/CMakeLists.txt
  tools/clang-format-vs/CMakeLists.txt
  tools/clang-format-vs/README.txt

Index: tools/CMakeLists.txt
===================================================================
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -2,6 +2,7 @@
 add_subdirectory(driver)
 if(CLANG_ENABLE_REWRITER)
   add_subdirectory(clang-format)
+  add_subdirectory(clang-format-vs)
 endif()
 
 if(CLANG_ENABLE_ARCMT)
Index: tools/clang-format-vs/CMakeLists.txt
===================================================================
--- /dev/null
+++ tools/clang-format-vs/CMakeLists.txt
@@ -0,0 +1,16 @@
+option(BUILD_CLANG_FORMAT_VS_PLUGIN "Build clang-format VS plugin" OFF)
+if (BUILD_CLANG_FORMAT_VS_PLUGIN)
+  add_custom_target(clang_format_exe_for_vsix
+      ${CMAKE_COMMAND} -E copy_if_different
+      "${LLVM_TOOLS_BINARY_DIR}/clang-format.exe"
+      "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/clang-format.exe"
+      DEPENDS clang-format)
+
+  add_custom_target(clang_format_vsix ALL
+      devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release
+      DEPENDS clang_format_exe_for_vsix
+      COMMAND ${CMAKE_COMMAND} -E copy_if_different
+      "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
+      "${LLVM_TOOLS_BINARY_DIR}/ClangFormat.vsix"
+      DEPENDS clang_format_exe_for_vsix)
+endif()
Index: tools/clang-format-vs/README.txt
===================================================================
--- tools/clang-format-vs/README.txt
+++ tools/clang-format-vs/README.txt
@@ -8,3 +8,6 @@
 
 clang-format.exe must be copied into the ClangFormat/ directory before building.
 It will be bundled into the .vsix file.
+
+The extension can be built manually from ClangFormat.sln (e.g. by opening it in
+Visual Studio), or with cmake by setting the BUILD_CLANG_FORMAT_VS_PLUGIN flag.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2310.1.patch
Type: text/x-patch
Size: 1738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131202/f01d011d/attachment.bin>


More information about the cfe-commits mailing list