# How to control the location of the c++20 Binary Module Interface (BMI) output directory?

**URL:** https://discourse.cmake.org/t/how-to-control-the-location-of-the-c-20-binary-module-interface-bmi-output-directory/7968
**Category:** Usage
**Created:** [April 24, 2023, 3:49pm UTC](https://discourse.cmake.org/t/how-to-control-the-location-of-the-c-20-binary-module-interface-bmi-output-directory/7968 "2023-04-24T15:49:46Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![danakj](https://discourse.cmake.org/user_avatar/discourse.cmake.org/danakj/32/4098_2.png) [@danakj](https://discourse.cmake.org/u/danakj)
#### Post date: [December 19, 2023, 8:36pm UTC](https://discourse.cmake.org/t/how-to-control-the-location-of-the-c-20-binary-module-interface-bmi-output-directory/7968/13 "2023-12-19T20:36:27Z")

</div>

Hi, I am here after a lot of scouring the internet due to my own clang tool failing when CMake updated to 3.28. The root of the issue is related to the `@foo.modmap` files as discussed here, but I think the reasons discussed so far miss the cause.

[Nibble Stew: The road to hell is paved with good intentions and C++ modules](https://nibblestew.blogspot.com/2023/10/the-road-to-hell-is-paved-with-good.html?lr=1) explains (the author is not a fan, but please don’t focus on that here) what is going on during compilation with CMake now and what the `@foo.modmap` files are. I could not find any other docs that explained it.

The problem then is that CMake generates a @foo.modmap file _during compilation_ for each .cc file that it builds. The file is not created as a result of configure, and it’s not left behind after compilation, only the .obj file is left behind.

So when I run a clang tool against the command line specified in compile\_commands.json, it fails due to the `@foo.modmap` file not existing. AFAICT the command that CMake writes into the compile\_commands.json is incorrect, since it’s pointing to a file (the modmap file) which does not actually exist (outside of cmake doing compilation which is not what compile\_commands.json is for).

This renders the compile\_commands.json broken, and requires tools to strip out the `@foo.modmap` argument in order to run the clang tool against the command line arguments in the compile\_commands.json file. This will work until code actually uses modules at which point it will fall over again, as the root issue is unresolved: that the command line in the compile\_commands.json file as generated by CMake is not able to independently reproduce the compilation step.

FTR, I am using CMake 3.28.1, and this issue occurs on Windows and Linux, targeting Clang and MSVC. If CMake is wedded to the idea of using a modmap file during compilation, it needs to write them all to disk at the same time that it generates the compile\_commands.json.

My debugging FWIW: [Subdoc fails with missing modmap files · Issue #437 · chromium/subspace · GitHub](https://github.com/chromium/subspace/issues/437)

---

_[View the full topic](https://discourse.cmake.org/t/how-to-control-the-location-of-the-c-20-binary-module-interface-bmi-output-directory/7968)._
