# CMake not building module partition that builds with command lines

**URL:** https://discourse.cmake.org/t/cmake-not-building-module-partition-that-builds-with-command-lines/13758
**Category:** Code
**Created:** [March 15, 2025, 9:55pm UTC](https://discourse.cmake.org/t/cmake-not-building-module-partition-that-builds-with-command-lines/13758 "2025-03-15T21:55:19Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![rmerriam](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rmerriam/32/5357_2.png) [@rmerriam](https://discourse.cmake.org/u/rmerriam)
#### Post date: [March 15, 2025, 9:55pm UTC](https://discourse.cmake.org/t/cmake-not-building-module-partition-that-builds-with-command-lines/13758/1 "2025-03-15T21:55:19Z")

</div>

I am encountering this problem with CMake on Ubuntu 24.04, Clang 19, GCC 14 and CLion 2024.3.4. These are examples for talk and book so the partition module needs to be done with an MIU and implementation file. Other non-partition examples build correctly.

```auto
cmake -E cmake_ninja_dyndep --tdi=Javanese/CMakeFiles/javanese.dir/CXXDependInfo.json --lang=CXX --modmapfmt=gcc --dd=Javanese/CMakeFiles/javanese.dir/CXX.dd @Javanese/CMakeFiles/javanese.dir/CXX.dd.rsp
CMake Error: Output Javanese/CMakeFiles/javanese.dir/balinese.cpp.o provides the `Javanese:Balinese` module 
but it is not found in a `FILE_SET` of type `CXX_MODULES`
ninja: build stopped: cannot make progress due to previous errors.

```

The files build correctly with both GCC and Clang using command lines.

Clang build:

```auto
+ clang++ -std=c++23 --precompile Balinese.cppm -o bin/Javanese-Balinese.pcm
+ clang++ -std=c++23 --precompile -fprebuilt-module-path=bin Javanese.cppm -o bin/Javanese.pcm
+ clang++ -std=c++23 -c -fprebuilt-module-path=bin Javanese.cppm -o bin/Javanese.o
+ clang++ -std=c++23 -c -fprebuilt-module-path=bin javanese.cpp -o bin/javanese.o
+ clang++ -std=c++23 -c -fprebuilt-module-path=bin balinese.cpp -o bin/balinese.o
+ clang++ -std=c++23 -r bin/Javanese.o bin/javanese.o bin/balinese.o -o bin/Javanese.Module.o
+ clang++ -std=c++23 -c -fprebuilt-module-path=bin main.cpp -o bin/main.o
+ clang++ -std=c++23 bin/Javanese.Module.o bin/main.o -o bin/main
+ bin/main
Kucing jawa ngomong 'mbelong'
Balinese anak kucing says 'meong'

```

The parent directory CMakeLists.txt

```auto
cmake_minimum_required(VERSION 3.30.5)

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# must appear before project()
set(CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS "/usr/bin/clang-scan-deps")
endif ()

project(pragmatic_modules LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# other subdirectories
add_subdirectory(Javanese)

```

The Javanese CMakeLists.txt

```auto
cmake_minimum_required(VERSION 3.30.5)
project(Javanese LANGUAGES CXX)
set(module_name javanese)

add_executable(${PROJECT_NAME} main.cpp)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)
target_link_libraries(${PROJECT_NAME} ${module_name})

add_library(${module_name})
target_compile_features(${module_name} PUBLIC cxx_std_23)
target_sources(${module_name}
               PUBLIC
               FILE_SET cxx_modules TYPE CXX_MODULES
               FILES
                    Balinese.cppm
                    ${PROJECT_NAME}.cppm
               PRIVATE
                    ${module_name}.cpp
                    balinese.cpp
)

```

The partitions MIU Balinese.cppm

```auto
module;

export module Javanese:Balinese;

namespace Balinese {
   export void meong();
}

```

The implementation file balinese.cpp

```auto
module;

#include <print>

module Javanese:Balinese;

namespace Balinese {
   auto meong() -> void {
      std::println("Balinese anak kucing says 'meong'");
   }
}

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 17, 2025, 8:32am UTC](https://discourse.cmake.org/t/cmake-not-building-module-partition-that-builds-with-command-lines/13758/2 "2025-03-17T08:32:56Z")

</div>

> [@rmerriam](#):
>
> `module Javanese:Balinese;`

Implementation units should _never_ mention partitions. That is a Microsoft non-standard extension. Just remove the partition name from `balinese.cpp`.

---

<div class="post-metadata">

### Author: ![rmerriam](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rmerriam/32/5357_2.png) [@rmerriam](https://discourse.cmake.org/u/rmerriam)
#### Post date: [March 17, 2025, 2:39pm UTC](https://discourse.cmake.org/t/cmake-not-building-module-partition-that-builds-with-command-lines/13758/3 "2025-03-17T14:39:05Z")

</div>

Unfortunately both GCC and Clang accepted the mention of the partition.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 17, 2025, 3:03pm UTC](https://discourse.cmake.org/t/cmake-not-building-module-partition-that-builds-with-command-lines/13758/4 "2025-03-17T15:03:09Z")

</div>

Yes, they’ll _make_ a partition BMI because that’s how one specifies a non-`export`ed partition. It’s why CMake reports that’s a TU that exports a module that isn’t in a `FILE_SET`.

---

<div class="post-metadata">

### Author: ![rmerriam](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rmerriam/32/5357_2.png) [@rmerriam](https://discourse.cmake.org/u/rmerriam)
#### Post date: [March 17, 2025, 3:21pm UTC](https://discourse.cmake.org/t/cmake-not-building-module-partition-that-builds-with-command-lines/13758/5 "2025-03-17T15:21:16Z")

</div>

A “non-exported partition” is something I’ve not seen mentioned elsewhere. Found mention in a search. Glad you mentioned it.

---

<div class="post-metadata">

### Author: ![bill.hoffman](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bill.hoffman/32/13_2.png) [@bill.hoffman](https://discourse.cmake.org/u/bill.hoffman)
#### Post date: [March 19, 2025, 6:37pm UTC](https://discourse.cmake.org/t/cmake-not-building-module-partition-that-builds-with-command-lines/13758/6 "2025-03-19T18:37:50Z")

</div>

> [@rmerriam](#):
>
> ```auto
> if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
> # must appear before project()
> set(CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS "/usr/bin/clang-scan-deps")
> endif ()
> 
> ```

That should not be required. Must be something going wrong here:  
[https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/Compiler/Clang-FindBinUtils.cmake?ref\_type=heads#L50](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/Compiler/Clang-FindBinUtils.cmake?ref_type=heads#L50)

@ben.boeckel

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 19, 2026, 9:53pm UTC](https://discourse.cmake.org/t/cmake-not-building-module-partition-that-builds-with-command-lines/13758/7 "2026-02-19T21:53:33Z")

</div>

Another report had been made here:

> [@Building C++ modules with GCC and Clang for presentatoins](https://discourse.cmake.org/t/building-c-modules-with-gcc-and-clang-for-presentatoins/13601):
>
> I’m working on a presentation about C++ modules using CMake to build them. Here are my two CMakeLists.txt files for GCC which works fine. What changes for Clang? Any improvements on the overall CMake code so it is good for a presentation? Upper level CMakeLists.txt cmake\_minimum\_required(VERSION 3.30) project(pragmatic\_modules) if(CMAKE\_CXX\_COMPILER\_ID STREQUAL "GNU") add\_compile\_options(-std=c++23 -Werror -Wpedantic -Wall -Mmodules ) elseif(CMAKE\_CXX\_COMPILER\_ID STREQUAL…
