Added check of BUILD variable in CMakeLists.txt