title: Get target filename without extension with CMake
body: <p>How can I get the basename of a target library with CMake?</p>
  
  <p>I'm creating a library with the CMake variable name ${lib} as in</p>
  
  <pre><code>set(lib lib)
  add_library(${lib} ...
  </code></pre>
  
  <p>I need the basename of the generated library file.</p>
  
  <p>CMake will create a library with the filename <code>&lt;prefix&gt;lib.&lt;extension&gt;</code> where both <code>&lt;prefix&gt;</code> and <code>&lt;extension&gt;</code> are platform specific.</p>
  
  <p>I've tried the generator <code>$&lt;TARGET_FILE_NAME:${lib}&gt;</code> which gives me the full name, which works because I'm needing this in a COMMAND, which is one of the few places where CMake allows generators.</p>
  
  <p>To remove the extension using CMake I need to use GET_FILENAME_COMPONENT as in</p>
  
  <pre><code>GET_FILENAME_COMPONENT(&lt;var&gt; &lt;filename&gt; NAME_WE)
  </code></pre>
  
  <p>but this is used to set the variable <code>&lt;var&gt;</code> (in normal CMake fashion) and generators don't work there.</p>
  
  <p>(The CMake language is an irregular abomination, if you ask me. CMake, as a concept, is pretty cool.)</p>