Member-only story
I’ve been stalking StackOverflow lately, answering questions and commenting. Recently, a question on using modules appeared without many responses. This gave me the impetus to dig into modules, at least a little, which is something I’ve meant to do.
My environment is CLion, GCC 14.2, and CMake 28.3, the earliest version of CMake that supports modules.
I wanted to explore beyond simple main and module source file examples while using CLion with CMake. I also wanted to understand how to manage modules in a large project with many directories and files.
Module Terminology
As a starting point, here are some terminology and comments.
A Translation Unit (TU) is just a standard C++ source file. Technically, all of these are TUs.
A Module Interface Unit (MIU) declares the module and its exported entities. It is equivalent to a header file (.h or .hpp) in traditional C++. The file extensions sometimes used to distinguish these are .cppm or .ixx, but this is a convention, not a requirement of the compilers. Any file extension may be used.
I don’t like using a unique file extension. My technique uses the camel-case class name MyClass in headers declaring classes: MyClass.h. I will do the same for MIUs: MyModule.cpp. This allows the use of the lowercase version for Module Implementation Units.