How to list specific targets from the command line?

I feel almost stupid to ask about it, but I could not find anything in this ...

Suppose I have a cmake project that contains several targets: libraries, executables, external targets, .... How to list them using the cmake command line interface. I want a list of things that are valid for replacing $target on the following command line.

 cmake . && cmake --build . --target $target 

Lots of bonus points for a solution that uses neither grep, nor find, nor python, nor perl, nor ... - you get the idea.

+7
cmake
source share
1 answer

In makefile generator build environments you can use

 cmake.exe --build . --target help 

And there is a graphical output solution (an example is found here ):

 cmake.exe . --graphviz=test.graph dotty test.graph 

See also Creating dependency graphs with CMake and CMake Graphviz Output Cleaner .

If you don't have dotty installed, you can make the target dependencies visible by including GLOBAL_DEPENDS_DEBUG_MODE in CMakeLists.txt :

 set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1) 

The failure is that you cannot invoke it from the command line. It will always be displayed on stderr when creating the make environment.

References

+9
source share

All Articles