Unable to build standalone examples

Hi, I am having some issues building the standalone examples and enabling the python binding following https://github.com/llvm/llvm-project/tree/main/mlir/examples/standalone

Command I use

    -DCMAKE_BUILD_TYPE=Release \
    -DLLVM_TARGETS_TO_BUILD=host \
    -DLLVM_ENABLE_PROJECTS=mlir \
    -DLLVM_EXTERNAL_PROJECTS=standalone-dialect -DLLVM_EXTERNAL_STANDALONE_DIALECT_SOURCE_DIR=../ -DMLIR_ENABLE_BINDINGS_PYTHON=ON

But I am getting some errors like

CMake Error at /Users/xingyuzhou/Downloads/mlir/llvm-project/mlir/cmake/modules/AddMLIRPython.cmake:560 (file):
  file failed to create directory:

    /python_packages/standalone/mlir_standalone/dialects

  because: No such file or directory
Call Stack (most recent call first):
  /Users/xingyuzhou/Downloads/mlir/llvm-project/mlir/cmake/modules/AddMLIRPython.cmake:215 (add_mlir_python_sources_target)
  /Users/xingyuzhou/Downloads/mlir/llvm-project/mlir/cmake/modules/AddMLIRPython.cmake:247 (_process_target)
  /Users/xingyuzhou/Downloads/mlir/llvm-project/mlir/examples/standalone/python/CMakeLists.txt:53 (add_mlir_python_modules)


CMake Error at /Users/xingyuzhou/Downloads/mlir/llvm-project/mlir/cmake/modules/AddMLIRPython.cmake:560 (file):
  file failed to create directory:

    /python_packages/standalone/mlir_standalone/dialects

  because: No such file or directory
Call Stack (most recent call first):
  /Users/xingyuzhou/Downloads/mlir/llvm-project/mlir/cmake/modules/AddMLIRPython.cmake:215 (add_mlir_python_sources_target)
  /Users/xingyuzhou/Downloads/mlir/llvm-project/mlir/cmake/modules/AddMLIRPython.cmake:247 (_process_target)
  /Users/xingyuzhou/Downloads/mlir/llvm-project/mlir/examples/standalone/python/CMakeLists.txt:53 (add_mlir_python_modules)

I am wondering how to fix this and build this example, Thanks!

Afk, but that absolute path is a surefire indication that some CMake variable with a project path is undefined in this case (like an MLIR_MAIN_SRC_DIR) or something. Llvm has a lot of these loose leaf variables and it would take a bit of digging to identify cause and fix. Unless if you know the system well, the flags that enable CMake tracing with variable expansion can give you a dump to grep through and see what was being asked for.

Thanks for your reply! I got it working by adding set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR}) to the section # Build via external projects mechanism