[CMake] Add compiler-rt header files to the list of sources for targets
authorDan Liew <dan@su-root.co.uk>
Tue, 10 Jul 2018 13:00:17 +0000 (13:00 +0000)
committerDan Liew <dan@su-root.co.uk>
Tue, 10 Jul 2018 13:00:17 +0000 (13:00 +0000)
commitb1f95697c10e84da63b952baf3020d2e149e6d6a
tree74c8f40101ae529a7f8191d4b05fe356dc6d52de
parentc052451a02c30b5335a72d29e7dc16aef98f7e23
[CMake] Add compiler-rt header files to the list of sources for targets
when building with an IDE so that header files show up in the UI.
This massively improves the development workflow in IDEs.

To implement this a new function `compiler_rt_process_sources(...)` has
been added that adds header files to the list of sources when the
generator is an IDE. For non-IDE generators (e.g. Ninja/Makefile) no
changes are made to the list of source files.

The function can be passed a list of headers via the
`ADDITIONAL_HEADERS` argument. For each runtime library a list of
explicit header files has been added and passed via
`ADDITIONAL_HEADERS`. For `tsan` and `sanitizer_common` a list of
headers was already present but it was stale and has been updated
to reflect the current state of the source tree.

The original version of this patch used file globbing (`*.{h,inc,def}`)
to find the headers but the approach was changed due to this being a
CMake anti-pattern (if the list of headers changes CMake won't
automatically re-generate if globbing is used).

The LLVM repo contains a similar function named `llvm_process_sources()`
but we don't use it here for several reasons:

* It depends on the `LLVM_ENABLE_OPTION` cache variable which is
  not set in standalone compiler-rt builds.
* We would have to `include(LLVMProcessSources)` which I'd like to
  avoid because it would include a bunch of stuff we don't need.

Differential Revision: https://reviews.llvm.org/D48422

llvm-svn: 336663
17 files changed:
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/cmake/Modules/CompilerRTUtils.cmake
compiler-rt/lib/asan/CMakeLists.txt
compiler-rt/lib/dfsan/CMakeLists.txt
compiler-rt/lib/esan/CMakeLists.txt
compiler-rt/lib/fuzzer/CMakeLists.txt
compiler-rt/lib/hwasan/CMakeLists.txt
compiler-rt/lib/interception/CMakeLists.txt
compiler-rt/lib/lsan/CMakeLists.txt
compiler-rt/lib/msan/CMakeLists.txt
compiler-rt/lib/profile/CMakeLists.txt
compiler-rt/lib/sanitizer_common/CMakeLists.txt
compiler-rt/lib/scudo/CMakeLists.txt
compiler-rt/lib/stats/CMakeLists.txt
compiler-rt/lib/tsan/CMakeLists.txt
compiler-rt/lib/ubsan/CMakeLists.txt
compiler-rt/lib/xray/CMakeLists.txt