[llvm-dev] llvm.natvis should be included when generating LLVM.sln

51 views
Skip to first unread message

<Alexander G. Riccio> via llvm-dev

unread,
Jan 4, 2016, 8:02:40 PM1/4/16
to llvm...@lists.llvm.org
As of Visual Studio 2015, natvis files can be included as part of individual projects, a much better method than manually copying the file to an specific directory in %USERPROFILE%.

I think it should be included in one of the CMakeLists.txt files, does anybody know how I can add it?

Sincerely,
Alexander Riccio
--
"Change the world or go home."

If left to my own devices, I will build more.

<Alexander G. Riccio> via llvm-dev

unread,
Jan 10, 2016, 6:59:19 PM1/10/16
to llvm...@lists.llvm.org
So, I've investigated this a bit more, and I see that adding a debug visualizer to a (simple test) project adds the following text to the vcxproj file:

  <ItemGroup>
    <Natvis Include="..\..\..\..\..\..\..\LLVM\llvm\utils\llvm.natvis" />
  </ItemGroup>

(This was an unrelated test project, hence the many path components)

...right after the main.cpp file:

  <ItemGroup>
    <ClCompile Include="main.cpp" />
  </ItemGroup>

...so that the vcxproj file looks like this:

  <ItemGroup>
    <ClCompile Include="main.cpp" />
  </ItemGroup>
  <ItemGroup>
    <Natvis Include="..\..\..\..\..\..\..\LLVM\llvm\utils\llvm.natvis" />
  </ItemGroup>

My question, then, is how can I get CMake to emit the "<Natvis Include=" element when generating the vcxproj files? Any CMake experts?

If CMake CANNOT yet do this, I'll just file a bug for it.


Sincerely,
Alexander Riccio
--
"Change the world or go home."

If left to my own devices, I will build more.

Zachary Turner via llvm-dev

unread,
Jan 12, 2016, 2:24:27 PM1/12/16
to <Alexander G. Riccio>, llvm...@lists.llvm.org
CMake cannot yet do this.  You will need to change the Visual Studio 2015 generator to support the nativs tag.  I'm not a CMake developer, but a 5 minutes look at the CMake source code suggests this might be very easy.  If you look at cmVisualStudio10TargetGenerator::WriteAllSources(), you'll see that it calls GetLanguage() on the source file, and depending on which language is set, it uses a different tool.  Either ClCompile, MASM, ResourceCompile, etc.  It sounds like all you need to do is add another language type, called Natvis, and put it behind a check on the version of the generator to make sure this language is only recognized when VS Version >= 2015.

If it were me, I would whip up a 10 line patch that did exactly this, post it on the CMake dev list, and see what kind of feedback I got.

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Zachary Turner via llvm-dev

unread,
Jan 12, 2016, 2:25:28 PM1/12/16
to <Alexander G. Riccio>, llvm...@lists.llvm.org
Assuming you did it that way, the way you would trigger this in CMake is to to add the .natvis file just like any other file, and then after you do:

set_source_file_properties(foo.natvis LANGUAGE natvis)

<Alexander G. Riccio> via llvm-dev

unread,
Jan 28, 2016, 2:34:16 AM1/28/16
to Zachary Turner, llvm...@lists.llvm.org
I haven't gotten around to this yet because I have some annoying issue with my installation of git (CMake uses git), but I love the idea of whipping up a 10 line patch, and hope to get around to it soon!

Assuming you did it that way, the way you would trigger this in CMake is to to add the .natvis file just like any other file, and then after you do:

set_source_file_properties(foo.natvis LANGUAGE natvis)

Ahh, this CMake thing is starting to make sense now.

Sincerely,
Alexander Riccio
--
"Change the world or go home."

If left to my own devices, I will build more.

Reply all
Reply to author
Forward
0 new messages