cmake - version 2

version one of this PR: https://github.com/GarageGames/Torque3D/pull/586
better isolated and using templates