diff --git a/cmake/scripts/std_modulemap_darwin_fix.py b/cmake/scripts/std_modulemap_darwin_fix.py index b29a20fd9d2bb..bfa322003039b 100644 --- a/cmake/scripts/std_modulemap_darwin_fix.py +++ b/cmake/scripts/std_modulemap_darwin_fix.py @@ -25,6 +25,13 @@ def main(): output_path = sys.argv[1] sdk = get_sdk_path() cpp_modulemap = os.path.join(sdk, "usr/include/c++/v1/module.modulemap") + if not os.path.exists(cpp_modulemap): + # Try again if we are running a conda build. conda-forge ships the MacOS SDK stripped of libc++. + # Instead, the standard libraries are shipped as a separate package which must be declared as a build + # dependency and thus ends up in the $BUILD_PREFIX path. For explanation, see + # https://conda-forge.zulipchat.com/#narrow/channel/516932-compilers/topic/Organisation.20of.20libc.2B.2B.20and.20SDKs.20on.20MacOS + if (os.environ.get("CONDA_BUILD", "0") == "1") and (os.environ.get("BUILD_PREFIX", None) is not None): + cpp_modulemap = os.path.join(os.environ["BUILD_PREFIX"], "include/c++/v1/module.modulemap") if not os.path.exists(cpp_modulemap): raise FileNotFoundError(f"Cannot find libc++ modulemap at {cpp_modulemap}")