I feel almost silly for asking this but I couldn\'t find anything on this...
Suppose I have a cmake project containing a number of targets: libraries, executables, exter
We may get all targets of the generated Makefile, as @Florian and @Olivia Stork answered.
However, people may just looking for explicitly declared targets in CMakeLists.txt . Targets like "all" and "clean" may not be what people is interested in.
Thus, they can simply query "Built target" in the output of make.
i.e.
cd ~/work/my_project
mkdir build && cd build && cmake ..
make -j4 > log.txt 2>&1
grep 'Built target' log.txt | awk '{print $4}'