When fmt is added as a subdirectory in a C++20 project using CMake 3.28+,
fmt may default FMT_MODULE to ON and add/build fmt::fmt-module, even when
the parent project only consumes fmt::fmt-header-only or fmt::fmt.
In Clang environments where clang++ is available but clang-scan-deps is not
found by CMake, the build generates a command like:
CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND -format=p1689 -- clang++ ...
and fails with:
/bin/sh: 1: CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND: not found
Expected:
fmt should not build the C++20 module target by default for add_subdirectory
consumers that did not request modules, or the Clang native CMake modules path
should require CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS to be found.
Workaround:
set(FMT_MODULE OFF CACHE BOOL "Build fmt module library." FORCE)
before add_subdirectory(fmt).
Caused issues for us when trying to upgrade fmtlib in PyTorch which uses CPP20, but not modules.
The clang containers did not install clang-scan-deps and therefore the compile runs crashed.
From PR: pytorch/pytorch#187691
When fmt is added as a subdirectory in a C++20 project using CMake 3.28+,
fmt may default
FMT_MODULEto ON and add/buildfmt::fmt-module, even whenthe parent project only consumes
fmt::fmt-header-onlyorfmt::fmt.In Clang environments where
clang++is available butclang-scan-depsis notfound by CMake, the build generates a command like:
CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND -format=p1689 -- clang++ ...
and fails with:
/bin/sh: 1: CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND: not found
Expected:
fmt should not build the C++20 module target by default for add_subdirectory
consumers that did not request modules, or the Clang native CMake modules path
should require
CMAKE_CXX_COMPILER_CLANG_SCAN_DEPSto be found.Workaround:
set(FMT_MODULE OFF CACHE BOOL "Build fmt module library." FORCE)
before add_subdirectory(fmt).
Caused issues for us when trying to upgrade fmtlib in PyTorch which uses CPP20, but not modules.
The clang containers did not install clang-scan-deps and therefore the compile runs crashed.
From PR: pytorch/pytorch#187691