|
|
@@ -36,7 +36,47 @@ if (WIN32)
|
|
|
endif()
|
|
|
endif()
|
|
|
|
|
|
-find_package(IntelSYCL)
|
|
|
+macro(detect_and_find_package package_name)
|
|
|
+ set(test_source "
|
|
|
+ cmake_minimum_required(VERSION ${CMAKE_VERSION})
|
|
|
+ project(check_package LANGUAGES CXX)
|
|
|
+ find_package(${package_name} QUIET)
|
|
|
+ ")
|
|
|
+
|
|
|
+ set(test_dir "${CMAKE_CURRENT_BINARY_DIR}/check_package_${package_name}")
|
|
|
+ file(WRITE "${test_dir}/CMakeLists.txt" "${test_source}")
|
|
|
+
|
|
|
+ set(cmake_args "")
|
|
|
+ if(CMAKE_GENERATOR)
|
|
|
+ list(APPEND cmake_args "-G" "${CMAKE_GENERATOR}")
|
|
|
+ endif()
|
|
|
+ if(CMAKE_GENERATOR_PLATFORM)
|
|
|
+ list(APPEND cmake_args "-A" "${CMAKE_GENERATOR_PLATFORM}")
|
|
|
+ endif()
|
|
|
+ if(CMAKE_GENERATOR_TOOLSET)
|
|
|
+ list(APPEND cmake_args "-T" "${CMAKE_GENERATOR_TOOLSET}")
|
|
|
+ endif()
|
|
|
+ if(CMAKE_CXX_COMPILER)
|
|
|
+ list(APPEND cmake_args "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
|
|
|
+ endif()
|
|
|
+
|
|
|
+ execute_process(
|
|
|
+ COMMAND ${CMAKE_COMMAND} ${cmake_args} .
|
|
|
+ WORKING_DIRECTORY "${test_dir}"
|
|
|
+ RESULT_VARIABLE result
|
|
|
+ OUTPUT_QUIET
|
|
|
+ ERROR_QUIET
|
|
|
+ )
|
|
|
+
|
|
|
+ if(result EQUAL 0)
|
|
|
+ find_package(${package_name} ${ARGN})
|
|
|
+ else()
|
|
|
+ message(WARNING "Detection of ${package_name} failed. The package might be broken or incompatible.")
|
|
|
+ set(${package_name}_FOUND FALSE)
|
|
|
+ endif()
|
|
|
+endmacro()
|
|
|
+
|
|
|
+detect_and_find_package(IntelSYCL)
|
|
|
if (IntelSYCL_FOUND)
|
|
|
# Use oneAPI CMake when possible
|
|
|
target_link_libraries(ggml-sycl PRIVATE IntelSYCL::SYCL_CXX)
|
|
|
@@ -190,4 +230,4 @@ endif()
|
|
|
if (GGML_SYCL_DEVICE_ARCH)
|
|
|
target_compile_options(ggml-sycl PRIVATE -Xsycl-target-backend --offload-arch=${GGML_SYCL_DEVICE_ARCH})
|
|
|
target_link_options(ggml-sycl PRIVATE -Xsycl-target-backend --offload-arch=${GGML_SYCL_DEVICE_ARCH})
|
|
|
-endif()
|
|
|
+endif()
|