ccache: support MSVC by using /Z7 via MSVC_DEBUG_INFORMATION_FORMAT #1853
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Attempt to improve support for building with ccache on Windows distros.
CMake uses
/Zi
inCMAKE_<LANG>_FLAGS_DEBUG
by default. Unfortunately, ccache does not support/Zi
. This means building C projects with CMake and Visual Studio is incompatible with ccache by default when using debug configurations.CMake 3.25 introduces CMP0141 which moves the
/Zi
flag out ofCMAKE_<LANG>_FLAGS_DEBUG
into a new, dedicatedMSVC_DEBUG_INFORMATION_FORMAT
target property instead. This property is initialized by the newCMAKE_MSVC_DEBUG_INFORMATION_FORMAT
variable, which still defaults to/Zi
(akaProgramDatabase
) when the compiler supports it (which, for MSVC, it usually does). However, other debug information formats such as/Z7
(akaEmbedded
) which are compatible with ccache are now available to be specified directly in a controlled manner (rather than messing with*_FLAGS
variables).Therefore, this PR adds
find_ccache_and_export_vars
(from #1524) tocompile-windows.sh
, setsCMP0141
toNEW
, andMSVC_DEBUG_INFORMATION_FORMAT
topEmbedded
(/Z7
) (when debug info is requested by the build configuration) to fully opt-into ccache-compatible builds.