Support for reduced bmi in clang?

Hi! Clang now has support for one phase compilation through -fmodules-reduced-bmi, just like GCC and MSVC does. Is there a way to use this new compiler feature in CMake C++20 modules support? I searched and couldn’t find documentation about that. Thanks!

I might be misunderstanding the full intent here, but adding it to CMAKE_CXX_FLAGS seems to work fine, ie cmake -S <sourcedir> -B <builddir> -DCMAKE_CXX_FLAGS=-fmodules-reduced-bmi.

You can sneak it onto only sources that actually use modules by appending to the undocumented variable CMAKE_CXX_MODULE_MAP_FLAG after the project() call.

string(APPEND CMAKE_CXX_MODULE_MAP_FLAG " -fmodules-reduced-bmi")

But I think the right answer is simple CMAKE_CXX_FLAGS via -D or a CMakePreset at config time

CMake only supports one-phase compilation anyways (.cxx → {.o, .pch} rather than .cxx.pch.o). This sounds like a further enhancement to keep BMI sizes small when doing the former.

Ya it makes the BMI files ~40% smaller from my limited test, so it’s a nice little optimization

Interesting. I wrongly assumed clang only supported two phase compilation. Seeing it was supported from the beginning and CMake only uses one phase, adding the flag seems sufficient. Thank you for the quick answer!