tests/acceptance-tests/CMakeLists.txt: Fix generation of transfer_files & moc_test_harness.cpp
Multiple targets that can be built in parallel depending on the same add_custom_command
OUTPUT
is not parallelism-safe, it can lead to every target invoking the specified COMMAND
and overwriting the OUTPUT
while it's being used somewhere else. CMake documentation warns about this, and instruct us to wrap the add_custom_command
in an add_custom_target
and add dependencies onto this separate target to fix the build order.
This should hopefully¹ fix parallelism-related build issues, like this one from Nixpkgs:
[ 69%] Generating transfer_files
[ 70%] Generating moc_test_harness.cpp
[ 70%] Generating transfer_files
[ 70%] Generating transfer_files
[ 70%] Generating transfer_files
[ 70%] Generating moc_test_harness.cpp
[ 70%] Generating transfer_files
[ 71%] Generating moc_test_harness.cpp
[ 71%] Generating moc_test_harness.cpp
[ 71%] Generating moc_test_harness.cpp
[ 72%] Generating transfer_files
[ 72%] Generating transfer_files
[ 72%] Generating transfer_files
[ 73%] Generating moc_test_harness.cpp
[ 73%] Generating moc_test_harness.cpp
[ 73%] Generating moc_test_harness.cpp
[ 73%] Generating transfer_files
[ 73%] Generating moc_test_harness.cpp
[ 73%] Generating moc_test_harness.cpp
[ 73%] Generating moc_test_harness.cpp
# ...
[ 75%] Generating transfer_files
# ...
[ 76%] Generating transfer_files
# ...
[ 99%] Linking CXX executable app_hub_communication_stores
# ...
/nix/store/nmdqydqrbdz9y8161b9n0xjf7hsp3yy0-binutils-2.40/bin/ld: CMakeFiles/app_hub_communication_stores.dir/app_hub_communication_stores.cpp.o: in function `std::_Function_handler<bool (), Hub_stores_are_reported_correctly_to_clients_Test::TestBody()::{lambda()#2}>::_M_invoke(std::_Any_data const&)':
app_hub_communication_stores.cpp:(.text+0x17d8): undefined reference to `vtable for test::TestHarness'
/nix/store/nmdqydqrbdz9y8161b9n0xjf7hsp3yy0-binutils-2.40/bin/ld: app_hub_communication_stores.cpp:(.text+0x17dc): undefined reference to `vtable for test::TestHarness'
[1]: Flaky so not 100% certain that it's the issue, but it seems likely to me.