title: CMake differences between linking when target is a library vs executable
body: <p>The following correctly links the executable to the protobuffer.</p>
  
  <pre><code>protobuf_generate_cpp(proto_srcs proto_hdrs simple.proto
  add_executable(executable a.cc "${proto_srcs}")
  target_link_libraries(executable "${PROTOBUF_LIBRARIES}")
  </code></pre>
  
  <p>The following does not correctly link the libraries.</p>
  
  <pre><code>protobuf_generate_cpp(proto_srcs proto_hdrs simple.proto
  add_library(proto_lib "${proto_srcs}")
  target_link_libraries(proto_lib "${PROTOBUF_LIBRARIES}")
  ...
  target_link_libraries(some_executable proto_lib)
  </code></pre>
  
  <p>The issue appears to be in the handling of debug vs optimized libraries.  In the first this is properly handled, while in the second it attempts to link to the debug/optimized library string, error follows.</p>
  
  <pre><code>ld: library not found for -loptimized;/usr/local/lib/libprotobuf.dylib;debug;/usr/local/lib/libprotobuf.dylib
  </code></pre>
  
  <p>I've tried playing with the quoting of arguments and changing the type of library being created, but I'm at a loss.  Anyone know what I'm doing wrong?</p>