title: How to check whether a target has been added or not?
body: <p>Assume I have a cmake macro that adds target (library or executable) based on some conditions</p>
  
  <pre><code>macro (conditionally_add target_name target_src condition)
    if (condition)
      add_library (target_name target_src)
    endif ()
  endmacro()
  </code></pre>
  
  <p>My question is, after calling this function</p>
  
  <pre><code>conditionally_add (mylib mysrc.cc ${some_condition})
  </code></pre>
  
  <p>How can I check whether the library has been added? More specifically, I'd like to do something below</p>
  
  <pre><code>if (my_lib_is_added)    # HOW TO DO THIS?
    # Do something.
  endif ()
  </code></pre>