title: cmake linking shared libraries on ubuntu
body: <p>Hi I am having problems with linking two libraries on ubuntu using cmake 2.8.12</p>
  
  <p>Directory structure</p>
  
  <pre><code>libraries
    \lib1
      CMakeLists.txt
      source1.cpp
    \lib2
      CMakeLists.txt
      source2.cpp
  build
  </code></pre>
  
  <p>CMakeLists.txt for lib1</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8.4)
  project(lib1)
  
  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ../../build/)
  set(BASE_DIR ../)
  set(SOURCE_FILES source1.cpp)
  
  include_directories ("${BASE_DIR}")
  add_library(lib1 SHARED ${SOURCE_FILES})
  
  target_include_directories (lib1 PUBLIC ${BASE_DIR})
  </code></pre>
  
  <p>This builds fine.</p>
  
  <p>Then for lib2 I have the following CMakeLists.txt</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8.4)
  project(lib2)
  
  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ../../build)
  set(BASE_DIR ../)
  set(SOURCE_FILES
      source2.cpp)
  
  include_directories ("${BASE_DIR}")
  
  add_library(lib2 SHARED ${SOURCE_FILES})
  
  # include lib1
  list(APPEND CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
  find_library(lib1 lib1)
  target_link_libraries(lib2 LINK_PUBLIC lib1)
  </code></pre>
  
  <p>Here I get</p>
  
  <p>Linking CXX shared library ../build/liblib2.so</p>
  
  <p>/usr/bin/ld: cannot find -llib1</p>
  
  <p>I am not clear how to correctly link these two shared libraries using CMake. Anyone an idea what is going wrong.</p>
  
  <p>Cheers, Mike</p>