Open ClausKlein opened 3 days ago
Thanks for the PR. As a general comment, unit tests are supposed to be run on the source, not on the installed artefacts and I don't think we should be changing that.
In this case, it is not possible. Consider treating it as an RFC.
The concept used is from Boost
, and the reasons for implementing it this way are discussed. See C++20 modules and Boost.
The current CMakeLists.txt
files are partly too complex and not obvious. In my opinion, they need to be refactored.
Now, the old CI test works without installation, but the fmt c++ module is not usable:
1/1 Test #22: find-package-test ................***Failed 6.65 sec
Internal cmake changing into directory: /Users/clausklein/Workspace/cpp/fmt/build/test/find-package-test
======== CMake output ======
FMT_MODULE: TRUE
FMT_ROOT is: /Users/clausklein/Workspace/cpp/fmt
Configuring done (0.0s)
Generating done (0.0s)
Build files have been written to: /Users/clausklein/Workspace/cpp/fmt/build/test/find-package-test
======== End CMake output ======
Change Dir: '/Users/clausklein/Workspace/cpp/fmt/build/test/find-package-test'
Run Clean Command: /usr/local/bin/ninja clean
[1/1] Cleaning all built files...
Cleaning... 28 files.
Run Build Command(s): /usr/local/bin/ninja
[1/16] Scanning /Users/clausklein/Workspace/cpp/fmt/test/find-package-test/main.cc for CXX dependencies
[2/16] Scanning /Users/clausklein/Workspace/cpp/fmt/test/find-package-test/main.cc for CXX dependencies
[3/16] Generating CXX dyndep file CMakeFiles/library-test.dir/CXX.dd
[4/16] Scanning /Users/clausklein/Workspace/cpp/fmt/test/find-package-test/main.cc for CXX dependencies
[5/16] Generating CXX dyndep file CMakeFiles/header-only-test.dir/CXX.dd
[6/16] Scanning /Users/clausklein/Workspace/cpp/fmt/src/fmt.cc for CXX dependencies
[7/16] Generating CXX dyndep file CMakeFiles/fmt-module.dir/CXX.dd
[8/16] Generating CXX dyndep file CMakeFiles/module-test.dir/CXX.dd
[9/16] Building CXX object CMakeFiles/library-test.dir/main.cc.o
[10/16] Linking CXX executable library-test
[11/16] Building CXX object CMakeFiles/module-test.dir/main.cc.o
[12/16] Building CXX object CMakeFiles/header-only-test.dir/main.cc.o
[13/16] Linking CXX executable header-only-test
[14/16] Building CXX object CMakeFiles/fmt-module.dir/Users/clausklein/Workspace/cpp/fmt/src/fmt.cc.o
[15/16] Linking CXX static library libfmt-module.a
[16/16] Linking CXX executable module-test
FAILED: module-test
: && /usr/local/opt/llvm/bin/clang++ -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/usr/local/opt/llvm/lib/c++ -stdlib=libc++ CMakeFiles/module-test.dir/main.cc.o -o module-test libfmt-module.a && :
Undefined symbols for architecture x86_64:
"fmt::v10::vprint(fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::context>)", referenced from:
_main in main.cc.o
ld: symbol(s) not found for architecture x86_64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 6.65 sec
The following tests FAILED:
22 - find-package-test (Failed)
Errors while running CTest
bash-5.2$
do you have any idea?
I'm not sure what causing the error, the vprint
overload in question is defined here:
BTW what version of clang do you use? On my system (AppleClang 15.0.0.15000309) it doesn't even get to this point failing with
CMake Error in CMakeLists.txt:
The target named "fmt" has C++ sources that may use modules, but the
compiler does not provide a way to discover the import graph dependencies.
See the cmake-cxxmodules(7) manual for details. Use the
CMAKE_CXX_SCAN_FOR_MODULES variable to enable or disable scanning.
Add workarounds to test installed FILE_SET CXX_MODULES
Add C++23 module test if possible
see too https://discourse.cmake.org/t/advice-on-c-20-modules-boost/10641