<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Aug 3, 2018 at 11:31 AM Louis-Paul CORDIER <<a href="mailto:lp.cordier@dynamixyz.com">lp.cordier@dynamixyz.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How can I detect using generator expression if a file exists? <br></blockquote><div><br></div><div>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.</div><div>I.e. a project might add the required compiler flags to generate PDBs in Release configurations as well.</div><div><br></div><div>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.</div><div><br></div><div>Nils<br></div></div></div>