CMP0138: MSVC -ZI debug info versus -GL for IPO/LTCG
Policy CMP0138 was introduced in !7295 (merged) to switch the default Debug information flag from /Zi
to -ZI
for #10189 (closed). Under the policy's NEW behavior, -ZI
is used for debug info, but that conflicts with the -GL
flag used for whole-program optimization (IPO).
Under CMP0138's NEW behavior, the CheckIPOSupported module now reports that IPO is not supported on MSVC due to the -ZI
flag. It's check fails with
cl : Command line error D8016 : '/ZI' and '/GL' command-line options are incompatible
The check runs in the Debug configuration. It could probably be made to pass by switching to the Release configuration, but that would cause projects to enable INTERPROCEDURAL_OPTIMIZATION and then fail to compile in Debug configurations.
This means that projects that want to enable IPO with MSVC now need to use string operations to replace -ZI
with -Zi
in CMAKE_{C,CXX}_FLAGS_{DEBUG,RELWITHDEBINFO}
, which is the exact opposite of the case in #10189 (closed).