-
Couldn't load subscription status.
- Fork 2.8k
[fix] error: module file CMakeFiles/__cmake_cxx23.dir/std.pcm cannot be loaded due to a configuration mismatch with the current compilation #4279 #4582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…n warnings are generated
…n warnings are generated
…n warnings are generated
…n warnings are generated
…n warnings are generated
…be loaded due to a configuration mismatch with the current compilation fmtlib#4279
…be loaded due to a configuration mismatch with the current compilation fmtlib#4279
|
This looks similar to #4580. In the future please update the PR instead of closing and creating a new one. |
OK, thank you for your suggestion. |
|
Could you provide an example demonstrating the problem? |
It's ok, thank you for checking the code. |
…be loaded due to a configuration mismatch with the current compilation fmtlib#4279#4582
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the logic to set std flag make sense. Please move the other changes to a separate PR and add more context.
| # Decide whether to use CMake's FILE_SET-based module support. We only enable | ||
| # it when the generator and CMake version support it and the compiler is not | ||
| # GCC (GCC lacks import-graph discovery in many setups). This check must run | ||
| # after project() so CMAKE_CXX_COMPILER_ID is available. | ||
| if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND | ||
| CMAKE_GENERATOR STREQUAL "Ninja" AND | ||
| NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||
| set(FMT_USE_CMAKE_MODULES TRUE) | ||
| else() | ||
| set(FMT_USE_CMAKE_MODULES FALSE) | ||
| endif() | ||
| message(STATUS "FMT_USE_CMAKE_MODULES = ${FMT_USE_CMAKE_MODULES}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better not to split the logic to set FMT_USE_CMAKE_MODULES.
[fix] error: module file CMakeFiles/__cmake_cxx23.dir/std.pcm cannot be loaded due to a configuration mismatch with the current compilation #4279
What I changed
The modifications I made (specific and traceable)
Edit file: CMakeLists.txt
In the manual pre-compilation module path (CMake does not use FILE_SET to manage modules), ensure that CMake's automatic module scanning is not triggered - to avoid build failures caused by CMake requiring the compiler to support import-graph scanning.
In scenarios where it is not safe to use CMake's FILE_SET module support (such as GCC + Ninja), FMT_USE_CMAKE_MODULES is disabled, causing the build to revert to manual pre-compilation/non-FILE_SET paths.
In environments where module support cannot be reliably provided (GCC's several versions), if the user requests -DFMT_MODULE=ON, FMT_MODULE will be automatically set back to OFF (and a warning will be printed) to avoid compiler internal errors (cc1plus segment errors) caused by -fmodules-ts.
In the manual module branch as the target, CXX_SCAN_FOR_MODULES (target property) is turned off, and CMAKE_CXX_SCAN_FOR_MODULES (cache) is globally turned off under GCC to ensure CMake no longer attempts to automatically scan.
Add diagnostic output to enable seeing the decision of FMT_USE_CMAKE_MODULES during configure (helpful for subsequent debugging).
(Notes) I did not modify the public API or source code functionality; only adjusted the CMake configuration logic, with minor and low-risk modifications.