[SOLVED] Compile PyTorch with additional linker options

I am working on a research project and we are trying to optimize the network communication in a distributed PyTorch deployment. I modified the gloo library and I am able to compile and run programs that use this library (similar to what you can find in gloo/gloo/examples).
So I replaced the third_party/gloo folder in PyTorch with my version of gloo and I am trying to compile it.

The tricky part is that my version of gloo requires some additional libraries and special linker options, and I cannot find the right place where to specify these options.
I tried to add these options to the Caffe2_DEPENDENCY_LIBS variable in pytorch/caffe2/CMakeLists.txt with no success.

My compilation stops with the linker error:

/pytorch/build/lib/libcaffe2_gpu.so: undefined reference to <my code>
/pytorch/build/lib/libcaffe2.so: undefined reference to <my code>

Can someone point me in the right direction?

Thanks!

I found a solution. You can find it on StackOverflow.