Do Big M modeling, along the lines of https://math.stackexchange.com/questions/2500415/how-to-write-if-else-statement-in-linear-programming/2501007 . There are many other example on the internet.
This makes use of CVX;s MIDCP capability (requires Gurobi, Mosek, or if you can get it to work, GLPK).