cmake: find dependencies after setting build flags This makes splitting up the library build instructions later on more obvious and easier to achieve.