Updated CMake function to handle imported dependencies.