Index: mlir/CMakeLists.txt =================================================================== --- mlir/CMakeLists.txt +++ mlir/CMakeLists.txt @@ -97,8 +97,10 @@ add_definitions(-DMLIR_CUDA_CONVERSIONS_ENABLED=${MLIR_ENABLE_CUDA_CONVERSIONS}) # Build the ROCm conversions and run according tests if the AMDGPU backend -# is available -if ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD) +# is available. We also require the native target, as MLIRExecutionEngine will +# not be built otherwise. +if ("AMDGPU" IN_LIST LLVM_TARGETS_TO_BUILD AND + ${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD) set(MLIR_ENABLE_ROCM_CONVERSIONS 1) else() set(MLIR_ENABLE_ROCM_CONVERSIONS 0) Index: mlir/lib/CAPI/CMakeLists.txt =================================================================== --- mlir/lib/CAPI/CMakeLists.txt +++ mlir/lib/CAPI/CMakeLists.txt @@ -16,7 +16,7 @@ add_subdirectory(Transforms) # Only enable the ExecutionEngine if the native target is configured in. -if(TARGET ${LLVM_NATIVE_ARCH}) +if (${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD) add_subdirectory(ExecutionEngine) endif() Index: mlir/lib/ExecutionEngine/CMakeLists.txt =================================================================== --- mlir/lib/ExecutionEngine/CMakeLists.txt +++ mlir/lib/ExecutionEngine/CMakeLists.txt @@ -40,7 +40,7 @@ ) # Only enable the ExecutionEngine if the native target is configured in. -if(NOT TARGET ${LLVM_NATIVE_ARCH}) +if (NOT ${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD) return() endif() Index: mlir/python/CMakeLists.txt =================================================================== --- mlir/python/CMakeLists.txt +++ mlir/python/CMakeLists.txt @@ -364,7 +364,7 @@ ) # Only enable the ExecutionEngine if the native target is configured in. -if(TARGET ${LLVM_NATIVE_ARCH}) +if (${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD) declare_mlir_python_extension(MLIRPythonExtension.ExecutionEngine MODULE_NAME _mlirExecutionEngine ADD_TO_PARENT MLIRPythonSources.ExecutionEngine Index: mlir/test/CAPI/CMakeLists.txt =================================================================== --- mlir/test/CAPI/CMakeLists.txt +++ mlir/test/CAPI/CMakeLists.txt @@ -20,7 +20,7 @@ endfunction(_add_capi_test_executable) # Only enable the ExecutionEngine if the native target is configured in. -if(TARGET ${LLVM_NATIVE_ARCH}) +if (${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD) _add_capi_test_executable(mlir-capi-execution-engine-test execution_engine.c LINK_LIBS PRIVATE Index: mlir/test/CMakeLists.txt =================================================================== --- mlir/test/CMakeLists.txt +++ mlir/test/CMakeLists.txt @@ -40,7 +40,7 @@ # The native target may not be enabled when cross compiling, raise an error. - if(NOT TARGET ${LLVM_NATIVE_ARCH}) + if (NOT ${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD) message(FATAL_ERROR "MLIR_INCLUDE_INTEGRATION_TESTS requires a native target") endif() Index: mlir/tools/CMakeLists.txt =================================================================== --- mlir/tools/CMakeLists.txt +++ mlir/tools/CMakeLists.txt @@ -11,6 +11,6 @@ # mlir-cpu-runner requires ExecutionEngine which is only built # when the native target is configured in. -if(TARGET ${LLVM_NATIVE_ARCH}) +if (${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD) add_subdirectory(mlir-cpu-runner) endif() Index: mlir/unittests/CMakeLists.txt =================================================================== --- mlir/unittests/CMakeLists.txt +++ mlir/unittests/CMakeLists.txt @@ -17,6 +17,6 @@ add_subdirectory(Transforms) # The native target may not be enabled when cross compiling. -if(TARGET ${LLVM_NATIVE_ARCH}) +if (${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD) add_subdirectory(ExecutionEngine) endif()