While the existence of a gapped topological \(\mathbb{Z}_2\) spin liquid on the spin-1/2 kagome Heisenberg antiferromagnet (KHAF) is now well established, the discussion of the effect of an interlayer coupling (ILC) by controlled theoretical approaches is still lacking. Here we provide a detailed analysis of this problem by using the coupled-cluster method to high orders of approximation. We consider a stacked KHAF with a perpendicular ILC \(J_\perp\), where we study ferro- as well as antiferromagnetic \(J_\perp\). We find that the spin-liquid ground state (GS) persists until relatively large strengths of the ILC. Only at \(|J^c_\perp| \sim 0.15\) the spin-liquid phase gives way for \(q=0\) magnetic long-range order, where the transition between both phases is continuous and the critical strength of the ILC, \(|J^c_\perp|\), is almost independent of the sign of \(J_\perp\). Thus, by contrast to the quantum GS selection of the strictly two-dimensional KHAF at large spin \(s\), the ILC leads first to a selection of the \(q=0\) GS. Only at larger \(|J_\perp|\) the ILC drives a first-order transition to the \(\sqrt{3}\times\sqrt{3}\) long-range ordered GS. As a result, the stacked spin-1/2 KHAF exhibits a rich GS phase diagram with two continuous and two discontinuous transitions driven by the ILC.