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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Louis-Paul CORDIER
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
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: $<TARGET_PDB_FILE:tgt> is not empty even if configuration has no PDB

Nils Gladitz-2
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.

Nils

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake