Ok, so it turns out that I don't need to use the developer drivers to compile OpenCV after all!
I had somehow messed up my software sources such that I wasn't updating from ppa:ubuntu-x-swat/x-updates any more. When I fixed that I was able to update my NVIDIA drivers to 304.43 from 295.49. I think that might have been the critical factor for getting OpenCV to compile, although I did also have to modify one makefile to make it work.
If anyone's interested in doing the same, I basically followed the instructions here. To paraphrase:
sudo apt-get install the following module dependencies if you don't already have them:
libopencv-dev build-essential checkinstall cmake pkg-config libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libv4l-dev
Download the latest OpenCV from here, then:
tar -xvf OpenCV-<version#>.tar.bz2
cd OpenCV-<version#>/
mkdir build
cd build
Run cmake to configure a build file. You will need to pass cmake a set of options to specify how you would like OpenCV to be built. The exact options will depend on your system - you can get some idea of what options are available by looking at ../CMakeLists.txt. The exact command I used was:
cmake -D WITH_QT=ON -D WITH_XINE=ON -D WITH_OPENGL=ON -D WITH_TBB=ON -D BUILD_EXAMPLES=ON BUILD_TESTS=ON ENABLE_SSE3=ON ENABLE_SSE4.1=ON ENABLE_SSE4.2=ON WITH_CUDA=ON ..
I had particular trouble getting it to compile with CUDA runtime support (WITH_CUDA=ON), hence the original question about the drivers.
cmake will create a file called CMakeCache.txt. I found that I had to modify this file as described here in order to avoid an error linking libcuda.so.
Find the line that starts:
CUDA_CUDA_LIBRARY:FILEPATH=
And append the path to libcuda.so, in my case:
CUDA_CUDA_LIBRARY:FILEPATH=/usr/lib/nvidia-current/libcuda.so
Now you should be able to run make to compile (takes a while...), then sudo make install to install
I hope somebody finds this useful.