title: Running cmake project with dynamic libraries
body: <p>I am working on a project which uses a 3rd party closed source SDK that consists of a single shared library and corresponding header file. I'm trying to avoid adding the library to the search path so I can try compiling the project against several different versions of the library for testing.</p>
  
  <p>My question is how do I handle shared libraries so the project builds and runs nicely? I can build the project, but the newly created executable can not locate the shared library I need. It will run if I copy the shared library to the same folder as the executable, but I want to avoid that doing that extra step manually to keep things easier for other developers. What would be a good way to manage shared library dependencies so that when the project gets built it can run even without the shared libraries in the search path?</p>
  
  <p>Here are the relavent parts of my <code>CMakeLists.txt</code> file showing how I am locating the shared library:</p>
  
  <pre><code>add_library(theSDK SHARED IMPORTED)
  set_target_properties( theSDK PROPERTIES IMPORTED_LOCATION 
      ${CMAKE_CURRENT_SOURCE_DIR}/lib/TheSDK/lib/libSDK.dylib )
  add_executable(myProject ${myProject_SOURCES})
  target_link_libraries (myProject theSDK)
  </code></pre>