Visual Studio project for clang has no sources


I’m working on LLVM on Windows using the MSVC CMake generator. Most of my time is spent in LLVM itself, which works fine. Each library has a source, headers, and tablegen directory (if there are tablegen files). However, in the Clang libraries, I only have “Object Libraries”, and I can’t access any headers or cpp files from visual studio.

I’m wondering if anybody has encountered this issue before and knows how I might work around it.


Christopher Tetreault

I use MSVC to open the LLVM folder as a cmake project (so I don't
execute cmake with the MSVC generator and open a solution from there),
and I get similarly bad behavior (all the LLVM components show up fine
in the solution explorer, but none of the other projects are there).
As best I can tell, Visual Studio doesn't handle the monorepo layout
nearly as well as it handled the previous directory layout and I've
not found a way to improve the situation. It's frustrating, so if
others have ideas on how to make Clang development on Windows at least
as good as it was before the git transition, that would be
appreciated. FWIW, my CMake configuration settings are:



   I've struggled with the Visual Studio issue for a few months now. I gave up on using the direct CMake support long ago because I don't care to manage the CMake settings .json file and I think that in its current state, Visual Studio still works better with msbuild projects. That said, I think the issue you're seeing is the fact that Visual Studio shows the files directly under the folder you have open only. If you create a CMakeLists.txt file in the folder above the llvm folder that just does add_subdirectory(llvm), I think it ends up working. You may have to tweak it, but it was something silly like that.

   For my issue, I suspect that I am either not passing a required flag, or the build system is broken for MSVC. I seem to recall it working a few months ago.

   Christopher Tetreault

Clang's CMakeLists.txt uses object libraries to only compile each cpp
file once and link the object files into both, a static and dynamic
library (don't know why LLVM doesn't do the same thing). As a result,
the clangXYZ libraries only contain the object files to be linked, but
are compiled by a separate "obj.clangXYZ" target. You find the object
library targets themselves in the "Object Libraries" folder (sibling
of "Clang libraries", "Clang executable", ...). If you expand these
projects, they do contain "Header Files" and "Source Files".



   I see it now, thank you for pointing it out. It might be nice to organize this stuff better (the solution generated by our cmake for llvm overall is a bit of a mess), I think that it would make sense to swap contents of "Clang libraries" and "Object Libraries" as a start. For the time being, I am happy. Thanks for your help!

   Christopher Tetreault