I ran into this exact GLSL issue a few months back. Excuse the plug, but I wrote up my solution here, if you want something that's backwards compatible: https://coaldev.tumblr.com/post/170129777035/preprocessing-glsl-shaders
Since you're using C++, you may have an easier time implementing this.