Skip to content

Commit ea92cfe

Browse files
authored
SDK Installer For Windows (#295)
- Added Support for building the Level Zero Windows SDK as an MSI installer using WIX - Enabled thru CPACK and the define BUILD_INSTALLER=1 - includes a packaged script level_zero_sdk_setup.ps1 enabling for customers to change the sdk being used after installation - installers support side-by-side installation of multiple versions of SDKs - LEVEL_ZERO_V1_SDK_PATH is set in the System Environment variables upon installation such that the path to the last installed SDK can be found. The active SDK can be changed using level_zero_sdk_setup.ps1 after installation. - added new msi installer workflow Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
1 parent e1c7124 commit ea92cfe

12 files changed

Lines changed: 223 additions & 17 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
on:
2+
push:
3+
branches: [ master ]
4+
pull_request:
5+
branches: [ master ]
6+
workflow_dispatch:
7+
8+
permissions: read-all
9+
10+
jobs:
11+
build-windows:
12+
if: github.repository_owner == 'oneapi-src'
13+
runs-on: [windows-latest]
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Build Loader on Latest Windows
17+
run: |
18+
mkdir build
19+
cd build
20+
cmake -D BUILD_INSTALLER=1 ..
21+
cmake --build . --config Release --target package

CMakeLists.txt

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,23 +224,29 @@ string(SUBSTRING "${os_name}" 0 1 os_name)
224224

225225
file(GLOB LEVEL_ZERO_API_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
226226

227+
set(SDK_COMPONENT_STRING "level-zero-devel")
228+
229+
if(BUILD_INSTALLER)
230+
set(SDK_COMPONENT_STRING "SDK")
231+
endif()
232+
227233
install(FILES ${LEVEL_ZERO_API_HEADERS}
228234
DESTINATION ./include/level_zero
229-
COMPONENT level-zero-devel
235+
COMPONENT ${SDK_COMPONENT_STRING}
230236
)
231237

232238
file(GLOB LEVEL_ZERO_LAYERS_API_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/layers/*.h")
233239

234240
install(FILES ${LEVEL_ZERO_LAYERS_API_HEADERS}
235241
DESTINATION ./include/level_zero/layers
236-
COMPONENT level-zero-devel
242+
COMPONENT ${SDK_COMPONENT_STRING}
237243
)
238244

239245
file(GLOB LEVEL_ZERO_LOADER_API_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/loader/*.h")
240246

241247
install(FILES ${LEVEL_ZERO_LOADER_API_HEADERS}
242248
DESTINATION ./include/level_zero/loader
243-
COMPONENT level-zero-devel
249+
COMPONENT ${SDK_COMPONENT_STRING}
244250
)
245251

246252
# If generators list was not define build native package for current distro
@@ -251,6 +257,59 @@ if(NOT DEFINED CPACK_GENERATOR)
251257
set(CPACK_GENERATOR "RPM")
252258
elseif(EXISTS "/etc/SUSE-brand" OR EXISTS "/etc/SUSE-release" OR sles_distro)
253259
set(CPACK_GENERATOR "RPM")
260+
elseif(BUILD_INSTALLER)
261+
set(PRODUCT_GUID_FILE "${CMAKE_SOURCE_DIR}/PRODUCT_GUID.txt")
262+
if(EXISTS "${PRODUCT_GUID_FILE}")
263+
file(STRINGS "${PRODUCT_GUID_FILE}" SAVED_PRODUCT_GUID)
264+
list(GET SAVED_PRODUCT_GUID 0 SAVED_PRODUCT_GUID_VERSION)
265+
message(STATUS "Saved Product GUID: ${SAVED_PRODUCT_GUID_VERSION}")
266+
message(STATUS "project version: ${PROJECT_VERSION}")
267+
if(NOT SAVED_PRODUCT_GUID_VERSION STREQUAL "${PROJECT_VERSION}")
268+
269+
execute_process(
270+
COMMAND python ${CMAKE_SOURCE_DIR}/scripts/generate_wix_guid.py
271+
OUTPUT_VARIABLE GENERATED_PRODUCT_GUID
272+
OUTPUT_STRIP_TRAILING_WHITESPACE
273+
)
274+
file(WRITE "${PRODUCT_GUID_FILE}" "${PROJECT_VERSION}\n${GENERATED_PRODUCT_GUID}")
275+
message(STATUS "Generated Product GUID: ${GENERATED_PRODUCT_GUID} for version ${PROJECT_VERSION}")
276+
else()
277+
string(REPLACE "\n" ";" GUID_CONTENTS "${SAVED_PRODUCT_GUID}")
278+
list(GET GUID_CONTENTS 1 GENERATED_PRODUCT_GUID)
279+
endif()
280+
else()
281+
execute_process(
282+
COMMAND python ${CMAKE_SOURCE_DIR}/scripts/generate_wix_guid.py
283+
OUTPUT_VARIABLE GENERATED_PRODUCT_GUID
284+
OUTPUT_STRIP_TRAILING_WHITESPACE
285+
)
286+
file(WRITE "${PRODUCT_GUID_FILE}" "${PROJECT_VERSION}\n${GENERATED_PRODUCT_GUID}")
287+
endif()
288+
message(STATUS "Using Product GUID: ${GENERATED_PRODUCT_GUID} for version ${PROJECT_VERSION}")
289+
set(CPACK_GENERATOR "WIX")
290+
set(CPACK_PACKAGE_NAME "oneAPI Level Zero")
291+
set(CPACK_PACKAGE_FILE_NAME "oneAPI_Level_Zero-${PROJECT_VERSION}-win64")
292+
set(CPACK_WIX_ROOT_FEATURE_TITLE "oneAPI Level Zero")
293+
set(CPACK_WIX_PROGRAM_MENU_FOLDER "oneAPI Level Zero")
294+
295+
set(CMAKE_INSTALL_PREFIX "LevelZeroSDK/${PROJECT_VERSION}/")
296+
# Add the script to the install directory
297+
install(FILES "${CMAKE_SOURCE_DIR}/scripts/level_zero_sdk_setup.ps1"
298+
DESTINATION ./scripts
299+
COMPONENT ${SDK_COMPONENT_STRING}
300+
)
301+
302+
set(CPACK_WIX_PATCH_FILE "${CMAKE_SOURCE_DIR}/scripts/wix_env_installation.wxs")
303+
304+
# sharing GUIDs between product and upgrade codes such that side by side installation is allowed.
305+
set(CPACK_WIX_PRODUCT_GUID ${GENERATED_PRODUCT_GUID})
306+
set(CPACK_WIX_UPGRADE_GUID ${GENERATED_PRODUCT_GUID})
307+
set(CPACK_WIX_UI_DIALOG "${CMAKE_SOURCE_DIR}/icons/oneapi-icon-left-aligned.png")
308+
set(CPACK_WIX_UI_BANNER "${CMAKE_SOURCE_DIR}/icons/oneapi-icon-right-aligned.png")
309+
set(CPACK_WIX_SKIP_PROGRAM_FOLDER ON)
310+
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
311+
list(REMOVE_ITEM CPACK_COMPONENTS_ALL "Loader")
312+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSES/MIT.txt")
254313
else()
255314
set(CPACK_GENERATOR "ZIP")
256315
endif()

LICENSES/MIT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (C) 2019-2021 Intel Corporation
3+
Copyright (C) 2019-2025 Intel Corporation
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

PRODUCT_GUID.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1.21.2
2+
020e45ef-fe9b-45a6-958d-f5ba23f6a7ff

icons/oneapi-icon-left-aligned.png

31.2 KB
Loading
5.85 KB
Loading

scripts/generate_wix_guid.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
Copyright (C) 2025 Intel Corporation
3+
4+
SPDX-License-Identifier: MIT
5+
6+
"""
7+
import uuid
8+
print(str(uuid.uuid4()))

scripts/level_zero_sdk_setup.ps1

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<#
2+
Copyright (C) 2025 Intel Corporation
3+
SPDX-License-Identifier: MIT
4+
#>
5+
6+
param (
7+
[string]$sdkVersion,
8+
[string]$installPath,
9+
[string]$removeSdkEnvVar
10+
)
11+
12+
if ($removeSdkEnvVar) {
13+
if ($removeSdkEnvVar -eq "1" -or $removeSdkEnvVar -eq "true") {
14+
Write-Output "true"
15+
$removeSdkEnvVarValue = $true
16+
} elseif ($removeSdkEnvVar -eq "0" -or $removeSdkEnvVar -eq "false") {
17+
$removeSdkEnvVarValue = $false
18+
} else {
19+
Write-Error "Invalid value for 'removeSdkEnvVar'. Must be a boolean value 0,1,true,false."
20+
Write-Output "Usage: .\level_zero_sdk_setup.ps1 -sdkVersion 1.21.1 -installPath C:\ -removeSdkEnvVar 1"
21+
exit 1
22+
}
23+
} else {
24+
$removeSdkEnvVarValue = $false
25+
}
26+
27+
if (-not $sdkVersion) {
28+
Write-Error "Parameter 'sdkVersion' is required. Example: 1.21.1"
29+
Write-Output "Usage: .\level_zero_sdk_setup.ps1 -sdkVersion 1.21.1 -installPath C:\ -[optional]removeSdkEnvVar 1"
30+
Write-Output "Usage: .\level_zero_sdk_setup.ps1 -sdkVersion 1.21.1 -installPath C:\"
31+
exit 1
32+
}
33+
34+
if (-not $installPath) {
35+
Write-Error "Parameter 'installPath' is required. Example: C:\Users\user\LevelZeroSDK, where LevelZeroSDK is the root directory. Default is SYSTEM_DRIVE:\"
36+
Write-Output "Usage: .\level_zero_sdk_setup.ps1 -sdkVersion 1.21.1 -installPath C:\Users\user\LevelZeroSDK -[optional]removeSdkEnvVar 1"
37+
Write-Output "Usage: .\level_zero_sdk_setup.ps1 -sdkVersion 1.21.1 -installPath C:\Users\user\LevelZeroSDK"
38+
exit 1
39+
}
40+
41+
# Update or set the LEVEL_ZERO_SDK_V<major_version>_PATH environment variable
42+
$majorVersion = $sdkVersion.Split('.')[0]
43+
$envVarName = "LEVEL_ZERO_V${majorVersion}_SDK_PATH"
44+
45+
if ($removeSdkEnvVarValue -eq $true) {
46+
if (-not [System.Environment]::GetEnvironmentVariable($envVarName, [System.EnvironmentVariableTarget]::Machine)) {
47+
Write-Error "Environment variable does not exist: $envVarName"
48+
exit 1
49+
}
50+
[System.Environment]::SetEnvironmentVariable($envVarName, $null, [System.EnvironmentVariableTarget]::Machine)
51+
Write-Output "Environment variable removed: $envVarName"
52+
} else {
53+
# Define the paths
54+
$sdkPath = Join-Path -Path $installPath -ChildPath "LevelZeroSDK\$sdkVersion\"
55+
56+
# Check if the SDK path exists
57+
if (-not (Test-Path -Path $sdkPath)) {
58+
Write-Error "The Level Zero SDK path '$sdkPath' does not exist."
59+
exit 1
60+
}
61+
$currentEnvPath = [System.Environment]::GetEnvironmentVariable($envVarName, [System.EnvironmentVariableTarget]::Machine)
62+
if ($null -eq $currentEnvPath -or $currentEnvPath -notcontains $sdkPath) {
63+
[System.Environment]::SetEnvironmentVariable($envVarName, $sdkPath, [System.EnvironmentVariableTarget]::Machine)
64+
}
65+
Write-Output "Level Zero SDK Path Setup completed successfully."
66+
Write-Output "Environment variable changed: $envVarName"
67+
Write-Output "Updated SDK Version: $sdkVersion"
68+
Write-Output "Updated SDK Path: $sdkPath"
69+
}

scripts/wix_env_installation.wxs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!--
2+
Copyright (C) 2025 Intel Corporation
3+
4+
SPDX-License-Identifier: MIT
5+
-->
6+
<CPackWiXPatch>
7+
<CPackWiXFragment Id="#PRODUCT">
8+
<Feature Id="EnvSetupFeature" Display="expand" Title="Set LEVEL_ZERO_V1_SDK_PATH" Level="1">
9+
<Component Id="SetEnvVar" Guid="ec0c4b66-da81-4d6a-b45a-5cddf0eec9ce" Directory="TARGETDIR">
10+
<!-- Set the environment variable during installation -->
11+
<Condition><![CDATA[NOT REMOVE]]></Condition>
12+
<Environment Id="SetLevelZeroSDKPath" Name="LEVEL_ZERO_V1_SDK_PATH" Value="[INSTALL_ROOT]" Permanent="no" Part="all" Action="set" System="yes"/>
13+
</Component>
14+
<Component Id="RemoveEnvVar" Guid="8fffc6ee-422c-4d2e-a80d-080ce60853c0" Directory="TARGETDIR">
15+
<!-- Remove the environment variable during uninstallation -->
16+
<Condition><![CDATA[REMOVE="ALL"]]></Condition>
17+
<Environment Id="RemoveLevelZeroSDKPath" Name="LEVEL_ZERO_V1_SDK_PATH" Action="remove" System="yes" Value="[INSTALL_ROOT]"/>
18+
</Component>
19+
</Feature>
20+
</CPackWiXFragment>
21+
</CPackWiXPatch>

source/CMakeLists.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,22 @@ if(WIN32)
5555
target_link_libraries (${TARGET_LOADER_NAME} PRIVATE cfgmgr32.lib)
5656
endif()
5757

58+
set(SDK_COMPONENT_STRING "level-zero-devel")
59+
set(LIB_COMPONENT_STRING "level-zero")
60+
61+
if(BUILD_INSTALLER)
62+
set(SDK_COMPONENT_STRING "SDK")
63+
set(LIB_COMPONENT_STRING "Loader")
64+
endif()
65+
5866
install(TARGETS ze_loader
59-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT level-zero-devel
60-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT level-zero
61-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT level-zero
62-
NAMELINK_COMPONENT level-zero-devel
67+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${SDK_COMPONENT_STRING}
68+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${LIB_COMPONENT_STRING}
69+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${LIB_COMPONENT_STRING}
70+
NAMELINK_COMPONENT ${SDK_COMPONENT_STRING}
6371
)
6472

73+
if(!BUILD_INSTALLER)
6574
file(RELATIVE_PATH pkgconfig_prefix "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_PREFIX}")
6675
file(RELATIVE_PATH pkgconfig_include_dir "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
6776
file(RELATIVE_PATH pkgconfig_lib_dir "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_FULL_LIBDIR}")
@@ -71,4 +80,5 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/level-zero.pc.in ${CMAKE_CURRENT_BINA
7180

7281
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libze_loader.pc"
7382
"${CMAKE_CURRENT_BINARY_DIR}/level-zero.pc"
74-
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" COMPONENT level-zero-devel)
83+
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" COMPONENT ${SDK_COMPONENT_STRING})
84+
endif()

0 commit comments

Comments
 (0)