Moved CMAKE_BUILD_TYPE logic to allow the value to be cached properly.