OptiX and MATLAB integration using mex

I am trying to use OptiX as a ray-traced forward model in a MATLAB script, as such I would like to compile a mex file so I can call a launch function repeatedly from MATLAB. However, I am having issues getting the mex compiler to correctly link during build.

I have a cmake script which builds perfectly, but when I export all the include directories, and libraries to use in the matlab mex call I get a bunch of “undefined reference to ‘<insert OptiX struct/datatype/function here>’” errors.

Has anyone done this before? If so what approach did you take?
Did you use cmake? A mex call within matlab? A manually configured make file? Or what?