title: How to clone specific submodules from Boost using cmake
body: <p>I know how to install Boost with the <code>b2</code> command and specify only to install the filesystem library. The Boost directory has many contents that I won't need, and it takes a long time to clone all submodules. I have this cmake file to download, build and install Boost. But I don't know how to specify which submodules I want to clone in the <code>CMakeLists.txt</code>. I'm using <code>ExternalProject_add</code> to download, build, and install Boost.</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8)
  include(ExternalProject)
  # Download boost from git
  
  SET (BOOST_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/boost/src/boost/lib/filesystem/include/boost/)
  SET (BOOST_URL https://github.com/boostorg/boost.git )
  get_filename_component(BOOST_STATIC_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/lib/libboost_filesystem.a ABSOLUTE)
  
  if ( UNIX )     
      SET (BOOST_STATIC_LIBRARIES ${BOOST_BUILD}/libboost_filesystem.a) 
  endif ()
  
  ExternalProject_Add(
  boost
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/boost
  GIT_REPOSITORY ${BOOST_URL}
  
  UPDATE_COMMAND ./bootstrap.sh --with-libraries=filesystem,system 
  CONFIGURE_COMMAND ""
  BUILD_COMMAND ./b2 link=static install --exec-prefix=${CMAKE_BINARY_DIR}/lib/ --includedir=${CMAKE_BINARY_DIR}/include/boost/
  BUILD_IN_SOURCE 1
  INSTALL_COMMAND ""
  )
  
  set(BOOST_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/lib)
  message ("${BOOST_STATIC_LIBRARIES}")
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>I now have the following <code>CMakeLists.txt</code> file:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8)
  include(ExternalProject)
  # Download boost from git
  SET (BOOST_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/boost/src/boost/lib/filesystem/include/boost/)
  SET (BOOST_URL https://github.com/boostorg/boost.git )
  get_filename_component(BOOST_STATIC_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/lib/libboost_filesystem.a ABSOLUTE)
  
  if ( UNIX )     
      SET (BOOST_STATIC_LIBRARIES ${BOOST_BUILD}/libboost_filesystem.a) 
  endif ()
  
  ExternalProject_Add(
  boost
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/boost
  GIT_REPOSITORY ${BOOST_URL}
  GIT_SUBMODULES libs/assert libs/utility libs/config libs/predef libs/system libs/detail libs/filesystem  tools/boostdep tools/build tools/bcp tools/boostbook tools/inspect tools/litre tools/quickbook tools/auto_index
  UPDATE_COMMAND ./bootstrap.sh --with-libraries=filesystem,system 
  CONFIGURE_COMMAND ./b2 headers
  BUILD_COMMAND ./b2 link=static install
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/lib
  BUILD_IN_SOURCE 1
  INSTALL_COMMAND ""
  )
  
  set(BOOST_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/lib)
  message ("${BOOST_STATIC_LIBRARIES}")
  </code></pre>
  
  <p>But I get this error message:</p>
  
  <pre><code>...patience...
  ...found 925 targets...
  ...updating 337 targets...
  common.mkdir /usr/local/include/boost
  mkdir: Unable to create directory "/usr/local/include/boost": Permission denied.
  
      mkdir -p "/usr/local/include/boost"
  
  ...failed common.mkdir /usr/local/include/boost...
  </code></pre>
  
  <p>But in the cmake file I use this:</p>
  
  <pre><code>CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/lib
  </code></pre>
  
  <p>To install in a different directory than root.
  But it does not seem to be working.</p>
  
  <hr>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>I got how to install in a different directory than root. But it seems that has another problem, because the same problem than before happens. What can I do?</p>
  
  <p>I added this:</p>
  
  <pre><code>UPDATE_COMMAND ./bootstrap.sh --with-libraries=filesystem,system --includedir=${CMAKE_BINARY_DIR}/include/
  
  
  cmake_minimum_required(VERSION 2.8)
  include(ExternalProject)
  # Download boost from git
  SET (BOOST_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/boost/src/boost/lib/filesystem/include/boost/)
  SET (BOOST_URL https://github.com/boostorg/boost.git )
  get_filename_component(BOOST_STATIC_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/lib/libboost_filesystem.a ABSOLUTE)
  
  if ( UNIX )     
      SET (BOOST_STATIC_LIBRARIES ${BOOST_BUILD}/libboost_filesystem.a) 
  endif ()
  
  ExternalProject_Add(
  boost
  PREFIX ${CMAKE_CURRENT_BINARY_DIR}/boost
  GIT_REPOSITORY ${BOOST_URL}
  GIT_SUBMODULES libs/assert libs/utility libs/config libs/predef libs/system libs/detail libs/filesystem  tools/boostdep tools/build tools/bcp tools/boostbook tools/inspect tools/litre tools/quickbook tools/auto_index
  UPDATE_COMMAND ./bootstrap.sh --with-libraries=filesystem,system --includedir=${CMAKE_BINARY_DIR}/include/
  CONFIGURE_COMMAND ./b2 headers
  BUILD_COMMAND ./b2 link=static install
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/lib
  BUILD_IN_SOURCE 1
  INSTALL_COMMAND ""
  )
  
  set(BOOST_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/lib)
  message ("${BOOST_STATIC_LIBRARIES}")
  </code></pre>