1- # Copyright 2022-2025 Intel Corporation.
1+ # Copyright (C) 2022-2025 Intel Corporation
22#
3- # This software and the related documents are Intel copyrighted materials, and
4- # your use of them is governed by the express license under which they were
5- # provided to you ("License"). Unless the License provides otherwise, you may
6- # not use, modify, copy, publish, distribute, disclose or transmit this
7- # software or the related documents without Intel's prior written permission.
8- #
9- # This software and the related documents are provided as is, with no express
10- # or implied warranties, other than those that are expressly stated in
11- # the License.
3+ # SPDX-License-Identifier: MIT
124
135include (compiler_source.cmake)
146
@@ -25,54 +17,91 @@ set(NPU_COMPILER_PACKAGE_DIR ${NPU_COMPILER_INSTALL_PREFIX}/cid)
2517
2618include (ExternalProject)
2719
20+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D CMAKE_BUILD_TYPE=Release" )
21+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D CMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} " )
22+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D BUILD_COMPILER_FOR_DRIVER=ON" )
23+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D BUILD_SHARED_LIBS=OFF" )
24+ # CLANG_FORMAT and NCC_STYLE is set to OFF to avoid LLVMDemangle doubled target issue
25+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_CLANG_FORMAT=OFF" )
26+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_CLANG_TIDY=OFF" )
27+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_NCC_STYLE=OFF" )
28+ # Copied from "how_to_build_driver_compiler" document
29+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_AUTO=OFF" )
30+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_AUTO_BATCH=OFF" )
31+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_BLOB_DUMP=OFF" )
32+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_FUNCTIONAL_TESTS=OFF" )
33+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_HETERO=OFF" )
34+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_INTEL_CPU=OFF" )
35+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_INTEL_GPU=OFF" )
36+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_JS=OFF" )
37+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_MULTI=OFF" )
38+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_INTEL_NPU=ON" )
39+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_INTEL_NPU_INTERNAL=OFF" )
40+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_INTEL_NPU_PROTOPIPE=OFF" )
41+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_OV_IR_FRONTEND=ON" )
42+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_OV_JAX_FRONTEND=OFF" )
43+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_OV_ONNX_FRONTEND=OFF" )
44+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_OV_PADDLE_FRONTEND=OFF" )
45+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_OV_PYTORCH_FRONTEND=OFF" )
46+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_OV_TF_FRONTEND=OFF" )
47+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_OV_TF_LITE_FRONTEND=OFF" )
48+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_PROXY=OFF" )
49+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_SAMPLES=OFF" )
50+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_TBBBIND_2_5=OFF" )
51+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_TEMPLATE=OFF" )
52+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ENABLE_TESTS=OFF" )
53+ # WA in case libgflags is installed in system
54+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D gflags_DIR=${CMAKE_CURRENT_SOURCE_DIR} /openvino_modules" )
55+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D OPENVINO_EXTRA_MODULES=${NPU_COMPILER_SOURCE_DIR} " )
56+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D OUTPUT_ROOT=${NPU_COMPILER_BINARY_DIR} " )
57+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D THREADING=${THREADING} " )
58+
59+ if (ANDROID)
60+ # First build native tools required for NPU compiler
61+ set (NPU_COMPILER_NATIVE_TOOLS_BUILD npu_compiler_native_tools_build)
62+ set (NPU_COMPILER_NATIVE_TOOLS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} /build_npu_compiler_native_tools)
63+
64+ ExternalProject_Add(
65+ ${NPU_COMPILER_NATIVE_TOOLS_BUILD}
66+ DOWNLOAD_COMMAND ""
67+ DEPENDS npu_compiler_source ${NPU_COMPILER_BUILD_DEPENDS}
68+ SOURCE_DIR ${NPU_COMPILER_OPENVINO_SOURCE_DIR}
69+ BINARY_DIR ${NPU_COMPILER_NATIVE_TOOLS_BINARY_DIR}
70+ CMAKE_ARGS
71+ ${NPU_COMPILER_CMAKE_ARGS}
72+ BUILD_COMMAND
73+ ${CMAKE_COMMAND}
74+ --build ${NPU_COMPILER_NATIVE_TOOLS_BINARY_DIR}
75+ --target npureg-tblgen mlir-headers mlir-generic-headers mlir-linalg-ods-yaml-gen flatc
76+ --parallel ${PARALLEL_PROCESSES}
77+ INSTALL_COMMAND
78+ mkdir -p ${NPU_COMPILER_BINARY_DIR} /build -modules/npu_compiler/thirdparty/llvm-project/llvm/NATIVE &&
79+ cp -r ${NPU_COMPILER_NATIVE_TOOLS_BINARY_DIR} /build -modules/npu_compiler/thirdparty/llvm-project/llvm/bin ${NPU_COMPILER_BINARY_DIR} /build -modules/npu_compiler/thirdparty/llvm-project/llvm/NATIVE/
80+ BYPRODUCTS
81+ ${NPU_COMPILER_BINARY_DIR} /bin/intel64/Release/flatc
82+ ${NPU_COMPILER_BINARY_DIR} /bin/intel64/Release/npureg-tblgen
83+ )
84+
85+ # Android specific settings
86+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ANDROID_ABI=${ANDROID_ABI} " )
87+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ANDROID_PLATFORM=${ANDROID_PLATFORM} " )
88+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D ANDROID_STL=${ANDROID_STL} " )
89+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D CMAKE_CXX_FLAGS_INIT='-frtti'" )
90+ endif ()
91+
92+ list (APPEND NPU_COMPILER_CMAKE_ARGS "-D CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} " )
93+
2894ExternalProject_Add(
2995 npu_compiler_build
3096 DOWNLOAD_COMMAND ""
31- DEPENDS npu_compiler_source ${NPU_COMPILER_BUILD_DEPENDS}
97+ DEPENDS npu_compiler_source ${NPU_COMPILER_BUILD_DEPENDS} ${NPU_COMPILER_NATIVE_TOOLS_BUILD}
3298 SOURCE_DIR ${NPU_COMPILER_OPENVINO_SOURCE_DIR}
3399 BINARY_DIR ${NPU_COMPILER_BINARY_DIR}
34100 CMAKE_ARGS
35- -D CMAKE_BUILD_TYPE =Release
36- -D CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
37- -D CMAKE_MAKE_PROGRAM =${CMAKE_MAKE_PROGRAM}
38- -D BUILD_COMPILER_FOR_DRIVER=ON
39- -D BUILD_SHARED_LIBS =OFF
40- # CLANG_FORMAT and NCC_STYLE is set to OFF to avoid LLVMDemangle doubled target issue
41- -D ENABLE_CLANG_FORMAT=OFF
42- -D ENABLE_CLANG_TIDY=OFF
43- -D ENABLE_NCC_STYLE=OFF
44- # Copied from "how_to_build_driver_compiler" document
45- -D ENABLE_AUTO=OFF
46- -D ENABLE_AUTO_BATCH=OFF
47- -D ENABLE_BLOB_DUMP=OFF
48- -D ENABLE_FUNCTIONAL_TESTS=OFF
49- -D ENABLE_HETERO=OFF
50- -D ENABLE_INTEL_CPU=OFF
51- -D ENABLE_INTEL_GPU=OFF
52- -D ENABLE_JS=OFF
53- -D ENABLE_MULTI=OFF
54- -D ENABLE_INTEL_NPU_PROTOPIPE=OFF
55- -D ENABLE_OV_IR_FRONTEND=ON
56- -D ENABLE_OV_JAX_FRONTEND=OFF
57- -D ENABLE_OV_ONNX_FRONTEND=OFF
58- -D ENABLE_OV_PADDLE_FRONTEND=OFF
59- -D ENABLE_OV_PYTORCH_FRONTEND=OFF
60- -D ENABLE_OV_TF_FRONTEND=OFF
61- -D ENABLE_OV_TF_LITE_FRONTEND=OFF
62- -D ENABLE_PROXY=OFF
63- -D ENABLE_SAMPLES=OFF
64- -D ENABLE_TBBBIND_2_5=OFF
65- -D ENABLE_TEMPLATE=OFF
66- -D ENABLE_TESTS=OFF
67- # WA in case libgflags is installed in system
68- -D gflags_DIR=${CMAKE_CURRENT_SOURCE_DIR} /openvino_modules
69- -D OPENVINO_EXTRA_MODULES=${NPU_COMPILER_SOURCE_DIR}
70- -D OUTPUT_ROOT=${NPU_COMPILER_BINARY_DIR}
71- -D THREADING=${THREADING}
101+ ${NPU_COMPILER_CMAKE_ARGS}
72102 BUILD_COMMAND
73103 ${CMAKE_COMMAND}
74104 --build ${NPU_COMPILER_BINARY_DIR}
75- --config Release
76105 --target compilerTest profilingTest vpuxCompilerL0Test loaderTest
77106 --parallel ${PARALLEL_PROCESSES}
78107 INSTALL_COMMAND
0 commit comments