# CMake Error: Output CMakeFiles/fmt.dir/module/fmt.cc.o provides the \`fmt\` module but it is not found in a \`FILE\_SET\` of type \`CXX\_MODULES\`

**URL:** <https://discourse.cmake.org/t/cmake-error-output-cmakefiles-fmt-dir-module-fmt-cc-o-provides-the-fmt-module-but-it-is-not-found-in-a-file-set-of-type-cxx-modules/13269>\
**Category:** Code\
**Created:** [December 27, 2024, 1:15pm UTC](https://discourse.cmake.org/t/cmake-error-output-cmakefiles-fmt-dir-module-fmt-cc-o-provides-the-fmt-module-but-it-is-not-found-in-a-file-set-of-type-cxx-modules/13269 "2024-12-27T13:15:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [December 27, 2024, 1:15pm UTC](https://discourse.cmake.org/t/cmake-error-output-cmakefiles-fmt-dir-module-fmt-cc-o-provides-the-fmt-module-but-it-is-not-found-in-a-file-set-of-type-cxx-modules/13269/1 "2024-12-27T13:15:18Z")

</div>

```auto
FAILED: CMakeFiles/fmt.dir/CXX.dd /Users/runner/work/fmt-module/fmt-module/build/CMakeFiles/fmt.dir/CXXModules.json CMakeFiles/fmt.dir/module/fmt.cc.o.modmap CMakeFiles/fmt.dir/module/format.cc.o.modmap CMakeFiles/fmt.dir/module/os.cc.o.modmap 
/opt/homebrew/bin/cmake -E cmake_ninja_dyndep --tdi=CMakeFiles/fmt.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=CMakeFiles/fmt.dir/CXX.dd @CMakeFiles/fmt.dir/CXX.dd.rsp
CMake Error: Output CMakeFiles/fmt.dir/module/fmt.cc.o provides the `fmt` module but it is not found in a `FILE_SET` of type `CXX_MODULES`

```

see the project [Sync with current fmt repo by ClausKlein · Pull Request #1 · ClausKlein/fmt-module · GitHub](https://github.com/ClausKlein/fmt-module/pull/1)

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [December 29, 2024, 8:54pm UTC](https://discourse.cmake.org/t/cmake-error-output-cmakefiles-fmt-dir-module-fmt-cc-o-provides-the-fmt-module-but-it-is-not-found-in-a-file-set-of-type-cxx-modules/13269/2 "2024-12-29T20:54:57Z")

</div>

Same comment as I just made on your other forum thread. Please post a clear, minimal, self-contained problem with a clear question. Do not expect forum users to go look at your project and debug it for you.

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [December 30, 2024, 1:32am UTC](https://discourse.cmake.org/t/cmake-error-output-cmakefiles-fmt-dir-module-fmt-cc-o-provides-the-fmt-module-but-it-is-not-found-in-a-file-set-of-type-cxx-modules/13269/3 "2024-12-30T01:32:45Z")

</div>

What must be changed to compile the a static [fmt](https://github.com/fmtlib/fmt) library, not the fmt module?

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [December 30, 2024, 11:22pm UTC](https://discourse.cmake.org/t/cmake-error-output-cmakefiles-fmt-dir-module-fmt-cc-o-provides-the-fmt-module-but-it-is-not-found-in-a-file-set-of-type-cxx-modules/13269/4 "2024-12-30T23:22:23Z")

</div>

It seems to me I have to disable `CMAKE_CXX_SCAN_FOR_MODULES` globally:

```cmake
cpmaddpackage(
  NAME fmt
  GITHUB_REPOSITORY fmtlib/fmt
  GIT_TAG 11.1.1
  VERSION 11.1.1
  DOWNLOAD_ONLY YES
)

  file(GLOB_RECURSE _fmt_public_header "${fmt_SOURCE_DIR}/include/fmt/*.h")
  file(GLOB_RECURSE _fmt_all_sources "${fmt_SOURCE_DIR}/src/*.cc")

  add_library(fmt STATIC)
  target_sources(
    fmt PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS ${fmt_SOURCE_DIR}/include FILES ${_fmt_public_header}
  )

  target_compile_features(
    fmt INTERFACE "$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>" "$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>"
  )

  target_compile_options(fmt PUBLIC $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/utf-8>)

  add_library(fmt::fmt ALIAS fmt)
  set_target_properties(fmt PROPERTIES CXX_SCAN_FOR_MODULES OFF)
  target_compile_definitions(fmt PUBLIC ${CPPdefinitions})
  target_sources(fmt PUBLIC ${_fmt_all_sources})

```

or the target property [CXX\_SCAN\_FOR\_MODULES](https://cmake.org/cmake/help/latest/prop_tgt/CXX_SCAN_FOR_MODULES.html#prop_tgt:https://cmake.org/cmake/help/latest/prop_tgt/CXX_SCAN_FOR_MODULES.html#prop_tgt:CXX_SCAN_FOR_MODULES) only.
