Updated to use CMake's improved target commands.
Fix for non-Windows builds.
Fixes for OSX builds.
Fix for compiler error on MSVC.