1+ # Copyright (C) 2018-2025 Intel Corporation
2+ # SPDX-License-Identifier: Apache-2.0
3+ #
4+
5+ # Function to download and extract files
6+ function (download_and_extract url zip_file extracted_dir modify_proxy)
7+ # Check if the prebuilt VCL compiler libraries not exist
8+ if (NOT EXISTS "${extracted_dir} " )
9+ if (modify_proxy STREQUAL "MODIFY" )
10+ # Update proxy to enable download for windows url
11+ set (original_NO_PROXY $ENV{NO_PROXY} )
12+ set (original_no_proxy $ENV{no_proxy} )
13+ set (ENV{NO_PROXY} "" )
14+ set (ENV{no_proxy} "" )
15+ endif ()
16+
17+ # Download the prebuilt VCL compiler libraries, if failure, show error message and exit
18+ message (STATUS "Downloading prebuilt VCL compiler libraries from ${url} " )
19+ file (DOWNLOAD "${url} " "${zip_file} "
20+ TIMEOUT 3600
21+ LOG log_output
22+ STATUS download_status
23+ SHOW_PROGRESS )
24+
25+ if (modify_proxy STREQUAL "MODIFY" )
26+ # Restore proxy
27+ set (ENV{NO_PROXY} ${original_NO_PROXY} )
28+ set (ENV{no_proxy} ${original_no_proxy} )
29+ endif ()
30+
31+ list (GET download_status 0 download_result)
32+ if (NOT download_result EQUAL 0)
33+ message (FATAL_ERROR "Download failed!\n Status: ${download_status} \n Log: ${log_output} " )
34+ else ()
35+ message (STATUS "Download completed: ${zip_file} " )
36+ endif ()
37+
38+ message (STATUS "Unzipping prebuilt VCL compiler libraries to ${extracted_dir} " )
39+ # Determine extraction method based on file extension
40+ if ("${zip_file} " MATCHES "\\ .zip$" )
41+ file (ARCHIVE_EXTRACT INPUT "${zip_file} " DESTINATION "${extracted_dir} " )
42+ elseif ("${zip_file} " MATCHES "\\ .tar.gz$" )
43+ if (NOT EXISTS "${extracted_dir} " )
44+ file (MAKE_DIRECTORY "${extracted_dir} " )
45+ message (STATUS "Directory ${extracted_dir} created to unzip." )
46+ endif ()
47+ execute_process (COMMAND tar -xzf "${zip_file} " -C "${extracted_dir} " )
48+ elseif ("${zip_file} " MATCHES "\\ .deb$" )
49+ execute_process (COMMAND dpkg-deb -x "${zip_file} " "${extracted_dir} " )
50+ elseif ("${zip_file} " MATCHES "\\ .exe$" )
51+ set (WINRAR_PATHS
52+ "C:/Program Files/WinRAR"
53+ "C:/Program Files (x86)/WinRAR"
54+ )
55+
56+ set (WINRAR_FOUND FALSE )
57+ set (WINRAR_EXECUTABLE "" )
58+
59+ foreach (PATH ${WINRAR_PATHS} )
60+ if (EXISTS "${PATH} /WinRAR.exe" )
61+ set (WINRAR_FOUND TRUE )
62+ set (WINRAR_EXECUTABLE "${PATH} /WinRAR.exe" )
63+ break ()
64+ endif ()
65+ endforeach ()
66+
67+ if (WINRAR_FOUND)
68+ message (STATUS "WinRAR found at: ${WINRAR_EXECUTABLE} and extract ${zip_file} to ${extracted_dir} " )
69+ file (MAKE_DIRECTORY "${extracted_dir} " )
70+ execute_process (
71+ COMMAND "${WINRAR_EXECUTABLE} " x -y -o+ "${zip_file} " "${extracted_dir} "
72+ RESULT_VARIABLE result
73+ OUTPUT_VARIABLE output
74+ ERROR_VARIABLE error
75+ )
76+
77+ if (result EQUAL 0)
78+ message (STATUS "Extraction successful: ${output} " )
79+ else ()
80+ #file(REMOVE_RECURSE "${extracted_dir}")
81+ message (STATUS "Extraction failed: ${error} " )
82+ endif ()
83+ else ()
84+ message (FATAL_ERROR "WinRAR not found. Please install WinRAR to proceed." )
85+ endif ()
86+ else ()
87+ message (FATAL_ERROR "Unsupported file extension for extraction: ${zip_file} " )
88+ endif ()
89+ file (REMOVE "${zip_file} " )
90+ else ()
91+ message (STATUS "Prebuilt VCL compiler libraries already exist, skip download" )
92+ endif ()
93+ endfunction ()
94+
95+ if (ENABLE_VCL_FOR_COMPILER)
96+ if (ENABLE_SYSTEM_NPU_VCL_COMPILER)
97+ message (STATUS "Using system NPU VCL compiler libraries, skip download" )
98+ else ()
99+ message (STATUS "Downloading prebuilt NPU VCL compiler libraries" )
100+ if (WIN32 )
101+ set (VCL_COMPILER_LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR} /temp/vcl_compiler_lib/win" )
102+ set (VCL_COMPILER_LIBS_URL "https://github.com/openvinotoolkit/npu_compiler/releases/download/npu_ud_2025_38_rc4/w_vpux_compiler_l0_win-7_4_3-Release_dyntbb_postcommit_cid_a826bd92b5e02af092e4d706a762252b1845f777_251010_2218.zip" )
103+ set (VCL_COMPILER_LIBS_ZIP "${VCL_COMPILER_LIBS_DIR} /w_vpux_compiler_l0_win-7_4_3-Release_dyntbb_postcommit_cid_a826bd92b5e02af092e4d706a762252b1845f777_251010_2218.zip" )
104+ set (VCL_COMPILER_LIBS_DIR_UNZIPPED "${VCL_COMPILER_LIBS_DIR} /cid_a826bd92b5e02af092e4d706a762252b1845f777_251010_2218" )
105+
106+ download_and_extract("${VCL_COMPILER_LIBS_URL} " "${VCL_COMPILER_LIBS_ZIP} " "${VCL_COMPILER_LIBS_DIR_UNZIPPED} " "MODIFY" )
107+ set (VCL_COMPILER_LIB_PATH "${VCL_COMPILER_LIBS_DIR_UNZIPPED} /cid/lib" )
108+
109+ configure_file (
110+ ${VCL_COMPILER_LIB_PATH} /npu_driver_compiler.dll
111+ ${VCL_COMPILER_LIB_PATH} /openvino_intel_npu_compiler.dll
112+ COPYONLY
113+ )
114+ set (VCL_COMPILER_LIB "${VCL_COMPILER_LIB_PATH} /openvino_intel_npu_compiler.dll" )
115+ file (COPY "${VCL_COMPILER_LIB} "
116+ DESTINATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY} /${CMAKE_BUILD_TYPE} " )
117+ message (STATUS "Not Copying prebuilt VCL compiler libraries openvino_intel_npu_compiler.dll to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} for windows" )
118+ else ()
119+ # Check if the operating system is Linux and not macOS
120+ if (UNIX AND NOT APPLE )
121+ # Get the OS name and version
122+ execute_process (COMMAND lsb_release -is OUTPUT_VARIABLE OS_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
123+ execute_process (COMMAND lsb_release -rs OUTPUT_VARIABLE OS_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
124+
125+ if (OS_NAME STREQUAL "Ubuntu" )
126+ if (OS_VERSION STREQUAL "22.04" )
127+ # Ubuntu 22.04-specific settings or actions
128+ set (VCL_COMPILER_LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR} /temp/vcl_compiler_libs/ubuntu22.04" )
129+ set (VCL_COMPILER_LIBS_URL "https://github.com/intel/linux-npu-driver/releases/download/v1.19.0/intel-driver-compiler-npu_1.19.0.20250707-16111289554_ubuntu22.04_amd64.deb" )
130+ set (VCL_COMPILER_LIBS_DEB "${VCL_COMPILER_LIBS_DIR} /intel-driver-compiler-npu_1.19.0.20250707-16111289554_ubuntu22.04_amd64.deb" )
131+ set (VCL_COMPILER_LIBS_DIR_EXTRACTED "${VCL_COMPILER_LIBS_DIR} /prebuilt_VCL_libs_from_1.19.0.20250707-16111289554_ubuntu22.04" )
132+
133+ download_and_extract("${VCL_COMPILER_LIBS_URL} " "${VCL_COMPILER_LIBS_DEB} " "${VCL_COMPILER_LIBS_DIR_EXTRACTED} " "NONE" )
134+
135+ set (VCL_COMPILER_LIB_PATH "${VCL_COMPILER_LIBS_DIR_EXTRACTED} /usr/lib/x86_64-linux-gnu" )
136+ configure_file (
137+ ${VCL_COMPILER_LIB_PATH} /libnpu_driver_compiler.so
138+ ${VCL_COMPILER_LIB_PATH} /libopenvino_intel_npu_compiler.so
139+ COPYONLY
140+ )
141+ set (VCL_COMPILER_LIB "${VCL_COMPILER_LIB_PATH} /libopenvino_intel_npu_compiler.so" )
142+ file (COPY "${VCL_COMPILER_LIB} "
143+ DESTINATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY} " )
144+ message (STATUS "Not Copying prebuilt VCL compiler libraries libopenvino_intel_npu_compiler.so to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} for Ubuntu 22.04" )
145+ elseif (OS_VERSION STREQUAL "24.04" )
146+ message (STATUS "This is Ubuntu 24.04" )
147+ # Ubuntu 24.04-specific settings or actions
148+ set (VCL_COMPILER_LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR} /temp/vcl_compiler_libs/ubuntu24.04" )
149+ set (VCL_COMPILER_LIBS_URL "https://github.com/intel/linux-npu-driver/releases/download/v1.19.0/intel-driver-compiler-npu_1.19.0.20250707-16111289554_ubuntu24.04_amd64.deb" )
150+ set (VCL_COMPILER_LIBS_DEB "${VCL_COMPILER_LIBS_DIR} /intel-driver-compiler-npu_1.19.0.20250707-16111289554_ubuntu24.04_amd64.deb" )
151+ set (VCL_COMPILER_LIBS_DIR_EXTRACTED "${VCL_COMPILER_LIBS_DIR} /prebuilt_VCL_libs_from_1.19.0.20250707-16111289554_ubuntu24.04" )
152+
153+ download_and_extract("${VCL_COMPILER_LIBS_URL} " "${VCL_COMPILER_LIBS_DEB} " "${VCL_COMPILER_LIBS_DIR_EXTRACTED} " "NONE" )
154+
155+ set (VCL_COMPILER_LIB_PATH "${VCL_COMPILER_LIBS_DIR_EXTRACTED} /usr/lib/x86_64-linux-gnu" )
156+ configure_file (
157+ ${VCL_COMPILER_LIB_PATH} /libnpu_driver_compiler.so
158+ ${VCL_COMPILER_LIB_PATH} /libopenvino_intel_npu_compiler.so
159+ COPYONLY
160+ )
161+ set (VCL_COMPILER_LIB "${VCL_COMPILER_LIB_PATH} /libopenvino_intel_npu_compiler.so" )
162+ # file(COPY "${VCL_COMPILER_LIB}"
163+ # DESTINATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
164+ message (STATUS "Copying prebuilt VCL compiler libraries libopenvino_intel_npu_compiler.so to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} for Ubuntu 24.04" )
165+ else ()
166+ message (STATUS "This is another version of Ubuntu: ${OS_VERSION} " )
167+ # Other Ubuntu-specific settings or actions
168+ endif ()
169+ else ()
170+ message (STATUS "This is a different Linux distribution: ${OS_NAME} , skip downloading prebuilt VCL compiler libraries" )
171+ # Other Linux-specific settings or actions
172+ endif ()
173+ endif ()
174+ endif ()
175+ endif ()
176+
177+ install (FILES ${VCL_COMPILER_LIB}
178+ DESTINATION ${OV_CPACK_RUNTIMEDIR} COMPONENT ${NPU_INTERNAL_COMPONENT} )
179+ endif ()
0 commit comments