Both and neither. Ideally, they are created simultaneously for the purpose of working with each other. Other choices are usually less than optimal.
Still, one less than optimal, but still very good, choice is to keep tinkering with both until they maes very well, and to look for the options that exist in the rules so that they fit each other the best.
For example, the Iron Heroes rulesety works better for my homebrew campaighsetting than the core D&D rules, but I am still putting more D&D elements back into the Iron Heroes framework in order to fit the setting, which was designed with certain D&D iconics like elves, dwarves, and stable magic in mind, even better.