cmake: targets against legacy-option-headers when appropriate
legacy-option-headers provides the headers included by
`src/common/options/legacy_config_opts.h`. these headers are generated from
corresponding .yaml.in file. because these headers file are generated at
build time, we need to construct the file-level dependencies between the
targets using them and these headers, otherwise the compiler could fail
to compile the tree if any of the headers are not generated yet, when
compiling .cc file which (indirectly) includes it.
in order to address this, in this change, we
1. search for all .cc files which have `#include "common/config.h"` in it
2. and find out the targets building the .cc file, then
3. add `legacy-option-headers` to its linkage using CMake
this should partially address the above race condition we've been running
into on slow build hosts.
because we have not audited the .h files including `common/config.h`,
this change should be considered a partial fix.