windows builds using msys2 - threading issues

Hi,
Moving some long running work to discourse after discussion with @dzenanz

My question is how to enable TBB under msys2. Detailed context below.

The error I see when enabling the TBB module is about the location of TBBConfig.cmake.

The tbb libraries appear to be installed according pacman (package names is mingw-w64-x86_64-intel-tbb).

Any clues as to what else I need to install?

Context:
My long term goal is to get the SimpleITK R package working under windows. R for windows is moving to a build and configuration system based around msys2. The package that can be used to build R and addon packages is rtools40. The compiler versions in use are gcc 8.3. It is possible to get access to upstream msys2 packages via a tweak to the config file.

These tools are able to build the simpleitk R package, however the tests fail because R doesn’t exit after running any ITK filters. Further investigations show that the ITK tests intermittently timeout, but pass if I set the threadcount to 1. Unfortunately the same trick doesn’t stop R freezing.

Thus I’m playing with various thread configurations to see if any work out of the box.

PR991 and links in it might be of interest.