title: Why use add_library({tgt} IMPORTED) versus target_link_libraries( -l {.so | .a})?
body: <p>What is the purpose of using the statement:</p>
  
  <pre><code>add_library(&lt;tgt&gt; [SHARED|STATIC] IMPORTED)
  </code></pre>
  
  <p>From what I have found even if you create an imported library target above you still would need to specify the specific location of the actual .so or .a. This would take at least 3 cmake commands to link to an executable and the compiler still would not automatically search through the common include directories on your OS.</p>
  
  <p>Example:
  <a href="https://stackoverflow.com/questions/36648375/what-are-the-differences-between-imported-target-and-interface-libraries">cmake code to link IMPORTED lib</a></p>
  
  <p>From the CMake documentation I understand there are really 3 ways to link a library that is not built as a target in a subproject of your overall application/library. </p>
  
  <p><a href="https://cmake.org/cmake/help/v3.10/command/target_link_libraries.html#id2" rel="noreferrer">CMake target_link_libraries() documentation</a></p>
  
  <ol>
  <li>Using a CMake package for one of the shipped package scripts.</li>
  <li><p>Using a linker flag:</p>
  
  <pre><code>target_link_libraries(&lt;tgt&gt; [SHARED|STATIC|...] -lncursesw)
  </code></pre></li>
  <li>Or using the IMPORTED library method (showcased in code at top).</li>
  </ol>
  
  <p>A major difference when using the second method is that it only takes a single line of code and will search through all of your compiler's predefined include directories on you OS. Could anyone help me understand why the add_library() method is used?<hr></p>
  
  <p>Additional Realated SO Posts:</p>
  
  <p><a href="https://stackoverflow.com/questions/48355884/include-directories-for-imported-library?rq=1">Include directories for IMPORTED libs</a></p>
  
  <p><a href="https://stackoverflow.com/questions/14850736/cmake-imported-library-behaviour?rq=1">CMake imported library behavior</a></p>