Trying to fix CMake tests about shared_ptr

I made this patch to solve the problem reported in the issue #196.
Please try this and report the result @sbooth, thanks.

Actually, I still have doubts that this is not a complete solution, but it may be useful for now.