[cfe-dev] [llvm-dev] Should we stop supporting building with Visual Studio?
Alexandre Ganea via cfe-dev
cfe-dev at lists.llvm.org
Wed Oct 10 08:58:38 PDT 2018
I'm not sure if that was mentioned, but Ninja could potentially be used inside Visual Studio with a Makefile project type .
We're already doing this to compile with Fastbuild inside Visual Studio.
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.
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='FastBuild Debug|x64'" Label="Configuration">
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:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='FastBuild Debug|x64'">
<NMakeBuildCommandLine>ninja -C build_debug</NMakeBuildCommandLine>
<NMakeReBuildCommandLine> ninja -t rebuild -C build_debug</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>ninja -t clean -C build_debug</NMakeCleanCommandLine>
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).
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".
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.
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.
More information about the cfe-dev