Skip to content

Commit 0c77866

Browse files
committed
Install adapters by cmake
1 parent 7e9d9d4 commit 0c77866

File tree

10 files changed

+25
-9
lines changed

10 files changed

+25
-9
lines changed

.github/workflows/build-hw-reusable.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,18 @@ jobs:
8787
-DUR_STATIC_ADAPTER_${{matrix.adapter.name}}=${{matrix.adapter.static_adapter}}
8888
-DUR_DPCXX=${{github.workspace}}/dpcpp_compiler/bin/clang++
8989
-DUR_SYCL_LIBRARY_DIR=${{github.workspace}}/dpcpp_compiler/lib
90+
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install
9091
${{ matrix.adapter.name == 'HIP' && '-DUR_CONFORMANCE_AMD_ARCH=gfx1030' || '' }}
9192
${{ matrix.adapter.name == 'HIP' && '-DUR_HIP_PLATFORM=AMD' || '' }}
9293
9394
- name: Build
9495
# This is so that device binaries can find the sycl runtime library
9596
run: cmake --build ${{github.workspace}}/build -j $(nproc)
9697

98+
- name: Install
99+
# This is to check that install command does not fail
100+
run: cmake --install ${{github.workspace}}/build
101+
97102
- name: Test adapter specific
98103
working-directory: ${{github.workspace}}/build
99104
run: ctest -C ${{matrix.build_type}} --output-on-failure -L "adapter-specific" --timeout 180

cmake/helpers.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ function(add_ur_library name)
139139
endif()
140140
endfunction()
141141

142+
function(install_ur_library name)
143+
install(TARGETS ${name}
144+
EXPORT ${PROJECT_NAME}-targets
145+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
146+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
147+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT unified-runtime
148+
)
149+
endfunction()
150+
142151
include(FetchContent)
143152

144153
function(FetchSource GIT_REPOSITORY GIT_TAG GIT_DIR DEST)

source/adapters/cuda/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ add_ur_adapter(${TARGET_NAME}
4545
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
4646
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
4747
)
48+
install_ur_library(${TARGET_NAME})
4849

4950
set_target_properties(${TARGET_NAME} PROPERTIES
5051
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
@@ -100,7 +101,7 @@ if (UR_ENABLE_TRACING)
100101
XPTI_ENABLE_INSTRUMENTATION
101102
XPTI_STATIC_LIBRARY
102103
)
103-
target_include_directories(${TARGET_NAME} PUBLIC
104+
target_include_directories(${TARGET_NAME} PRIVATE
104105
${XPTI_INCLUDES}
105106
${CUDA_CUPTI_INCLUDE_DIR}
106107
)

source/adapters/hip/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ add_ur_adapter(${TARGET_NAME}
9292
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
9393
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
9494
)
95+
install_ur_library(${TARGET_NAME})
9596

9697
if(NOT MSVC)
9798
target_compile_options(${TARGET_NAME} PRIVATE

source/adapters/level_zero/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ if(UR_BUILD_ADAPTER_L0)
5050
${CMAKE_CURRENT_SOURCE_DIR}/helpers/memory_helpers.cpp
5151
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
5252
)
53+
install_ur_library(ur_adapter_level_zero)
5354

5455
if(UR_STATIC_ADAPTER_L0)
5556
target_compile_definitions(ur_adapter_level_zero PUBLIC UR_STATIC_ADAPTER_LEVEL_ZERO)
5657

5758
# 'utils' target from 'level-zero-loader' includes path which is prefixed
5859
# in the source directory, this breaks the installation of 'utils' target.
5960
set_target_properties(utils PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "")
60-
install(TARGETS ur_adapter_level_zero ur_umf LevelZeroLoader LevelZeroLoader-Headers ze_loader utils
61+
install(TARGETS ur_umf LevelZeroLoader LevelZeroLoader-Headers ze_loader utils
6162
EXPORT ${PROJECT_NAME}-targets
6263
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
6364
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
@@ -150,6 +151,7 @@ if(UR_BUILD_ADAPTER_L0_V2)
150151
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_in_order.cpp
151152
${CMAKE_CURRENT_SOURCE_DIR}/v2/usm.cpp
152153
)
154+
install_ur_library(ur_adapter_level_zero_v2)
153155

154156
if(NOT WIN32)
155157
# api.cpp contains NOT_SUPPORTED functions-only

source/adapters/native_cpu/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ add_ur_adapter(${TARGET_NAME}
4141
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
4242
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
4343
)
44+
install_ur_library(${TARGET_NAME})
4445

4546
set_target_properties(${TARGET_NAME} PROPERTIES
4647
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"

source/adapters/opencl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ add_ur_adapter(${TARGET_NAME} SHARED
4343
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
4444
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
4545
)
46+
install_ur_library(${TARGET_NAME})
4647

4748
set_target_properties(${TARGET_NAME} PROPERTIES
4849
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"

source/loader/CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ add_ur_library(ur_loader
1919
""
2020
${CMAKE_CURRENT_BINARY_DIR}/UrLoaderVersion.rc
2121
)
22+
install_ur_library(ur_loader)
2223

2324
if (MSVC)
2425
set(TARGET_LIBNAME ur_loader)
@@ -101,13 +102,6 @@ if(UNIX)
101102
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libur_loader.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" COMPONENT unified-runtime)
102103
endif()
103104

104-
install(TARGETS ur_loader
105-
EXPORT ${PROJECT_NAME}-targets
106-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
107-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
108-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT unified-runtime
109-
)
110-
111105
target_sources(ur_loader
112106
PRIVATE
113107
${CMAKE_CURRENT_SOURCE_DIR}/ur_object.hpp

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set(UR_TEST_PLATFORMS_COUNT 1 CACHE STRING "Count of platforms on which conforma
1515
set(UR_TEST_FUZZTESTS ON CACHE BOOL "Run fuzz tests if using clang and UR_DPCXX is specified")
1616
# For Windows: Prevent overriding the parent project's compiler/linker settings
1717
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
18+
set(INSTALL_GTEST OFF)
1819
FetchContent_MakeAvailable(googletest)
1920
enable_testing()
2021

test/adapters/level_zero/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ if(UR_BUILD_ADAPTER_L0)
4545
# Make L0 use CallMap from a seprate shared lib so that we can access the map
4646
# from the tests. This only seems to work on linux
4747
add_library(zeCallMap SHARED zeCallMap.cpp)
48+
install_ur_library(zeCallMap)
4849
target_compile_definitions(ur_adapter_level_zero PRIVATE UR_L0_CALL_COUNT_IN_TESTS)
4950
# TODO: stop exporting internals like this for tests...
5051
target_link_libraries(ur_adapter_level_zero PRIVATE zeCallMap)

0 commit comments

Comments
 (0)