Reused functionality implemented in hive!899 (merged) to correctly initialize CMAKE_BUILD_TYPE variable.