ERROR: format.cc.o is of type `CXX_MODULES` but does not provide a module interface unit or partition
It seems to me, the code is a bad mixture between std c++ std code and a c++20 CXX_MODULE?
- How may/shall I import the
fmt modulein my own c++20 modules? - How to install it to be usable with my
cmake export config package?
bash-5.2$ make
Executing workflow step 1 of 5: configure preset "dev"
Preset CMake variables:
CMAKE_BUILD_TYPE="Debug"
CMAKE_CXX_EXTENSIONS="ON"
CMAKE_CXX_FLAGS="-fstack-protector-strong -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wno-implicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast"
CMAKE_CXX_STANDARD="23"
CMAKE_CXX_STANDARD_REQUIRED="ON"
CMAKE_EXPORT_COMPILE_COMMANDS="ON"
CMAKE_INSTALL_PREFIX:PATH="/Users/clausklein/Workspace/cpp/cxx20/fmt-module/stagedir"
CMAKE_PREFIX_PATH:STRING="/Users/clausklein/Workspace/cpp/cxx20/fmt-module/stagedir"
FMT_DEVELOPER_MODE="ON"
-- use ccache
-- The CXX compiler identification is Clang 19.1.4
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/Cellar/llvm/19.1.4/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/local/bin/git (found version "2.47.1")
-- CPM: Adding package [email protected] (11.0.2 at /Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455)
-- The C compiler identification is Clang 19.1.4
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- CPM: Adding package [email protected] (v1.15.2 at /Users/clausklein/.cache/CPM/googletest/63d366a111d035db343a038884a22e44986dcf4d)
-- Module tests to be built:
-- Configuring done (1.9s)
-- Generating done (0.1s)
-- Build files have been written to: /Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev
Executing workflow step 2 of 5: build preset "dev"
[8/17] Generating CXX dyndep file CMakeFiles/fmt.dir/CXX.dd
FAILED: CMakeFiles/fmt.dir/CXX.dd /Users/clausklein/Workspace/cpp/cxx20/fmt-module/build/dev/CMakeFiles/fmt.dir/CXXModules.json CMakeFiles/fmt.dir/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/src/fmt.cc.o.modmap CMakeFiles/fmt.dir/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/src/format.cc.o.modmap CMakeFiles/fmt.dir/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/src/os.cc.o.modmap
/usr/local/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/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/src/format.cc.o is of type `CXX_MODULES` but does not provide a module interface unit or partition
CMake Error: Output CMakeFiles/fmt.dir/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/src/os.cc.o is of type `CXX_MODULES` but does not provide a module interface unit or partition
[9/17] Linking CXX static library lib/libgtest_mainD.a
ninja: build stopped: subcommand failed.
make: *** [all] Error 1
bash-5.2$
If I try to use in in an other project I get this:
bash-5.2$ ninja -C build
ninja: Entering directory `build'
[0/1] Re-running CMake...
-- use ccache
-- CPM: fmt-module: Adding package [email protected] (11.0.2 at /Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455)
-- CPM: Adding package fmt-module@ (develop at /Users/clausklein/.cache/CPM/fmt-module/540a12df97be7d01b82964ac4ce4347c33344eb9)
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/clausklein/Workspace/cpp/cxx20/spllog/build
[12/20] Building CXX object CMakeFiles/spllog_configs.dir/Configs/SplLog.cppm.o
FAILED: CMakeFiles/spllog_configs.dir/Configs/SplLog.cppm.o CMakeFiles/spllog_configs.dir/spllog_configs.pcm
/usr/local/bin/ccache /usr/local/opt/llvm/bin/clang++ -DUSE_MODULES -isystem /Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include -Wall -Wextra -Wpedantic -Wno-error -std=gnu++23 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk -mmacosx-version-min=14.7 -MD -MT CMakeFiles/spllog_configs.dir/Configs/SplLog.cppm.o -MF CMakeFiles/spllog_configs.dir/Configs/SplLog.cppm.o.d @CMakeFiles/spllog_configs.dir/Configs/SplLog.cppm.o.modmap -o CMakeFiles/spllog_configs.dir/Configs/SplLog.cppm.o -c /Users/clausklein/Workspace/cpp/cxx20/spllog/Configs/SplLog.cppm
In file included from /Users/clausklein/Workspace/cpp/cxx20/spllog/Configs/SplLog.cppm:3:
/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include/fmt/color.h:570:13: error: no member named 'copy' in namespace 'std'; did you mean 'bcopy'?
570 | out = std::copy(emphasis.begin(), emphasis.end(), out);
| ^~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/_strings.h:71:7: note: 'bcopy' declared here
71 | void bcopy(const void *, void *, size_t) __POSIX_C_DEPRECATED(200112L);
| ^
In file included from /Users/clausklein/Workspace/cpp/cxx20/spllog/Configs/SplLog.cppm:3:
/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include/fmt/color.h:576:13: error: no member named 'copy' in namespace 'std'; did you mean 'bcopy'?
576 | out = std::copy(foreground.begin(), foreground.end(), out);
| ^~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/_strings.h:71:7: note: 'bcopy' declared here
71 | void bcopy(const void *, void *, size_t) __POSIX_C_DEPRECATED(200112L);
| ^
In file included from /Users/clausklein/Workspace/cpp/cxx20/spllog/Configs/SplLog.cppm:3:
/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include/fmt/color.h:582:13: error: no member named 'copy' in namespace 'std'; did you mean 'bcopy'?
582 | out = std::copy(background.begin(), background.end(), out);
| ^~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/_strings.h:71:7: note: 'bcopy' declared here
71 | void bcopy(const void *, void *, size_t) __POSIX_C_DEPRECATED(200112L);
| ^
In file included from /Users/clausklein/Workspace/cpp/cxx20/spllog/Configs/SplLog.cppm:3:
/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include/fmt/color.h:587:13: error: no member named 'copy' in namespace 'std'; did you mean 'bcopy'?
587 | out = std::copy(reset_color.begin(), reset_color.end(), out);
| ^~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/include/_strings.h:71:7: note: 'bcopy' declared here
71 | void bcopy(const void *, void *, size_t) __POSIX_C_DEPRECATED(200112L);
| ^
4 errors generated.
[13/20] Building CXX object _deps/fmt-module-build/CMakeFiles/fmt.dir/module/fmt.cppm.o
In file included from /Users/clausklein/.cache/CPM/fmt-module/540a12df97be7d01b82964ac4ce4347c33344eb9/module/fmt.cppm:107:
In file included from /Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include/fmt/args.h:17:
In file included from /Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include/fmt/format.h:41:
/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include/fmt/base.h:17:12: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
17 | # include <stdio.h> // FILE
| ^
In file included from /Users/clausklein/.cache/CPM/fmt-module/540a12df97be7d01b82964ac4ce4347c33344eb9/module/fmt.cppm:107:
In file included from /Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include/fmt/args.h:17:
/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include/fmt/format.h:59:14: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
59 | # include <bit> // std::bit_cast
| ^
In file included from /Users/clausklein/.cache/CPM/fmt-module/540a12df97be7d01b82964ac4ce4347c33344eb9/module/fmt.cppm:113:
/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include/fmt/os.h:20:14: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
20 | # include <xlocale.h> // LC_NUMERIC_MASK on macOS
| ^
/Users/clausklein/.cache/CPM/fmt/cccb77ae9609d2768ed80dd42cec54f77b1f1455/include/fmt/os.h:33:14: warning: '#include <filename>' attaches the declarations to the named module 'fmt', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
33 | # include <fcntl.h> // for O_RDONLY
| ^
4 warnings generated.
ninja: build stopped: subcommand failed.
bash-5.2$
Could you provide a self-contained repro illustrating what you are trying to do and the problem?
Also check out https://vitaut.net/posts/2023/simple-cxx20-modules/.
Could you provide a self-contained repro illustrating what you are trying to do and the problem?
Sure; see https://github.com/ClausKlein/fmt-module/pull/1/commits/47796a61dfa3de8ea39f1c4ac27ed96903c08c9a add https://github.com/fmtlib/fmt/issues/4237
I mean without any external projects, just the minimal code snippet and build commands. We are not going to debug your CMake configs.
See too https://discourse.cmake.org/t/distributing-c-20-modules-as-source/13246/1