[CMake][runtimes] Add file level dependency to merge_archives commands
authorMarkus Böck <markus.boeck02@gmail.com>
Thu, 18 Mar 2021 17:51:10 +0000 (18:51 +0100)
committerMarkus Böck <markus.boeck02@gmail.com>
Thu, 18 Mar 2021 17:51:10 +0000 (18:51 +0100)
commit6359049c35042adb34ffe6ba77008613c1436ee1
tree45988909b395696978af204fde68aa3f4ad50959
parenteb37d3546cd0c6e67798496634c45e501f7806f1
[CMake][runtimes] Add file level dependency to merge_archives commands

Both libc++ and libc++abi have options of merging with another archive. In the case of libc++abi, libunwind can be merged into it and in the case of libc++, libc++abi can be merged into it.

This is realized using add_custom_command with POST_BUILD and the usage of the CMake generator expression TARGET_LINKER_FILE in the arguments. For such generator expressions CMake doc states: "This target-level dependency does NOT add a file-level dependency that would cause the custom command to re-run whenever the executable is recompiled" [1]

This patch adds a DEPENDS argument to both add_custom_command invocations so that the archives also have a file-level dependency on the target they are merging with. That way, changes in say, libunwind source code, will be updated in the libc++abi and/or libc++ static libraries as well.

[1] https://cmake.org/cmake/help/v3.20/command/add_custom_command.html

Differential Revision: https://reviews.llvm.org/D98129
libcxx/src/CMakeLists.txt
libcxxabi/src/CMakeLists.txt