r/cpp • • Mar 29 '25

CMake 4.0.0 released

265 Upvotes

141 comments sorted by

View all comments

Show parent comments

1

u/kronicum Mar 29 '25

The water cooler talk around header units is that there's no intent to support them, in CMake or (AFAIK) other build systems; at least not until changes to the standard are made to better define their semantics.

MSBuild supports them.

What does "to better define their semantics" look like?

5

u/not_a_novel_account cmake dev Mar 29 '25 edited Mar 29 '25

It is quite easy to claim support for header units so long as you leave the problem of figuring out the local preprocessor arguments to somebody else. MSVC also has extremely compatible BMIs which aids their adoption, but that solution doesn't generalize.

These problems are what the CMake support is hung up on: https://gitlab.kitware.com/cmake/cmake/-/issues/25293

And, as mentioned, there's no real push to develop solutions to them. If the standard had taken the approach used by clang modules (basically, no preprocessor state leakage allowed), header units would have been no-more-complicated than named modules.

6

u/GabrielDosReis Mar 29 '25

MSVC also has extremely compatible BMIs which aids their adoption, but that solution doesn't generalize.

Why? I am genuinely interested.

If the standard had taken the approach used by clang modules (basically, no preprocessor state leakage allowed), header units would have been no-more-complicated than named modules.

Wait, what are you talking about? No preprocessor leakage is what the community (and the committee) almost crucified me for. Please, read the records for the whole macro debate and history.

3

u/not_a_novel_account cmake dev Mar 29 '25

Why? I am genuinely interested.

Because the other compilers didn't follow MSVC on this

Please, read the records for the whole macro debate and history.

I wasn't in the room, I can only explain what the consequences for the decision that was made. I'm not saying MS or anyone else in particular is "to blame" for it, only that the result is unlikely to be fully implemented by high-level build systems as is (unless somebody wants throw a lot of money at the problem).

3

u/GabrielDosReis Mar 29 '25 edited Mar 29 '25

Because the other compilers didn't follow MSVC on this

Even with an unstable BMI format, a compiler can still support header units within a project. The stability becomes critical only when distributing or sharing BMIs across projects using different versions of the compilers using incompatible BMI formats. The challenges related to non-stability are the same as for PCHs.

I wasn't in the room, I can only explain what the consequences for the decision that was made. I'm not saying MS or anyone else in particular is "to blame" for it, only that the result is unlikely to be fully implemented by high-level build systems as is.

I was not suggesting you were blaming anyone. I am more like flabbergasted by the various things I am reading, especially concerning macros, as I was in the rooms and the target of various colorful characterizations regarding my suggestion for how to deal with the macro situation.

Start with section 5 of P0947. How would you make include transitional work if you didn't let preprocessor macro state leak? If you look at the actual deployment of Clang modulemaps, most of the time, all macros are specified to leak, which is what header units do.

→ More replies (0)