title: How to setup a new C++ project with restbed?
body: <p>I am trying to write a web service in C++ (I am very new to the language) using <a href="https://github.com/Corvusoft/restbed" rel="nofollow noreferrer">restbed</a> for HTTP handling. Both projects seem to be using cmake to do build configuration and dependency management, so I figured I would do so as well. But I am confused about how to go about it.</p>
  
  <p>Here is my minimal CMakeLists.txt</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.7)
  project(WebService)
  
  set (WebService_VERSION_MAJOR 1)
  set (WebService_VERSION_MAJOR 0)
  
  set(CMAKE_CXX_STANDARD 11)
  
  add_executable(${PROJECT_NAME} main.cpp)
  </code></pre>
  
  <p>I understand that there are a few ways to add dependencies in cmake. I have tried doing things like find_package(restbed), but obviously it doesn't know where to find the package I want and keeps asking for extra cmake files to help it. I am not sure where I am supposed to find these. Am I supposed to write one myself?</p>
  
  <p>I have tried using the ExternalProject_Add directive. I added the following.</p>
  
  <pre><code>ExternalProject_Add(
      restbed
      GIT_REPOSITORY "git@github.com:Corvusoft/restbed.git"
      SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps/restbed"
      CMAKE_ARGS -DBUILD_SSL=OFF
      )
  set (restbed_INCLUDE ${CMAKE_SOURCE_DIR}/deps/restbed/distribution/include/)
  set (restbed_LIB ${CMAKE_SOURCE_DIR}/deps/restbed/distribution/library/librestbed.a)
  
  add_dependencies(${PROJECT_NAME} restbed)
  include_directories(${restbed_INCLUDE})
  target_link_libraries(${PROJECT_NAME} ${restbed_LIB})
  </code></pre>
  
  <p>The problem I am having is that apparently all the steps for setting up an external project are performed during the build and not during cmake configuration. This means that every external project rebuilds and reinstalls everything every time I run <code>make</code>. My service is small and this seems very wasteful.</p>
  
  <p>Is there a better way to deal with dependencies? Is there an easier tool than cmake? Is there something for C++ that is similar to Rust's cargo or Haskell's stack maybe?</p>