[CMake] $<TARGET_PDB_FILE:tgt> is not empty even if configuration has no PDB

Nils Gladitz nilsgladitz at gmail.com
Fri Aug 3 06:17:40 EDT 2018


On Fri, Aug 3, 2018 at 11:31 AM Louis-Paul CORDIER <lp.cordier at dynamixyz.com>
wrote:

> How can I detect using generator expression if a file exists?
>

Since there is no first class CMake feature controlling if PDB files are
generated and since CMake does not try to interpret custom compiler flags
projects or users might be setting it doesn't necessarily know which
configurations may or may not generate PDBs.
I.e. a project might add the required compiler flags to generate PDBs in
Release configurations as well.

If you know for your use case that PDBs are generated for all
configurations except Release you could guard expansion of
$<TARGET_PDB_FILE> with something like
$<$<NOT:$<CONFIG:Release>>:$<TARGET_PDB_FILE:...>> (untested) or
alternatively and perhaps cleaner and more flexible you could replace your
direct command invocation with a cmake script wrapper that checks for
existence of files before invoking the actual tool. That way it would also
work when users directly manipulated PDB specific compiler flags.

Nils
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180803/c65381f2/attachment.html>


More information about the CMake mailing list