1# Build file for the C10 XPU. 2# 3# C10 XPU is a minimal library, but it does depend on SYCL. 4 5include(../../cmake/public/xpu.cmake) 6 7if(NOT BUILD_LIBTORCHLESS) 8 find_library(C10_XPU_LIB c10_xpu PATHS $ENV{LIBTORCH_LIB_PATH} NO_DEFAULT_PATH) 9endif() 10 11# ---[ Configure macro file. 12set(C10_XPU_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) # used in xpu_cmake_macros.h.in 13configure_file( 14 ${CMAKE_CURRENT_LIST_DIR}/impl/xpu_cmake_macros.h.in 15 ${CMAKE_BINARY_DIR}/c10/xpu/impl/xpu_cmake_macros.h) 16 17set(C10_XPU_SRCS 18 XPUCachingAllocator.cpp 19 XPUFunctions.cpp 20 XPUStream.cpp 21 impl/XPUGuardImpl.cpp 22) 23set(C10_XPU_HEADERS 24 XPUCachingAllocator.h 25 XPUDeviceProp.h 26 XPUException.h 27 XPUFunctions.h 28 XPUMacros.h 29 XPUStream.h 30 impl/XPUGuardImpl.h 31) 32if(NOT BUILD_LIBTORCHLESS) 33 add_library(c10_xpu ${C10_XPU_SRCS} ${C10_XPU_HEADERS}) 34 target_compile_options(c10_xpu PRIVATE "-DC10_XPU_BUILD_MAIN_LIB") 35 # Enable hidden visibility if compiler supports it. 36 if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY}) 37 target_compile_options(c10_xpu PRIVATE "-fvisibility=hidden") 38 endif() 39 40 # ---[ Dependency of c10_xpu 41 target_link_libraries(c10_xpu PUBLIC c10 torch::xpurt) 42 target_include_directories( 43 c10_xpu PUBLIC 44 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..> 45 $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}> 46 $<INSTALL_INTERFACE:include> 47 ) 48 install(TARGETS c10_xpu EXPORT Caffe2Targets DESTINATION lib) 49 set(C10_XPU_LIB c10_xpu) 50 add_subdirectory(test) 51endif() 52 53# ---[ Installation 54 55foreach(file ${C10_XPU_HEADERS}) 56 get_filename_component(dir ${file} DIRECTORY) 57 install(FILES ${file} DESTINATION include/c10/xpu/${dir}) 58endforeach() 59install(FILES ${CMAKE_BINARY_DIR}/c10/xpu/impl/xpu_cmake_macros.h 60 DESTINATION include/c10/xpu/impl) 61 62if(MSVC AND C10_XPU_BUILD_SHARED_LIBS) 63 install(FILES $<TARGET_PDB_FILE:c10_xpu> DESTINATION lib OPTIONAL) 64endif() 65