Hi Markus:
Well, the general answer would be no, you cannot change the controller. But if the project just involves crude source and header files (does not involve custom libraries, RTOS, stacks or similar), and you are switching to a MCU from same family, then you could reuse a project by modifying project settings, connection settings and files such as derivative.h and linker file.
But if in your mind is just to have a magic macro definition to switch between devices, that is not possible.
However you can have common sources and control the compilation with #if and #ifdef as usual.
Hope this clarifies a little more your doubts.
Regards!
Jorge Gonzalez