CMake: enable building the clang-format vs plugin

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

llvm-svn: 196299
This commit is contained in:
Hans Wennborg 2013-12-03 18:02:51 +00:00
parent c6b26f0545
commit d6f21bdf58
3 changed files with 20 additions and 0 deletions

View 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)

View File

@ -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()

View File

@ -8,3 +8,6 @@ Build prerequisites are:
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.