I\'m following the instructions in the CMake FAQ entry \"How can I build my MSVC application with a static runtime?\" to centralize selection of the MSVC runtime for a bunch
I took your code and generalized it to work for every existing configuration and not just for Debug/Release/RelWithDebInfo/MinSizeRel.
Also I made it to work with gcc too - check it out here