Recall that a CW-structure on a space $X$ is a sequence of spaces $X_0 \subseteq X_1 \subseteq ... \subseteq X$ such that each $X_{n+1}$ is obtained from $X_n$ by means of pushouts
$$\begin{array}{ccc}
\sqcup_i\mathbb{S}^n &\overset{\sqcup\phi_i}\rightarrow&X_n\\
\downarrow&&\downarrow\\
\sqcup_i\mathbb{D}^{n+1} &\underset{\sqcup\psi_i}\rightarrow&X_{n+1}
\end{array}$$
and $X= \bigcup_n X_n$.
So let us first prove the statement for each $X_n$, that is: $X_n$ is compact iff each $X_k$ with $k\leq n$ has only finitely many cells. By induction it suffices to prove that $X_{n+1}$ is compact iff $X_n$ is compact and we only attach finitely many $(n+1)$-cells in the square above. One direction is easy, since if we only have finitely many cells the spaces $\sqcup_i \mathbb{S}^n$ and $\sqcup_i \mathbb{D}^{n+1}$ are compact, thus $X_{n+1}$ is compact as a pushout of compact spaces. Conversely, if $X_{n+1}$ is compact, then so is the closed subspace $X_n$. Suppose $\cal{U}$ is an open cover of $X_{n+1}$. For each point $x_i = \psi_i(0) \in \psi_i(\mathbb{D}^{n+1}) \subseteq X_{n+1}$ we refine that cover to an open cover $\cal{U}'$ by replacing each $U\in\cal U$ with $x_i\in U$ with the two open subsets $V = U \setminus \{x_i\}$ and $W = \psi_i\left(\mathbb{B}(0,\frac{1}{2})\right)$. By compactness we find a finite subcover of $\cal{U}'$, so in particular we only need finitely many of the $W$'s, hence there are only finitely many $x_i$'s and we in fact only attached finitely many cells.
Now consider the general $X$. If it has only finitely many cells, then $X=X_m$ for some $m$, thus $X$ is compact by our previous discussion. Conversely, if $X$ is compact we can do a similar argument as before. Assume that $X \neq X_m$ for all $m$. Choose an open cover $\cal{U}$ of $X$ and refine it to isolate every $x_n$ in a chosen sequence $(x_n)_n$ of points satisfying $x_{n+1}\in X_{n+1}\setminus X_n$. By construction this new open cover $\cal{U}'$ will not admit a finite subcover. A contradiction to compactness. Thus $X=X_m$ for some $m$ and our previous discussion applies.