How to compile a program with setuid?

Colleagues, please tell me how to solve my problem - I want the program have set setuid after compilation.

Right now I’m using a very simple CMakeLists.txt:

set (HEADERS ...)
set (SOURCES ...)

add_executable myprog ${HEADERS} ${SOURCES})

Thanks in advance for the advice,

I think it must be down at the installation step.
See the parameter PERMISSIONS of the install() command.

Thank you. I found this in the documentation and did it. Entered PERMISSIONS SETUID.
But this only works when I say make install.

Is it possible to make setuid installed after make?

I don’t think so, but I am still learning CMake, so maybe it is possible…

The question is rather if this is a good thing to do. As a normal user, you cannot set an executable as suid-root, only root user can do this. This might need a password during build and this will fail in a non-interactive shell or the prompt drowns in the output.