However even if the current configuration is not generating a PDB (for
Release for instance), this generator expression is providing a path,
making the ducible tool to fail because the pdb file does not exists. Is
it a bug? How can I detect using generator expression if a file exists?
I tried to check all _PDB_ properties of the target but they are all
empty by default.
Re: $<TARGET_PDB_FILE:tgt> is not empty even if configuration has no PDB
On Fri, Aug 3, 2018 at 11:31 AM Louis-Paul CORDIER <[hidden email]> 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.