Ops.cpp.inc could not link to Ops.h.inc

I built an MLIR project from the Standalone project below the MLIR source. I have defined my Dialect, but I had an error generating the library. Quantumops.cpp.inc is not linked to Quantumops.h.inc, so the compiler cannot find the declaration of the type, such as ExtractQubitOp.


I don’t know what’s going on, I’m an MLIR beginner and I follow the Standalone project structure entirely.
Below is CMakeLists.txt in my root directory.

# CMakeList.txt: 
#
cmake_minimum_required (VERSION 3.10)

if (POLICY CMP0068)
	cmake_policy(SET CMP0068 NEW)
	set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
endif ()

if(POLICY CMP0075)
	cmake_policy(SET CMP0075 NEW)
endif()

if (POLICY CMP0077)
	cmake_policy(SET CMP0077 NEW)
endif ()

project("QMIRDemo")

set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")

find_package(LLVM REQUIRED CONFIG)

message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Found LLVNMConfig.cmake in: ${LLVM_DIR}")

find_package(MLIR REQUIRED CONFIG)

message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")

set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR})

list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(TableGen)
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)

include_directories(${LLVM_INCLUDE_DIRS})
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
add_definitions(${LLVM_DEFINITIONS_LIST})
link_directories(${LLVM_BUILD_LIBRARY_DIR})

include_directories(${MLIR_INCLUDE_DIRS})

include_directories(include/)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)

add_subdirectory(include)

add_subdirectory(dialect)

set(LLVM_COMPONENTS Support)

get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
set(LIBS 
		${dialect_libs} 
		${conversion_libs} 
        MLIROptLib 
		MLIRQuantum 
		MLIRTargetLLVMIR
        MLIRExecutionEngine
        MLIRStandard
        MLIRAffine
        LLVMLinker
		)

add_llvm_executable(qmir main.cpp mlir/MLIRGen.cpp)

llvm_update_compile_flags(qmir)

target_link_libraries(qmir
  PRIVATE
	${LIBS}
    MLIRAnalysis 
    MLIRCallInterfaces 
    MLIRIR
    MLIRParser 
    MLIRPass
    MLIRSideEffectInterfaces
    MLIRTransforms)

Here is CMakeLists.txt in my include folder

add_mlir_dialect(QuantumOps quantum)
add_mlir_doc(QuantumDialect -gen-dialect-doc QuantumDialect Quantum/)
add_mlir_doc(QuantumOps -gen-op-doc QuantumOps Quantum/)

Here is CMakeLists.txt from my Dialect library

add_mlir_dialect_library(MLIRQuantum 
		QuantumDialect.cpp 
		QuantumOps.cpp
		
		ADDITIONAL_HEADER_DIRS 
		${PROJECT_SOURCE_DIR}/include/Quantum 
		
		DEPENDS 
		MLIRQuantumOpsIncGen 
		
		LINK_LIBS PUBLIC 
		MLIRIR
		)

I followed the standalone project entirely to build the project. Standalone project I can build normally. I want to know how do I link correctly

The .inc files are meant to be included in other files. The file that’s including the .cpp.inc file is expected to include your dialect header file (.h) that in turn includes the .h.inc file while defining the GET_OP_CLASSES macro right above the .h.inc include.

+1, they are not self-contained C++ files.