0

suppose Makefile having a phony target like this

.PHONY : run_my_command
-  - - -  - -  -  - - - 
 - - - -  - -  - -  -  - 

we can directly run only this .phony target in Makefile from command line by giving the below command

make -f Makefile run_my_command

I want to do the same thing with CMakeList. How to tell cmake to create a phony target with the name i give?

Note: I dont want to run this phony target everytime i run make. Instead i want to run it manually when required. I know that add_custom_target() will generate phony target and with the help of add_dependency() we can attach the phony target to the target. But my requirement is different. I want to run this phony target manually when required.

deepan muthusamy
  • 321
  • 2
  • 14
  • 2
    Why `add_custom_target` doesn't suit your needs? – arrowd Mar 04 '21 at 06:45
  • 2
    Elaborating arrowd's comment: If you create a target with `add_custom_target` without `ALL` keyword and don't use it as DEPENDS for other target, then this target will be executed if and only if specified in the command line for `make`. – Tsyvarev Mar 04 '21 at 07:58
  • it is working perfectly @Tsyvarev. here is the link for example : https://gist.github.com/baiwfg2/39881ba703e9c74e95366ed422641609 – deepan muthusamy Mar 04 '21 at 13:26

0 Answers0