It is possible to do this by specifying your package as "all" architectures and using post-install and pre-remove scripts (not pre-install). But this is a very bad idea. It undermines a lot of what .deb files are intended to be.
You will need to make your .deb file dependent on the compiler (gcc?) as well as the development package for any libraries your code depends on, not just the library themselves.
You will need to create a post-install script to compile the code, and put the binaries in the right places. You will need to create a pre-remove script to delete all the installed binaries when the package is deleted.
Even after that, you will be left with a package that doesn't correctly inform the dpkg installer where all the binaries are. It will not be able to detect collisions between your package and others.
This is a really bad idea, I strongly suggest you don't do it.