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`

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.