CUDA-11.0 wrong pkgconfig and found the root cause with proposed workaround

I found that pkg-config --libs cuda-11.0 gives me wrong path

$ pkg-config --libs cuda-11.0
-L/usr/local/cuda-11.0/x86_64-linux/lib -lcuda

But when I look at that location, it doesn’t exist.

$ ls /usr/local/cuda-11.0/x86_64-linux/lib
ls: cannot access '/usr/local/cuda-11.0/x86_64-linux/lib': No such file or directory

Problem is that this path is missing /targets/ between /usr/local/cuda-11.0 and x86_64-linux/lib.

$ ls /usr/local/cuda-11.0/targets/x86_64-linux/lib                         libcudart_static.a                                    libculibos.a              liblapack_static.a                libmetis_static.a                libcudadevrt.a                                                  stubs

This is inside NGC docker image but also on the host machine if cuda-11.0 is installed with package manager. So, these files

/usr/lib/pkgconfig$ ls

accinj64-11.0.pc  cuda-11.0.pc    cufft-11.0.pc   cuinj64-11.0.pc  cusolver-11.0.pc  nppc-11.0.pc  nppial-11.0.pc  nppicom-11.0.pc  nppif-11.0.pc  nppim-11.0.pc   nppisu-11.0.pc  npps-11.0.pc        nvidia-ml-11.0.pc  nvrtc-11.0.pc
cublas-11.0.pc    cudart-11.0.pc  cufftw-11.0.pc  curand-11.0.pc   cusparse-11.0.pc  nppi-11.0.pc  nppicc-11.0.pc  nppidei-11.0.pc  nppig-11.0.pc  nppist-11.0.pc  nppitc-11.0.pc  nvToolsExt-11.0.pc  nvjpeg-11.0.pc

contains wrong PATH information.

/usr/lib/pkgconfig$ cat cuda-11.0.pc 

Name: cuda
Description: CUDA Driver Library
Version: 11.0
Libs: -L${libdir} -lcuda
Cflags: -I${includedir}

So, simple workaround is to create a symlink inside /usr/local/cuda-11.0/
sudo ln -s targets/x86_64-linux/ x86_64-linux