4 ms·
Is there a good way to debug CMake build rules (especially in the presence of add_custom_command and friends)? I've got a case which builds differently in Make
by eslaught 8y ago
Is there a good way to debug CMake build rules (especially in the presence of add_custom_command and friends)? I've got a case which builds differently in Make vs Visual Studio---in VS, dependencies get messed up and some files don't even get built at all (and then the build fails later on because those files are missing). I can't for the life of me figure out how to debug this, it's absolutely infuriating.
- ahartmetz 8y agocmake --trace and --trace-expand maybe. Because a typical build of a sizable project runs order of magnitude 10k lines of CMake script, you can just dump it all and search. Worked pretty well for me a couple of times.
- tom_ 8y agoI've got by with some combination of the following: - message(STATUS ...) or message(FATAL_ERROR ...) for printing stuff out at configure time, e.g. message(STATUS "libcurl found: ${HAVE_LIBCURL}") - cmake -E echo for printing stuff out at build time, e.g. add_custom_command(TARGET lorenz POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "lorenz command line:" COMMAND ${CMAKE_COMMAND} -E echo '$<TARGET_FILE:lorenz>' ${LORENZ_ARGS} VERBATIM) - diagnostic-level MSBuild output for dependency issues - you can configure this in Visual Studio, Tools, Options, Projects and Solutions, I think (it's around there somewhere). You might not expect much from MSBuild debug output, considering how annoying the rest of it is, but it's actually extremely comprehensive, and I've found it useful for figuring out even rather weird stuff. There's quite a lot of it, though, so get a cup of tea A passing familiarity with the MSBuild syntax might be helpful, but I've managed to do mostly without.