title: how do i compile/link test cases (googleTest) using cmake to the code bundled up in shared library?
body: <p>My project is organized like this:</p>
  
  <ul>
  <li>cpp
  
  <ul>
  <li>main.cpp (calls code from <code>dataStructures/</code> and <code>common/</code>)</li>
  <li>CMakeLists.txt (<em>topmost</em> CMakeLists file)</li>
  <li>build</li>
  <li>test
  
  <ul>
  <li>main.cpp</li>
  <li>CMakeLists.txt</li>
  <li>common
  
  <ul>
  <li>CMakeLists.txt</li>
  <li>include</li>
  <li>src</li>
  </ul></li>
  <li>googletest</li>
  <li>build</li>
  </ul></li>
  <li>common
  
  <ul>
  <li>CMakeLists.txt (should be responsible for building common shared library)</li>
  <li>include
  
  <ul>
  <li>utils.h</li>
  </ul></li>
  <li>src
  
  <ul>
  <li>utils.cpp</li>
  </ul></li>
  <li>build</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p><code>build\</code> directories contain the built target. The actual code can be seen here: <a href="https://github.com/brainydexter/PublicCode/tree/master/cpp" rel="nofollow">https://github.com/brainydexter/PublicCode/tree/master/cpp</a></p>
  
  <p>I'm able to build <code>shared</code> libraries for the actual code ( like <code>common</code>). Now, I'd like to test it using GoogleTest. So, I created a <code>test</code> directory and put the test code in there (what I have in the repo is just a sample, more like hello world to get the build system up and working. I will be adding more test cases later on).</p>
  
  <p><strong>I need some help in triggering the tests from the topmost CMakeLists.txt</strong>. I'm not sure how to do this. In <code>test</code>, CMakeLists.txt looks like this:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.1.2)
  
  add_subdirectory(googletest/googletest)
  include_directories(googletest/googletest/include)
  
  add_subdirectory(common)
  
  enable_testing()
  
  add_executable(testCpp main.cpp)
  target_link_libraries(testCpp gtest gtest_main )
  </code></pre>
  
  <p>Do I need to add anything else to enable tests in <code>test/common</code> ?</p>
  
  <p><code>test/common/CMakeLists.txt</code>:</p>
  
  <pre><code>file(GLOB SOURCES "src/*.cpp")
  
  add_executable(testCommon ${SOURCES})
  
  target_link_libraries(testCommon cppCommon)
  </code></pre>
  
  <p><strong>I'm not sure if the target should be executable here or a library that the google test framework can consume ?</strong> I'd appreciate any help on this.</p>