add target for python script


It might be weird, but I happen to need to add a target to a project that is not a C program with main, but a script python.

I’m looking for something like add_executable(), but for my custom command.
Something similar to

    COMMAND python

where the command will not be called during the build, but during the execution of the target


CMake does not have an abstraction for executables that are not compiled as CMake targets. This includes shell scripts and the like. You might be able to (ab)use IMPORTED targets for this, though this generally requires that a single string be enough (i.e., no interpreter needed).

1 Like