title: cmake - UnitTest++ linking unit test binaries fails
body: <p>I'm new to CMake, but I was able to setup the CMakeLists.txt files for my C++ project, it resembles a little bit <a href="http://isti.bitbucket.org/2012/06/01/cmake-check.html" rel="nofollow">this setup</a>, BTW. I need to use UnitTest++ for unit testing, but for some reason linking the unit test executables fails. Here is the shell output:</p>
  
  <pre><code>jorge [~/coders/desarrollo/santotomasdeaquino] ~&gt; mkdir build
  jorge [~/coders/desarrollo/santotomasdeaquino] ~&gt; cd build/
  jorge [~/coders/desarrollo/santotomasdeaquino/build] ~&gt; cmake VERBOSE=1 ..
  -- The C compiler identification is GNU 4.8.2
  -- The CXX compiler identification is GNU 4.8.2
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/c++
  -- Check for working CXX compiler: /usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Boost version: 1.54.0
  -- Found the following Boost libraries:
  --   filesystem
  -- Librerias: /usr/lib64/libboost_filesystem.so
  -- Found UnitTest++: /usr/lib64/libUnitTest++.a
  -- Librerias: /usr/lib64/libboost_filesystem.so;ResourceManager
  -- dir='/usr/include'
  -- dir='/home/jorge/coders/desarrollo/santotomasdeaquino/include'
  -- dir='/home/jorge/coders/desarrollo/santotomasdeaquino/tests'
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /home/jorge/coders/desarrollo/santotomasdeaquino/build
  jorge [~/coders/desarrollo/santotomasdeaquino/build] ~&gt; LC_ALL=C make
  [ 50%] Built target ResourceManager
  Linking CXX executable test_resourcemanager
  CMakeFiles/test_resourcemanager.dir/test_resourcemanager.cpp.o: In function `TestPruebaDeCMake::RunImpl() const':
  test_resourcemanager.cpp:(.text+0x23): undefined reference to `UnitTest::CurrentTest::Details()'
  test_resourcemanager.cpp:(.text+0x3a): undefined reference to `UnitTest::TestDetails::TestDetails(UnitTest::TestDetails const&amp;, int)'
  test_resourcemanager.cpp:(.text+0x3f): undefined reference to `UnitTest::CurrentTest::Results()'
  test_resourcemanager.cpp:(.text+0x56): undefined reference to `UnitTest::TestResults::OnTestFailure(UnitTest::TestDetails const&amp;, char const*)'
  test_resourcemanager.cpp:(.text+0x7f): undefined reference to `UnitTest::CurrentTest::Details()'
  test_resourcemanager.cpp:(.text+0x96): undefined reference to `UnitTest::TestDetails::TestDetails(UnitTest::TestDetails const&amp;, int)'
  test_resourcemanager.cpp:(.text+0x9b): undefined reference to `UnitTest::CurrentTest::Results()'
  test_resourcemanager.cpp:(.text+0xb2): undefined reference to `UnitTest::TestResults::OnTestFailure(UnitTest::TestDetails const&amp;, char const*)'
  CMakeFiles/test_resourcemanager.dir/test_resourcemanager.cpp.o: In function `main':
  test_resourcemanager.cpp:(.text+0xc8): undefined reference to `UnitTest::RunAllTests()'
  CMakeFiles/test_resourcemanager.dir/test_resourcemanager.cpp.o: In function `__static_initialization_and_destruction_0(int, int)':
  test_resourcemanager.cpp:(.text+0x10a): undefined reference to `UnitTest::Test::GetTestList()'
  test_resourcemanager.cpp:(.text+0x11c): undefined reference to `UnitTest::ListAdder::ListAdder(UnitTest::TestList&amp;, UnitTest::Test*)'
  CMakeFiles/test_resourcemanager.dir/test_resourcemanager.cpp.o: In function `TestPruebaDeCMake::TestPruebaDeCMake()':
  test_resourcemanager.cpp:(.text._ZN17TestPruebaDeCMakeC2Ev[_ZN17TestPruebaDeCMakeC5Ev]+0x2c): undefined reference to `UnitTest::Test::Test(char const*, char const*, char const*, int)'
  CMakeFiles/test_resourcemanager.dir/test_resourcemanager.cpp.o: In function `TestPruebaDeCMake::~TestPruebaDeCMake()':
  test_resourcemanager.cpp:(.text._ZN17TestPruebaDeCMakeD2Ev[_ZN17TestPruebaDeCMakeD5Ev]+0x1f): undefined reference to `UnitTest::Test::~Test()'
  CMakeFiles/test_resourcemanager.dir/test_resourcemanager.cpp.o:(.rodata._ZTI17TestPruebaDeCMake[_ZTI17TestPruebaDeCMake]+0x10): undefined reference to `typeinfo for UnitTest::Test'
  collect2: error: ld returned 1 exit status
  tests/CMakeFiles/test_resourcemanager.dir/build.make:90: recipe for target 'tests/test_resourcemanager' failed
  make[2]: *** [tests/test_resourcemanager] Error 1
  CMakeFiles/Makefile2:128: recipe for target 'tests/CMakeFiles/test_resourcemanager.dir/all' failed
  make[1]: *** [tests/CMakeFiles/test_resourcemanager.dir/all] Error 2
  Makefile:85: recipe for target 'all' failed
  make: *** [all] Error 2
  jorge [~/coders/desarrollo/santotomasdeaquino/build] ~&gt; 
  </code></pre>
  
  <p>This is my root CMakeLists.txt file:</p>
  
  <pre><code>jorge [~/coders/desarrollo/santotomasdeaquino] ~&gt; cat CMakeLists.txt 
  cmake_minimum_required(VERSION 2.8)
  
  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
  
  # project name
  project(tomas-aquino)
  
  # In this project, Boost is gonna be use
  find_package(Boost 1.48.0 REQUIRED COMPONENTS filesystem)
  include_directories(${Boost_INCLUDE_DIRS})
  set(LIBS ${Boost_LIBRARIES})
  message(STATUS "Librerias: ${LIBS}")
  
  include_directories(include)
  include_directories(tests)
  
  enable_testing()
  
  add_subdirectory(src)
  add_subdirectory(tests)
  jorge [~/coders/desarrollo/santotomasdeaquino] ~&gt; 
  </code></pre>
  
  <p>and this is my CMakeLists.txt file related to my executable unit testing binaries:</p>
  
  <pre><code>jorge [~/coders/desarrollo/santotomasdeaquino] ~&gt; cat tests/CMakeLists.txt 
  enable_testing()
  find_package(UnitTest++ REQUIRED)
  include_directories(${UNITTEST++_INCLUDE_DIRS})
  set(LIBS ${LIBS} ${UNITTEST_LIBRARIES} ResourceManager)
  
  add_executable(test_resourcemanager test_resourcemanager.cpp)
  message(STATUS "Librerias: ${LIBS}")
  target_link_libraries(test_resourcemanager ${LIBS})
  
  add_test(test_resourcemanager ${CMAKE_CURRENT_BINARY_DIR}/test_resourcemanager)
  
  get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
  foreach(dir ${dirs})
    message(STATUS "dir='${dir}'")
  endforeach()
  jorge [~/coders/desarrollo/santotomasdeaquino] ~&gt; 
  </code></pre>
  
  <p>and here is the last CMakeLists.txt file related to building the libraries of my project:</p>
  
  <pre><code>jorge [~/coders/desarrollo/santotomasdeaquino] ~&gt; cat src/CMakeLists.txt 
  include_directories(./tomasaquino)
  add_library(ResourceManager ./tomasaquino/ResourceManager.cpp)
  jorge [~/coders/desarrollo/santotomasdeaquino] ~&gt; 
  </code></pre>
  
  <p>What I'm doing wrong?</p>