<div dir="ltr"><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">On Wed, Oct 10, 2018 at 9:04 AM Alexandre Ganea via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm not sure if that was mentioned, but Ninja could potentially be used inside Visual Studio with a Makefile project type [1].<br>
We're already doing this to compile with Fastbuild inside Visual Studio.<br>
<br>
You generate `cmake -G"Visual Studio 15 2017 Win64" ...` in such way that, in Project Properties / General / Project Defaults, "Configuration Type" would be set to "Makefile" for all generated .vcxproj. <br>
For example:<br>
<br>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='FastBuild Debug|x64'" Label="Configuration"><br>
    <ConfigurationType>Makefile</ConfigurationType><br>
  </PropertyGroup><br>
<br>
Now a "NMake" section replaces all the previous sections in "Project Properties". This is where any batch command(s) can be called for building/rebuild/clean. In this case, we would probably use `ninja -C build_release` for example: <br>
<br>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='FastBuild Debug|x64'"><br>
    <NMakeBuildCommandLine>ninja -C build_debug</NMakeBuildCommandLine><br>
    <NMakeReBuildCommandLine> ninja -t rebuild -C build_debug</NMakeReBuildCommandLine><br>
    <NMakeCleanCommandLine>ninja -t clean -C build_debug</NMakeCleanCommandLine><br>
  </PropertyGroup><br>
<br>
To avoid calling ninja many times for each vcxproj, we also disable the "Build" checkbox in the "Configuration Manager" for all projects but one (say for ALL_BUILD). <br>
<br>
The only quirk I see would be for the NMake batch to first call `cmake -G Ninja" with the parameters initially passed to `cmake -G"Visual Studio 15 2017". <br>
<br>
This overall scheme would retain the different targets in Visual Studio (Debug, Release, RelWithDebInfo, etc.) by passing a different CMAKE_BUILD_TYPE to the above NMake batch file. <br>
<br>
The only thing you're loosing with this is the ability to compile as single .cpp (Ctrl-F7). However, you can get around that by installing the "Clang Power Tools" extension and bind a key for that purpose.<br>
<br>
--------------------<br>
[1] <a href="https://docs.microsoft.com/en-us/cpp/ide/creating-a-makefile-project?view=vs-2017" rel="noreferrer" target="_blank">https://docs.microsoft.com/en-us/cpp/ide/creating-a-makefile-project?view=vs-2017</a> <br></blockquote><div><br></div><div>What benefit would this give us? </div><div><br></div><div>- Michael Spencer </div></div></div>