title: CMake one build directory for multiple projects
body: <p>I´m a beginner user of CMake. My environment has several projects like:</p>
  
  <pre><code>project
    |------ CMakeLists.txt (The main Cmake)
    |------ ProjectA
    |          |----- .cpp files
    |          |----- .hpp files
    |          |----- CMakeList.txt
    |------ ProjectB
    |          |----- .cpp files
    |          |----- .hpp files
    |          |----- CMakeList.txt
    | 
    |------ build
    |         |-----  CMakeStuff
    |------ bin
    |        |---- executables
    |------ lib
    |        |---- libwhatever.a
    |------ db 
             |---- Database stuff
  </code></pre>
  
  <p>I would like to use a single build directory for every project, as showed above. Preferrably that It can be divided into multiple subprojects, like <code>build/projectA</code>, <code>build/ProjectB</code> so that if I need to rebuild a single project I can delete the whole <code>build/Project</code> file and all is gone and a new <code>Cmake</code> will build it again.</p>
  
  <p>I´m having difficulties configuring CMAKE. </p>
  
  <p>My original CMakeList.txt on the project folder:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.2.2.)
  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib)
  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib)
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)
  
  project(projectA)
  set(CMAKE_BUILD_TYPE Debug)
  
  file(GLOB SOURCES "*.cpp")
  
  add_library(commonmessage SHARED ${SOURCES})
  
  install(TARGETS commonmessage DESTINATION ../lib)
  </code></pre>
  
  <p>My questions are: </p>
  
  <p>A) What will happen if I run cmake on a single build directory - is that possible and what would be the correct CMAKE configuration ?</p>
  
  <p>B) My compilation for <code>ProjectA</code> needs to include files from <code>ProjectB</code> - how can I set that in the <code>CMakeLists.txt</code> for each individual project ?</p>
  
  <p>C) At the end I need a single makefile to build all, as well as the option to build each project individually. Will that be possible with a single build directory ?</p>
  
  <p>Thanks for helping.</p>