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

Louis-Paul CORDIER lp.cordier at dynamixyz.com
Fri Aug 3 05:19:39 EDT 2018


Hi everybody,

I am currently trying to add reproducible MSVC build to my project using 
ducible tool.

ducible can take in optional parameter, a pdb file.

I am using the following command:

   set(DUCIBLE_BINARY "${CMAKE_CURRENT_LIST_DIR}/bin/ducible.exe")
   add_custom_command(TARGET ${MYTARGET}
                      POST_BUILD
                      COMMAND ${DUCIBLE_BINARY} 
\"$<TARGET_FILE:${MYTARGET}>\" \"$<TARGET_PDB_FILE:${MYTARGET}>\"
                      COMMENT "Patching for reproducible build.")

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.

Thank you very much for your help,

Louis-Paul CORDIER


More information about the CMake mailing list