CMake multi-config generators

(Discourse recommended I start a new topic.)

There was a question whether LLVM cmake supports multi-config generators Does LLVM support to be built with "Ninja Multi-Config" CMake Generator? The answer was no, and I can see that CMAKE_BUILD_TYPE is used in many places in the tree.

I might have misunderstood the question, but Visual Studio is a multi-config generator, right? I can do one -G and then choose Debug or Release in the IDE for each build. And the VS Getting Started does not tell us to set CMAKE_BUILD_TYPE Getting Started with the LLVM System using Microsoft Visual Studio — LLVM 18.0.0git documentation . So is it that we can build multiple configs of the main EXEs but at some point will run into a problem? Or will even the main EXEs be affected by CMAKE_BUILD_TYPE? So should that variable be on the -G command?

There is some support for Multi-Config generators. You can build LLVM with Visual Studio or Ninja Multi-Config to some extent.
It is definitely true though, that the Multi-Config support is in a bad shape.
For example lit-testing is inherently broken to some extent, because it uses configure_file to expose things like are assertions enabled? to tests.
configure_file is run once at CMake configuration phase, so it cannot give a right answer for a Multi-Config build (we should use file(GENERATE …) instead).

tl;dr important things like builds work, advanced things like lit tests don’t.

1 Like