title: Header-only and static build with QMake
body: <p>I am trying to set up a simple class that can be used both as a header only and static with qmake. I am contolling if the build is static using a macro "STATIC_BUILD" defined in the .pro file.</p>
  
  <p>foo.pro:</p>
  
  <pre><code>TEMPLATE = app
  CONFIG += c++11
  
  CONFIG += STATIC_BUILD
  
  STATIC_BUILD {
      DEFINES += STATIC_BUILD
  }
  
  SOURCES += \
      main.cpp
  
  HEADERS += \
      foo.h
  
  STATIC_BUILD {
      SOURCES += \
          foo.cpp
  }
  </code></pre>
  
  <p>foo.h</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#ifndef FOO_H
  #define FOO_H
  
  #ifndef STATIC_BUILD
  #define MY_INLINE inline
  #else
  #define MY_INLINE
  #endif
  
  class Foo {
  public:
      Foo();
  
      int getI() const;
      void setI(int value);
  
  private:
      int i;
  };
  
  #ifndef STATIC_BUILD
  #include "foo.cpp"
  #endif
  
  #endif // FOO_H
  </code></pre>
  
  <p>foo.cpp</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include "foo.h"
  
  MY_INLINE Foo::Foo(){}
  
  MY_INLINE int Foo::getI() const {
      return i;
  }
  
  MY_INLINE void Foo::setI(int value) {
      i = value;
  }
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include "foo.h"
  
  int main() {
      Foo f;
      f.setI(3);
      std::cout &lt;&lt; f.getI() &lt;&lt; "\n";
      return 0;
  }
  </code></pre>
  
  <p>Commenting the line "CONFIG += STATIC_BUILD" in foo.pro and using the class as header only works as expected. 
  If I compile this project as static (with the line above not commented) I get "undefined reference" for members of "Foo". </p>
  
  <p>I noticed that, with "CONFIG += STATIC_BUILD" not commented and commenting instead the line</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include "foo.cpp"
  </code></pre>
  
  <p>in foo.h, everything works correctly (only for the static build, of course). 
  This does not make any sense to me because the "ifndef" has excactly the purpose to do not "compile" the #include in the static build. </p>
  
  <p>What am I doing wrong?</p>
  
  <p>I am using Qt 5.11 with gcc in a linux environment.</p>