title: How to structure a cmake project with different 3rd-party libraries
body: <p>I'm new with cmake and try to create a small project which needs some 3rd-party libs. I would like to have the libs as git repos to always be up-to-date. Some libs are just .cpp and .hpp files (glad, imgui) and others are cmake projects (glfw, glm).</p>
  
  <p>The idea is to have a 3rd-party project with all the libs as a kind of subprojects and a sandbox project which uses the libs and includes etc.
  And I would like to use modern cmake code which is not installing something outside the framework structure.</p>
  
  <p>Folder structure:</p>
  
  <pre><code>Framework
  |--3rd_party
  |  |--glad
  |  |  |--include
  |  |  |--src
  |  |--glfw-master
  |  |  |--...
  |  |  |--CMakeLists.txt
  |  |--glm-master
  |  |  |--..
  |  |  |--CMakeLists.txt
  |  |--imgui-master
  |  |  |--*.cpp
  |  |  |--*.hpp
  |  |  |--examples
  |  |  |  |--*.cpp
  |  |  |  |--*.hpp
  |  |--CMakeLists.txt
  |--sandbox
  |  |--main.cpp
  |  |--CMakeLists.txt
  |--CMakeLists.txt
  </code></pre>
  
  <p>So I created this folder structure and also some CMakeLists:</p>
  
  <p>CMakeLists.txt (Framework)</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.10)
  
  project(Framework)
  
  add_subdirectory("3rd_party")
  add_subdirectory("sandbox")
  </code></pre>
  
  <p>CMakeLists.txt (3rd_party)</p>
  
  <pre><code>#GLFW
  set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
  set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
  set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
  add_subdirectory(glfw-master)
  
  # GLM
  set(GLM_TEST_ENABLE OFF CACHE BOOL "" FORCE)
  add_subdirectory(glm-master)
  
  # Glad
  add_library(
      Glad STATIC
      "glad/src/glad.c"
  )
  
  target_include_directories(Glad PUBLIC "glad/include")
  
  # ImGui
  add_compile_definitions(IMGUI_IMPL_OPENGL_LOADER_GLAD=1)
  
  set(IMGUI_SOURCES
      "imgui-master/imgui.cpp"
      "imgui-master/imgui_demo.cpp"
      "imgui-master/imgui_draw.cpp"
      "imgui-master/imgui_widgets.cpp"
      "imgui-master/examples/imgui_impl_glfw.cpp"
      "imgui-master/examples/imgui_impl_opengl3.cpp"
  )
  
  set(IMGUI_HEADERS
      "imgui-master/imconfig.h"
      "imgui-master/imgui.h"
      "imgui-master/imgui_internal.h"
      "imgui-master/imstb_rectpack.h"
      "imgui-master/imstb_textedit.h"
      "imgui-master/imstb_truetype.h"
      "imgui-master/examples/imgui_impl_glfw.h"
      "imgui-master/examples/imgui_impl_opengl3.h"
  )
  
  add_library(
      ImGui STATIC
      ${IMGUI_SOURCES}
      ${IMGUI_HEADERS}
  )
  
  target_include_directories(ImGui PUBLIC "imgui-master" "glfw-master/include" "glad/include")
  </code></pre>
  
  <p>CMakeLists.txt (sandbox)</p>
  
  <pre><code>project(Sandbox)
  
  find_package(OpenGL REQUIRED)
  
  add_executable(sandbox main.cpp)
  
  # OpenGL
  target_include_directories(Sandbox PUBLIC ${OPENGL_INCLUDE_DIR})
  target_include_directories(Sandbox PUBLIC external)
  
  # Glfw
  target_include_directories(Sandbox PUBLIC "../3rd_party/glfw-master/include")
  
  # Link libs
  target_link_libraries(Sandbox PUBLIC
             ${OPENGL_LIBRARIES}
             "../3rd_party/glfw-master/src/Debug/glfw3"
             Glad
             ImGui
             glm_static
  )
  </code></pre>
  
  <p>The code works but not as I expect. At first I know it's a little bit ugly maybe there is a better way to handle the path for includes and sources but the bigger problem is project structure.
  For example, when I build it for ms vs studio I have three solutions</p>
  
  <pre><code>./framework.sln
  ./sandbox/sandbox.sln
  ./3rd_party/glfw-master/glfw.sln
  </code></pre>
  
  <p>And glad, glm and imgui are part of sandbox.sln</p>
  
  <p>What I would like to have is a solution with two sub-solutions sandbox and 3rd_party which also has sub-solutions or projects for all the libs.</p>
  
  <p>So is it possible at all and if yes how can I create such a structure with cmake?</p>