]> granicus.if.org Git - clang/commitdiff
CMake: enable building the clang-format vs plugin
authorHans Wennborg <hans@hanshq.net>
Tue, 3 Dec 2013 18:02:51 +0000 (18:02 +0000)
committerHans Wennborg <hans@hanshq.net>
Tue, 3 Dec 2013 18:02:51 +0000 (18:02 +0000)
This makes it possible to build the clang-format vs plugin from the cmake build.
It is a hack, as it shells out to "devenv" to actually build 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.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196299 91177308-0d34-0410-b5e6-96231b3b80d8

tools/CMakeLists.txt
tools/clang-format-vs/CMakeLists.txt [new file with mode: 0644]
tools/clang-format-vs/README.txt

index fef0adc621562950eba695f64810236857283229..58be615e85c950da3a98e402a7cd9a120019245f 100644 (file)
@@ -2,6 +2,7 @@ add_subdirectory(diagtool)
 add_subdirectory(driver)
 if(CLANG_ENABLE_REWRITER)
   add_subdirectory(clang-format)
+  add_subdirectory(clang-format-vs)
 endif()
 
 if(CLANG_ENABLE_ARCMT)
diff --git a/tools/clang-format-vs/CMakeLists.txt b/tools/clang-format-vs/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f38213f
--- /dev/null
@@ -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 d74060e19a42750b503fc52f3eecdca6b93832b2..b87df6e92379d6b21ebe1e097430216e7be41cfa 100644 (file)
@@ -8,3 +8,6 @@ Build prerequisites are:
 \r
 clang-format.exe must be copied into the ClangFormat/ directory before building.\r
 It will be bundled into the .vsix file.\r
+\r
+The extension can be built manually from ClangFormat.sln (e.g. by opening it in\r
+Visual Studio), or with cmake by setting the BUILD_CLANG_FORMAT_VS_PLUGIN flag.\r