[DeviceRTL] Fix incremental build
authorYe Luo <yeluo@anl.gov>
Thu, 27 Oct 2022 19:01:18 +0000 (14:01 -0500)
committerYe Luo <yeluo@anl.gov>
Fri, 28 Oct 2022 03:20:17 +0000 (22:20 -0500)
commit0911e57f1db3e5a6053eeb9ca1ff2ea97c5db336
tree51ca3b6394b5d6a5a09dddac51c14d7376c7afb5
parentcf953e34d0e1fa925f2d981b5a1992c62e90a137
[DeviceRTL] Fix incremental build

Need both add_custom_command to resolve file-level dependency and add_custom_target to resolve target-level dependency.
From CMake add_custom_command doc:
Do not list the output in more than one independent target that may build in parallel or the two instances of the rule may conflict (instead use the add_custom_target() command to drive the command and make the other targets depend on that one).

${CMAKE_CURRENT_BINARY_DIR}/${bclib_name} is used by multiple targets and thus requires a custom target to avoid racing.

Differential Revision: https://reviews.llvm.org/D136911
openmp/libomptarget/DeviceRTL/CMakeLists.txt