Please move this block under if(... SKIP_LINK) section. Also could you please check that opencv_world builds correctly after applying your patch.