Moved some of build.sh to cmake