title: GCC, CMake, precompiled headers and maintaining dependencies
body: <p>I'm trying to figure out how to maintain dependencies of my precompiled headers. It includes <code>STL</code> headers, some third-parties like <code>boost</code> and some of our rarely changing infrastructure headers.    </p>
  
  <p>I came out with something like this</p>
  
  <pre><code>SET(PCH_DIR ${CMAKE_CURRENT_BINARY_DIR})
  SET(PCH_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/../include/server/server.h)
  SET(PCH_DST server.h.gch)
  ADD_CUSTOM_TARGET(serverPCH DEPENDS ${PCH_DST})
  ADD_CUSTOM_COMMAND(OUTPUT ${PCH_DST} ${PCH_DEP}
                     COMMAND ${CMAKE_CXX_COMPILER} -x c++-header ${COMMON_CXXFLAGS} ${COMPILER_DEFINITIONS} -std=gnu++1z -c ${PCH_HEADER} -o ${PCH_DST} -I${CMAKE_SOURCE_DIR}/lib/include/server -I${CMAKE_SOURCE_DIR}/lib/include
                     MAIN_DEPENDENCY ${PCH_HEADER}
                     WORKING_DIRECTORY ${PCH_DIR}
                     COMMENT "Building precompiled header"
                     VERBATIM)
  </code></pre>
  
  <p>Looks like its doing its job and it gets recompiled once the header is edited. However, PCH recompilation is not triggered when one of files included in <code>server.h</code> is changed. Is there a way to trigger re-compilation if any of headers included in <code>server.h</code> is changed?</p>