How do I list the defined make targets from the command line?

后端 未结 3 1253
后悔当初
后悔当初 2021-02-02 06:49

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

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-02 07:44

    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}'
    

提交回复
热议问题