Using external project in in-tree project

Hi,

I am working on a downstream MLIR-based project (project1) which lives inside the mlir folder and it is build as part of LLVM_ENABLE_PROJECTS=mlir.

llvm-project
 |- mlir
   |- project1

There is a second MLIR-based project (project2) which was set up using LLVM_EXTERNAL_PROJECTS. Now, I would like to use project2 dialects/passes in project1. But trying to access CMake project2 properties in project1 did not work, for example this returns an empty string in a project1 CMake:

get_property(project2_dialect_libs GLOBAL PROPERTY PROJECT2_DIALECT_LIBS)

The CMake command is something like:

cmake -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_EXTERNAL_PROJECTS=“project2” -DLLVM_EXTERNAL_PROJECT2_SOURCE_DIR=…

And the behavior makes sense, I suppose we do not want in-tree code to depend on out-of-tree code. It seems that I need to refactor/configure project1 as a LLVM_EXTERNAL_PROJECTS. Or is it possible to use project2 (external project) in project1 (in-tree project)? Maybe with some minor changes to the in-tree CMake files.

Thanks for any suggestions/ideas,
Antonio.