diff --git a/Manual.md b/Manual.md
index 622eee3743..66ac89a404 100644
--- a/Manual.md
+++ b/Manual.md
@@ -545,7 +545,9 @@ to execute a `build_style` script must be defined via `$hostmakedepends`.
 The current list of available `build_style` scripts is the following:
 
 - `cmake` For packages that use the CMake build system, configuration arguments
-can be passed in via `configure_args`.
+can be passed in via `configure_args`. The `cmake_builddir` variable may be
+defined to specify the directory for building under `build_wrksrc` instead of
+the default `build`.
 
 - `configure` For packages that use non-GNU configure scripts, at least `--prefix=/usr`
 should be passed in via `configure_args`.
diff --git a/common/build-style/cmake.sh b/common/build-style/cmake.sh
index 30654953dc..503558ad81 100644
--- a/common/build-style/cmake.sh
+++ b/common/build-style/cmake.sh
@@ -2,8 +2,8 @@
 # This helper is for templates using cmake.
 #
 do_configure() {
-	[ ! -d build ] && mkdir build
-	cd build
+	[ ! -d ${cmake_builddir:=build} ] && mkdir -p ${cmake_builddir}
+	cd ${cmake_builddir}
 
 	if [ "$CROSS_BUILD" ]; then
 		cat > cross_${XBPS_CROSS_TRIPLET}.cmake <<_EOF
@@ -32,13 +32,14 @@ _EOF
 
 	configure_args+=" -DCMAKE_INSTALL_SBINDIR=bin"
 
-	cmake ${configure_args} ..
+	cmake ${configure_args} $(echo ${cmake_builddir}|sed \
+		-e 's|[^/]$|/|' -e 's|[^/]*||g' -e 's|/|../|g')
 }
 
 do_build() {
 	: ${make_cmd:=make}
 
-	cd build
+	cd ${cmake_builddir:=build}
 	${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}
 }
 
@@ -46,6 +47,6 @@ do_install() {
 	: ${make_cmd:=make}
 	: ${make_install_target:=install}
 
-	cd build
+	cd ${cmake_builddir:=build}
 	${make_cmd} DESTDIR=${DESTDIR} ${make_install_args} ${make_install_target}
 }