Draft: use libatomic for linking with onetbb if necessary
Without adding libatomic, the following test project will fail on platforms without native atomics (armel, parisc, sh):
cmake_minimum_required(VERSION 3.16.0)
project(tbbtest)
find_package(TBB REQUIRED)
add_executable(hello hello.cc)
target_link_libraries(hello PRIVATE TBB::tbb)
#include "tbb/parallel_for.h"
#include <iostream>
int main(int,char**) {
tbb::parallel_for(
tbb::blocked_range<size_t>(0,10),
[&](const tbb::blocked_range<size_t>& r) {
for (size_t i=r.begin();i<r.end();++i) std::cout << "hello" << std::endl;
}
);
return 0;
}
[ 50%] Building CXX object CMakeFiles/hello.dir/hello.cc.o
[100%] Linking CXX executable hello
/usr/bin/ld: CMakeFiles/hello.dir/hello.cc.o: undefined reference to symbol '__atomic_fetch_add_8@@LIBATOMIC_1.0'
/usr/bin/ld: /lib/arm-linux-gnueabi/libatomic.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/hello.dir/build.make:98: hello] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/hello.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Bug: https://github.com/uxlfoundation/oneTBB/issues/1454 Closes: #1088922