targets with parameters

Hello,

I sometimes want to pass parameters to targets.
Example:

set(project_path “/tmp/proj_10122021”)
add_custom_target(ls_project COMMAND ls ${project_path})

I now could run:

make ls_project

and would get the contents of that path.

How would it be possible to extend this target such that this would become possible:

$ make ls_project testcases  --> list testcases
$ make ls_project doc  --> list documentation

Thanks for your feedback!

This is not how make works. This would build the ls_project and either the testcases or doc targets. make dir=documentation ls_project is possible in Make, but CMake does not expose such functionality in its model since none of the other generators support runtime input like this.

Thanks! OK, I probably will need to write a set of shell scripts to help me debug/extend build features. When using CMake with the -P option, is it possible to load the CMake variable settings from a standalone CMake script ?

You can include() a file to load in variable settings at least.