Thanks to @Tsyvarev I found out that I misunderstood the error message. There was another source file that I forgot to add dependency and the error was about that target rather than the one I posted. After adding dependency using target_link_libraries
everything worked fine.