Skip to content

Commit

Permalink
Merge pull request oneapi-src#1410 from kbenzie/benie/cmake-external-…
Browse files Browse the repository at this point in the history
…adapter-source-dirs

[CMake] Support external adapter source dirs
  • Loading branch information
kbenzie authored Mar 14, 2024
2 parents 09be088 + 6d58609 commit 6513abc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ set(UR_SYCL_LIBRARY_DIR "" CACHE PATH
set(UR_CONFORMANCE_TARGET_TRIPLES "" CACHE STRING
"List of sycl targets to build CTS device binaries for")
set(UR_CONFORMANCE_AMD_ARCH "" CACHE STRING "AMD device target ID to build CTS binaries for")
set(UR_ADAPTER_LEVEL_ZERO_SOURCE_DIR "" CACHE PATH
"Path to external 'level_zero' adapter source dir")
set(UR_ADAPTER_OPENCL_SOURCE_DIR "" CACHE PATH
"Path to external 'opencl' adapter source dir")
set(UR_ADAPTER_CUDA_SOURCE_DIR "" CACHE PATH
"Path to external 'cuda' adapter source dir")
set(UR_ADAPTER_HIP_SOURCE_DIR "" CACHE PATH
"Path to external 'hip' adapter source dir")
set(UR_ADAPTER_NATIVE_CPU_SOURCE_DIR "" CACHE PATH
"Path to external 'native_cpu' adapter source dir")

# There's little reason not to generate the compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down
26 changes: 21 additions & 5 deletions source/adapters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,37 @@ endfunction()

add_subdirectory(null)

function(add_ur_adapter_subdirectory name)
string(TOUPPER ${name} NAME)
if(UR_ADAPTER_${NAME}_SOURCE_DIR)
if(NOT IS_DIRECTORY ${UR_ADAPTER_${NAME}_SOURCE_DIR})
message(FATAL_ERROR
"UR_ADAPTER_${NAME}_SOURCE_DIR is not a directory: "
"${UR_ADAPTER_${NAME}_SOURCE_DIR}")
endif()
add_subdirectory(
"${UR_ADAPTER_${NAME}_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}/${name}")
else()
add_subdirectory(${name})
endif()
endfunction()

if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_ALL)
add_subdirectory(level_zero)
add_ur_adapter_subdirectory(level_zero)
endif()

if(UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_ALL)
add_subdirectory(cuda)
add_ur_adapter_subdirectory(cuda)
endif()

if(UR_BUILD_ADAPTER_HIP OR UR_BUILD_ADAPTER_ALL)
add_subdirectory(hip)
add_ur_adapter_subdirectory(hip)
endif()

if(UR_BUILD_ADAPTER_OPENCL OR UR_BUILD_ADAPTER_ALL)
add_subdirectory(opencl)
add_ur_adapter_subdirectory(opencl)
endif()
if(UR_BUILD_ADAPTER_NATIVE_CPU OR UR_BUILD_ADAPTER_ALL)
add_subdirectory(native_cpu)
add_ur_adapter_subdirectory(native_cpu)
endif()

0 comments on commit 6513abc

Please sign in to comment.