If you want to call attention to the reversal of priorities, you could say it is a case of the tail wagging the dog: the primary concern or objective of something has been made subsidiary to something that is relatively minor or should be dependent on it.
As a metaphor it has probably existed for some time, but as an idiom, the OED attests to it only from 1935, in the letters of no less than F. Scott Fitzgerald. The Phrase Finder entry traces it to the 1870s, but it does not appear in print outside the U.S. until the mid-20th century.
To put the cart before the horse similarly indicates that things are reversed from their proper or natural order, though I tend to use this more when referring to a sequence of actions as opposed to a ranking of priorities or importance. Buying a set of race tires before I buy a new car would be putting the cart before the horse. Choosing a new car based on whether those tires will fit or not is the tail wagging the dog.
If you want to emphasize that you are forced to work in a certain way because of circumstances you cannot change, you must play the hand you are dealt. This is a reference to card games where you cannot exchange your cards in the hope of receiving better ones, but instead strategize how to make the most of the situation you are given.
There are different ways this saying can be interpreted, however. On the one hand, it can be a call to focus on practical solutions rather than wasting time with wishful thinking. It might also be call to recognize and stay within one's limitations, like don't bite off more than you can chew, or cut your coat according to your cloth. In this line, however, it can also be perceived as dismissing efforts to improve, reform, or correct injustice.