Set default target for project(SomePorject NONE) project

Hi!

I am using cmake not to build something, but to generate some Makefile with bunch of tatrgets.
So I do not have any executable, or library, but I have a lot of add_custom_targets with a lot of ifs

It works well for me.

The only thing that I did not manage to, is to set one of the target as “default”, so I can just run make after generating, and get one of my target processed.

Let’s say I have

add_custom_target(target_A)
add_custom_target(target_B)
add_custom_target(target_A1)
add_custom_target(target_A2)
add_dependencies(target_A target_A1)
add_dependencies(target_A target_A2)

And have some commands added to these target.

How can I have target_A being executed when I issue make command after generation?

All solutions I’ve googeled, advises to do use add_library somehow, but I have no real library in my case… What is the solution in this case?

Use option ALL to include any custom target as part of all default target.

1 Like

That worked. Thanks for quick answer

Hi, is it possible to clarify what do yo mean by use option ALL to include any custom target as part of all default target?

Add the ALL argument to add_custom_target(), as per its docs:

add_custom_target(Whatever ALL ...)