I have a software that I'm sharing under MIT license. I would like to add some GPL library to accelerate some algorithms. I #ifdef the includes and calls to this library so that my application can be compiled without the GPL code. The include statements to this third party library and references to it in the makefile are still there though. Can I keep the MIT license on my software project or do I need to change it to GPL? How do I need to structure the license of my git repository in this case?
You can license your source code under MIT, since your source code doesn't contain GPL-covered parts.
However, when you compile the software with the GPL component, then the binary as a whole can only be licensed under the GPL with all the obligations that implies, like providing the complete corresponding source code of the binary – including your MIT-licensed parts. There is no fundamental difference between an MIT project including GPL code vs a GPL project including MIT code.