[llvm] [docs][CMake] Add CMakePreset, improve VS documentation (PR #84760)

Tobias Hieta via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 06:34:52 PDT 2024


================
@@ -119,7 +121,56 @@ These instruction were tested with Visual Studio 2019 and Python 3.9.6:
  Select the last link: ``Source code (zip)`` and unpack the downloaded file using
  Windows Explorer built-in zip support or any other unzip tool.
 
-12. Finally, configure LLVM using CMake:
+12. Open the LLVM folder in Visual Studio or generate a solution via CMake.
+
+  At this point you can select if you want to use the
+  :ref:`native support for CMake<vs_native_cmake>` in Visual Studio or
+  :ref:`generate Visual Studio<gen_vs_cmake>` solution file from CMake.
+  Both integrations are supported in the LLVM project.
+
+.. _vs_native_cmake:
+
+Visual Studio native CMake support
+==================================
+
+Before you can build LLVM with Visual Studio you need to follow the step
+outlined in :ref:`Getting Started<getting_started>`.
+
+Support for native CMake integration was added in Visual Studio 2019, but it has
+been made more robust in 2022. If you are using Visual Studio before 2022, it's
+recommended to generate a Visual Studio solution from CMake instead of using the
+native CMake integration.
+
+If you want to generate a Visual Studio Solution, please refer to the
+chapter below on :ref:generating Visual Studio Solution<gen_vs_cmake>.
+
+To use the native CMake support, launch Visual Studio 2022 and select the option
+Open a Local Folder and open the root llvm-project folder. This will
+automatically launch CMake (have some patience, it can be a bit slow) and
+populate the interface.
+
+LLVM ships with a default CMakePresets.json that is supposed to make it easy to
+get started, but usually you need to modify the settings used. The best way to
+do this is to create a CMakeUserPresets.json in the llvm subfolder and add your
+configuration there. For more information about the Preset system, see
+`Microsoft's documentation <https://learn.microsoft.com/en-us/cpp/build/cmake-presets-json-reference>`_.
----------------
tru wrote:

Huh, this is surprising to me. Note that I haven't really used Visual Studio, but use Visual Studio Code, I was just asked by my team to improve this for the VS users since it was a little bit of a chore.

When I read up on the CMakeSettings.json vs CMakePresets.json, it read to me like CMakeSettings.json was the Microsoft only solution that is only respected in Visual Studio and that upstream CMake added CMakePresets.json to do the same thing, presets also work with the command line `cmake --preset <name>` and they work in Visual Studio Code. So I thought it was a better way forward.

But if the mere presence of the file removes a whole UI bit in Visual Studio that others expect, that seems like a regression for sure (and also a bit dumb?).

I guess the goal I had here was that I got a lot of questions from devs that when they opened the default settings "clang wasn't enabled" and it was not at all obvious to them how to enable it. That's why I thought a default set of settings to build clang was an upgrade to that.

All in all, happy to remove that file if it's supposed to work the way that you described above. But I would love for some more input from someone that understand's the idea behind hiding that UI in VS when using presets think? @dmpots do you know or do you know someone that knows? (sorry I snooped and saw that you where working at Microsoft).

https://github.com/llvm/llvm-project/pull/84760


More information about the llvm-commits mailing list