title: cmake: relative link directories
body: <p>I'm trying to build my project with cmake and I'm having problem with specifying directories with libraries to link.  </p>
  
  <p>My project have the following directory hierarchy:</p>
  
  <p>folder/my_libs/libA/include<br>
  folder/my_libs/libA/src<br>
  folder/my_libs/libA/projects<br>
  folder/my_libs/libA/unit_tests  </p>
  
  <p>folder/other_libs/devlib/include<br>
  folder/other_libs/devlib/lib  </p>
  
  <p>3RD_PARTY_LIB/gtest-1.5.0/include<br>
  3RD_PARTY_LIB/gtest-1.5.0/lib<br>
  3RD_PARTY_LIB/pcre-8.02/include<br>
  3RD_PARTY_LIB/pcre-8.02/lib  </p>
  
  <p><code>3RD_PARTY_LIB</code> is environment variable that contains path of some 3rd party libs that I use.  </p>
  
  <p>The problem is in unit_tests/CMakeLists.txt - when I specify relative paths for includes with <strong>include_directories</strong> they are handled correctly, but relative paths specified with <strong>link_directories</strong> are handled wrong.    </p>
  
  <p>Here are my makefiles:</p>
  
  <p>=================================<br>
  <strong># folder/my_libs/libA/CMakeLists.txt</strong></p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
  project("libA")        
  add_subdirectory(src)
  add_subdirectory(unit_tests)
  </code></pre>
  
  <p>=================================<br>
  <strong># folder/my_libs/libA/src/CMakeLists.txt</strong>  </p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8 FATAL_ERROR)    
  project("libA")
  
  set(HDR_LIST ../include/AuxRoutines.h          
               ...
               ../include/utility.h)
  
  set(SRC_LIST ModuleImpl.cpp 
               ..
               Version.cpp)
  
  # add include dirs
  include_directories("../include")
  include_directories("../../../other_libs/devlib/include")
  
  # disable some warnings
  add_compile_options("/wd 4996")
  ...
  
  # this command creates a new library from specified sources
  add_library(libA STATIC ${SRC_LIST} ${HDR_LIST} )
  </code></pre>
  
  <p>=================================<br>
  <strong># folder/my_libs/libA/unit_tests/CMakeLists.txt</strong></p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8 FATAL_ERROR)    
  project("sys_utils_tests")
  
  set(SRC_LIST AuxiliaryRoutinesTests.cpp 
               ...
               UnitTests.h)
  
  # add include dir
  include_directories("../include")
  include_directories("../../../other_libs/devlib/include")
  include_directories($ENV{3RD_PARTY_LIB}/gtest-1.5.0/include)
  include_directories($ENV{3RD_PARTY_LIB}/pcre-8.02/include)
  
  # where to look for libs
  link_directories(../../../other_libs/devlib/lib/)  
  link_directories($ENV{3RD_PARTY_LIB}/gtest-1.5.0/lib/)  
  
  # disable some warnings
  add_compile_options("/wd 4996")
  ...
  
  # make an executable from specified sources
  add_executable(libATest ${SRC_LIST})
  
  # libs to link with
  target_link_libraries(libATest libA)
  target_link_libraries(libATest gtestd.lib)
  target_link_libraries(libATest devlibd.lib)
  </code></pre>