title: Linking to a library that hasn't been built yet with CMake
body: <p>I'm building a project whose final output is a static library, and my CMake-based build system consists of two subdirectories - the Src and the Tests - where the build for the tests produces an executable and links the to the library which is built from src.</p>
  
  <p>My problem is that the test build requires the library to already exist if it is to proceed without any errors. Is there a way to get CMake to understand that the library will exists when it comes to build the tests, or do I have to do these in separate steps?</p>
  
  <p>My CMakeLists.txt files as as follows:</p>
  
  <p>Root file:</p>
  
  <pre><code>cmake_minimum_required( VERSION 2.8 )
  project( mylib )
  add_subdirectory( Src )
  add_subdirectory( Tests )
  </code></pre>
  
  <p>Src file:</p>
  
  <pre><code>file( GLOB MYLIB_SOURCES *.cpp )
  add_library( mylib ${MYLIB_SOURCES} )
  </code></pre>
  
  <p>Test file:</p>
  
  <pre><code>file( GLOB MYLIB_TESTS *.cpp )
  add_executable( tests ${MYLIB_TESTS} )
  
  find_package( GTest REQUIRED )
  find_library( LIB_MYLIB NAMES mylib PATHS "${CMAKE_SOURCE_DIR}/Build/Src" )
  
  include_directories( ../Src )
  include_directories( ${GTEST_INCLUDE_DIRECTORIES} )
  
  target_link_libraries( tests ${LIB_MYLIB} ${GTEST_LIBRARIES} pthread )
  </code></pre>