Fixed CMake building test objects multiple times

@jeffdonahue noticed in #943 that some test objects were built multiple times. E.g. `test_caffe_main.cpp` was built separately for each test executable. I fixed it by employing CMake's Object Library (available since CMake 2.8.8). It is not available for CUDA, however, and in this case I'm creating a separate library for every `test_*.cu`.

Surprisingly, CMake builds are now faster than Make's.