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`

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

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.

What must be changed to compile the a static fmt library, not the fmt module?

It seems to me I have to disable CMAKE_CXX_SCAN_FOR_MODULES globally:

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 only.