I don't see why it could be a bad idea. I'll elaborate a little. CMake have a configure_file() macro for substituting variables surrounded by '@' with a CMake configuration-time variables. I changed the name of test_caffe_main.hpp to test_caffe_main.hpp.in and put the following file there:
#define CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@"
At configuration time CMake generates the test_caffe_main.hpp file from the input file and  the @CMAKE_SOURCE_DIR@ gets substituted by the value of CMAKE_SOURCE_DIR, which in this case was /home/adam/workspace/caffe/src/. I used the same method for the test_data/sample_data_list.txt.