title: CMake: Link precompiled library depending on OS and architecture
body: <p>I have different, precompiled versions of a 3rd-party library (Windows/Linux/Mac, 32/64-bit). It must be included in the project files to keep the requirements for compilation on other systems to a minimum and because I cannot expect it to be available for download years later. Both static and dynamic versions are available but no source.</p>
  
  <p>How should I link it in my <code>CMakeLists.txt</code> so that the dependent <code>main.cpp</code> compiles on all systems? Would it work on different Linux distributions?</p>
  
  <pre><code>CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
  PROJECT(ExampleProject)
  LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/libs)
  ADD_EXECUTABLE(Test main.cpp)
  TARGET_LINK_LIBRARIES(Test lib1_win32)
  </code></pre>
  
  <p>This works under Windows but obviously does not account for different operating systems and architectures. I know the alternatives to <code>LINK_DIRECTORIES</code>, this is just an example.</p>