If $Q$ is your covariance matrix, and $r$ is a vector of your expected returns, then the maximum Sharpe ratio is given by the following math program.
$${\rm maximize} \frac{r^t x}{\sqrt{0.5 x^t Q x}}$$
subject to
$$ 1^t x = m$$
$$ x \in \{0,1\}^n$$
Where $x$ is a vector of indicators of which of the $n$ assets are part of the $m$ selected assets. While the objective is not convex, its solution lies of the efficient frontier of $$\rm{maximize}\ r^t x, -0.5 x^t Q x.$$
You can compute the efficient frontier of the return/variance by solving the following mixed-integer convex-quadratic program for multiple values of $r^*$.
$$ {\rm minimize} \frac{1}{2} x^t Q x - \epsilon r^t x$$
subject to
$$ r^t x \ge r^*$$
$$ 1^t x = m$$
$$ x \in \{0,1\}^n$$
where $r$ is a vector of expected returns, and $r^*$ is a target expected return. The optimal value for any any value of $r^*$ that is feasible will yield a point on the efficient frontier. The portfolio with the best Sharpe ratio will be on the efficient frontier, so by iteratively solving the above problem for multiple values of $r^*$, you can find the value of $r^*$ that yields the best Sharpe ratio. The highest feasible value for $r^*$ can be computed by taking the top $m$ expected returns.