You can probably do them both at the same time, no harm in that, but it'll obviously mean a slightly longer session so it depends how your motivation is. That's why it can be good to use your journey to and from the gym to do your cardio as you've got to get there anyway. Then just use the gym for weights.