cmakeninjabuildconfigurationbuild-target

How do I list all available targets for a project configured for ninja?


I'm looking at a build folder configured using CMake for building with ninja. Naturally, it has a build.ninja file and I can ninja tgt1 in that folder and build target tgt1. But - what I want to do is list all possible targets. How do I do that?


Solution

  • Listing the available targets is in ninja-speak, a "tool" in ninja's arsenal. So, just execute:

    ninja -t targets all
    

    you may want to filter out some of those, since the "targets" here are not the same as your CMake targets. You'll see a lot of what you might call intermediate targets, some auxiliary targets CMake has on the side, as well as "phony" targets if you remember those from the days of yore (=GNU Make). The format is:

    [target name]: [target type]
    

    e.g.

    src/foo/CMakeFiles/install/strip.util: CUSTOM_COMMAND
    src/foo/CMakeFiles/bar.dir/bar.cpp.o: CXX_COMPILER__bar_unscanned_Release
    

    with the former being an auxiliary CMake target rather than relating to any file/target name you've chosen.