title: compile qt library with cmake
body: <p>I'm sorry for my stupid question. I'm trying to compile dll with cmake from class with Qt objects. Library contains function which uses class defined in other file.  And during link proccess I get error "undefined reference" to class member.
  Where is the error in CMakeList.txt?</p>
  
  <p>CMakeList.txt:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8) 
  project(foo)            
  set(SOURCE_LIB foo.cpp window.cpp)          
  find_package (Qt4 REQUIRED)
  include (${QT_USE_FILE})
  ADD_DEFINITIONS(-DFOO_LIBRARY)
  add_library(foo SHARED ${SOURCE_LIB})   
  target_link_libraries(foo ${QT_LIBRARIES})
  </code></pre>
  
  <p>foo.h:</p>
  
  <pre><code>#ifndef FOO_H
  #define FOO_H
  
  #include "foo_global.h"
  
  void FOOSHARED_EXPORT hello_world();
  #endif // FOO_H
  </code></pre>
  
  <p>foo.cpp:</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QMessageBox&gt;
  #include "window.h"
  
  void hello_world()
  {
      int argc = 0;
      char ** argv = (char **) 0;
      QApplication a(argc, argv);
      Window *w = new Window();
      w-&gt;Msg();
  }
  </code></pre>
  
  <p>foo_global.h:</p>
  
  <pre><code>#ifndef FOO_GLOBAL_H
  #define FOO_GLOBAL_H
  
  #include &lt;QtCore/qglobal.h&gt;
  
  #if defined(FOO_LIBRARY)
  #  define FOOSHARED_EXPORT Q_DECL_EXPORT
  #else
  #  define FOOSHARED_EXPORT Q_DECL_IMPORT
  #endif
  
  #endif // FOO_GLOBAL_H
  </code></pre>
  
  <p>window.cpp:</p>
  
  <pre><code>#include &lt;QMessageBox&gt;
  #include "window.h"
  
  void Window :: Msg()
  {
      QMessageBox *msg = new QMessageBox();
      msg-&gt;setText("hello");
      msg-&gt;exec();
  }
  </code></pre>
  
  <p>window.h:</p>
  
  <pre><code>#ifndef WINDOW_H
  #define WINDOW_H
  
  #include &lt;QtGui&gt;
  
  class Window
  {
      Q_OBJECT
  public:
      void Msg();
  
  };
  
  #endif // WINDOW_H
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Test\build&gt;c:\MinGW\bin\mingw32-make.exe
  Scanning dependencies of target foo
  [ 50%] Building CXX object CMakeFiles/foo.dir/foo.cpp.obj
  [100%] Building CXX object CMakeFiles/foo.dir/window.cpp.obj
  Linking CXX shared library libfoo.dll
  Creating library file: libfoo.dll.a
  CMakeFiles\foo.dir/objects.a(foo.cpp.obj):foo.cpp:(.text$_ZN6WindowC1Ev[Window::
  Window()]+0x8): undefined reference to `vtable for Window'
  collect2: ld returned 1 exit status
  mingw32-make[2]: *** [libfoo.dll] Error 1
  mingw32-make[1]: *** [CMakeFiles/foo.dir/all] Error 2
  mingw32-make: *** [all] Error 2
  </code></pre>