Skip to content

Commit 50165ad

Browse files
committed
Add USE_SYSTEM_LIBRARIES option for distro packagers
Signed-off-by: Alexander F. Lent <[email protected]>
1 parent 9e3d56d commit 50165ad

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
3737
option(ENABLE_OPENVINO_PACKAGE "Enable building the OpenVINO package" OFF)
3838
option(ENABLE_NPU_COMPILER_BUILD "Enable building compiler in driver" OFF)
3939
option(ENABLE_NPU_PERFETTO_BUILD "Enable building with Perfetto library" OFF)
40+
# TODO: USE_SYSTEM_LIBRARIES should also unvendor the kernel uapi header.
41+
option(USE_SYSTEM_LIBRARIES "Use system versions of third_party libraries" OFF)
4042

4143
message(STATUS "option ENABLE_NPU_COMPILER_BUILD: ${ENABLE_NPU_COMPILER_BUILD}")
4244
message(STATUS "option ENABLE_NPU_PERFETTO_BUILD: ${ENABLE_NPU_PERFETTO_BUILD}")

third_party/CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@ add_compile_options(-Wno-error -include cstdint)
1010
include(cmake/vpux_elf.cmake)
1111
include(cmake/level-zero.cmake)
1212
include(cmake/level-zero-npu-extensions.cmake)
13+
# TODO: Handle USE_SYSTEM_LIBRARIES for Perfetto SDK, too
1314
if (ENABLE_NPU_PERFETTO_BUILD)
15+
if (USE_SYSTEM_LIBRARIES)
16+
message(FATAL_ERROR "USE_SYSTEM_LIBRARIES is not yet implemented for the Perfetto SDK")
17+
endif()
1418
include(cmake/perfetto.cmake)
1519
endif()
1620

17-
set(INSTALL_GTEST OFF)
18-
add_subdirectory(googletest EXCLUDE_FROM_ALL)
21+
if (NOT USE_SYSTEM_LIBRARIES)
22+
set(INSTALL_GTEST OFF)
23+
add_subdirectory(googletest EXCLUDE_FROM_ALL)
1924

20-
set(YAML_CPP_INSTALL OFF)
21-
set(BUILD_SHARED_LIBS OFF)
22-
add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL)
25+
set(YAML_CPP_INSTALL OFF)
26+
set(BUILD_SHARED_LIBS OFF)
27+
add_subdirectory(yaml-cpp EXCLUDE_FROM_ALL)
28+
else()
29+
message(STATUS "USE_SYSTEM_LIBRARIES excluded the vendored gtest/gmock and yaml-cpp from the build")
30+
endif()

third_party/cmake/level-zero-npu-extensions.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
# This software and the related documents are provided as is, with no express or
1010
# implied warranties, other than those that are expressly stated in the License.
1111

12+
# TODO: Detect empty directory and upgrade to warning then regardless
13+
if (USE_SYSTEM_LIBRARIES)
14+
message(STATUS "USE_SYSTEM_LIBRARIES does not apply to level-zero-npu-extensions; it must always be vendored.")
15+
endif()
16+
1217
set(LEVEL_ZERO_EXT_HEADERS_DIR "${CMAKE_BINARY_DIR}/include/level_zero")
1318
file(MAKE_DIRECTORY ${LEVEL_ZERO_EXT_HEADERS_DIR})
1419
file(GLOB_RECURSE LEVEL_ZERO_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/level-zero-npu-extensions/*.h)

third_party/cmake/level-zero.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ endif()
2121
find_package(LevelZero ${LEVEL_ZERO_VERSION})
2222

2323
if(NOT LevelZero_FOUND)
24+
if(USE_SYSTEM_LIBRARIES)
25+
message(FATAL_ERROR "LevelZero was not found and USE_SYSTEM_LIBRARIES was requested.")
26+
endif()
2427
message(STATUS "LevelZero not found in the system, take one from third_party/level_zero")
2528

2629
# EXCLUDE_FROM_ALL is used because level-zero-devel install destination starts with root

third_party/cmake/vpux_elf.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ if (TARGET vpux_elf)
1515
return()
1616
endif()
1717

18+
# TODO: Detect empty directory and upgrade to warning then regardless
19+
if (USE_SYSTEM_LIBRARIES)
20+
message(STATUS "USE_SYSTEM_LIBRARIES does not apply to vpux_elf; it must always be vendored.")
21+
endif()
22+
1823
# Below function is required by vpux_elf
1924
function(enable_warnings_as_errors TARGET_NAME)
2025
target_compile_options(${TARGET_NAME} PRIVATE -Wall -Wextra -Werror)

0 commit comments

Comments
 (0)