title: How to properly write CMakeLists for library outside project folder
body: <p>I decided to try CMake for my new project. I've spent some hours reading the official documentation and tutorials so I've gained some basic knowledge, but unable to write proper CMakeLists for my project.</p>
  
  <p>The file hierarchy looks like this:</p>
  
  <pre><code>project
  |-- library
  |   |-- CMakeLists.txt
  |   |-- lib.cpp
  |   `-- lib.h
  |-- app1
  |   |-- CMakeLists.txt
  |   |-- app1.cpp
  |   |-- app1.h
  |   `-- main.cpp
  |-- app2
  |   |-- CMakeLists.txt
  |   |-- app2.cpp
  |   |-- app2.h
  |   `-- main.cpp
  `-- app3
      |-- CMakeLists.txt
      |-- app3.cpp
      |-- app3.h
      `-- main.cpp
  </code></pre>
  
  <p>The point is that I want to compile the library as a static library so it can be used by app1, app2, app3 and so on. The reason for this structure is that each appN has it's own main function that will be run on AWS Lambda, but I'd like to write some common code shared between them in the library.</p>
  
  <p>From what I've read so far it's easy to add a library if it was in a sub-directory of the appN using <code>add_directory()</code> and add it to the <code>target_link_libraries()</code>, but I cannot figure out how to add a library that is outside of the appN folders. I tried using relative paths like <code>${CMAKE_CURRENT_SOURCE_DIR}/../library/lib.a</code> etc, but then CMake gives error that library is outside project folder.</p>
  
  <p>I'm sure there is some way to do this. I've read some about CMake modules and <code>find_package()</code>, but it seems to be a bit overkill/complicated for this use-case, I think?</p>