cmake: fix lookup of external libraries