title: define on const int, but put the value in the installed header
body: <p>I have a C++ library which does some numerical work. The main parameter is the number of segments. For speed it matters a factor 3 that the number of segment is <code>const</code>, however I would like to define it at compile time using <code>-DSEGMENTS 32</code>. The header looks like this:</p>
  
  <pre><code>#ifdef SEGMENTS
  const int segments = SEGMENTS
  #else
  const int segments = 20
  #endif
  </code></pre>
  
  <p>That works. However, programs linking with this library don't get the <code>-DSEGMENTS</code> and thus <code>segments</code> is always 20. Without the <code>const</code> I know the solution, but with I don't know. I can imagine some <code>extern</code> trick or installing the header after precompiling if that is possible with cmake.</p>