How to run the test suite on macOS?

When building LLVM (trunk) on macOS (where there is no /usr/include/), the resulting Clang works fine for me when I add an appropriate -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk to the command line when invoking Clang. (I'm not sure I'm using it as intended, but that appears to work reasonably well for me.)

However, when I try to run LLVM's test suite with `cmake --build . --target check-all`, that fails with things like

FAILED: projects/compiler-rt/lib/fuzzer/tests/FuzzedDataProviderTestObjects.FuzzedDataProviderUnittest.cpp.x86_64.o cd /Users/stephan/Software/llvm/build/projects/compiler-rt/lib/fuzzer/tests && /Users/stephan/Software/llvm/build/./bin/clang -Wno-covered-switch-default -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -I/Users/stephan/Software/llvm/llvm-project/llvm/utils/unittest/googletest/include -I/Users/stephan/Software/llvm/llvm-project/llvm/utils/unittest/googletest -I/Users/stephan/Software/llvm/llvm-project/compiler-rt/lib/fuzzer -fno-rtti -O2 -fvisibility=hidden -arch x86_64 -c -o FuzzedDataProviderTestObjects.FuzzedDataProviderUnittest.cpp.x86_64.o /Users/stephan/Software/llvm/llvm-project/compiler-rt/lib/fuzzer/tests/FuzzedDataProviderUnittest.cpp
In file included from /Users/stephan/Software/llvm/llvm-project/compiler-rt/lib/fuzzer/tests/FuzzedDataProviderUnittest.cpp:5:
In file included from /Users/stephan/Software/llvm/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:55:
In file included from /Users/stephan/Software/llvm/build/./bin/../include/c++/v1/ostream:138:
In file included from /Users/stephan/Software/llvm/build/./bin/../include/c++/v1/ios:214:
In file included from /Users/stephan/Software/llvm/build/./bin/../include/c++/v1/iosfwd:95:
/Users/stephan/Software/llvm/build/./bin/../include/c++/v1/wchar.h:119:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
              ^~~~~~~~~
1 error generated.

Am I missing anything like setting up an appropriate environment, or passing appropriate values for some cmake -D configuration switches?

You can implicitly set the sysroot by running clang through xcrun (--sdk allows you to choose an SDK), or by setting the SDKROOT environment variable directly.

-- adrian

You can implicitly set the sysroot by running clang through xcrun (--sdk allows you to choose an SDK), or by setting the SDKROOT environment variable directly.

Thanks. I wouldn't know how to tunnel xcrun into that cmake invocation, but setting SDKROOT indeed works.