Summary: The current handling of `libclc` is to use custom clang jobs to compile source files. This is the way we used to compile GPU libraries, but we have largely moved away from this. The eventual goal is to simple be able to use `clang` like a normal project. One barrier to this is the lack of language support for OpenCL in CMake. This PR uses CMake's custom language support to define a minimal OpenCL language, largely just a wrapper around `clang -x cl`. This does nothing, just enables the support. Future PRs will need to untangle the mess of dependencies. The 'link+opt' steps that we now do should be able to simply be done as a custom `llvm-link` and `opt` job on the library, which isn't ideal but it still better than the current state.
35 lines
1.0 KiB
CMake
35 lines
1.0 KiB
CMake
configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeCLCCompiler.cmake.in
|
|
${CMAKE_PLATFORM_INFO_DIR}/CMakeCLCCompiler.cmake @ONLY)
|
|
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCLCCompiler.cmake)
|
|
|
|
if(CMAKE_CLC_COMPILER_FORCED)
|
|
set(CMAKE_CLC_COMPILER_WORKS TRUE)
|
|
return()
|
|
endif()
|
|
|
|
set(_test_file "${CMAKE_CURRENT_LIST_DIR}/CMakeCLCCompilerTest.cl")
|
|
set(_test_dir "${CMAKE_PLATFORM_INFO_DIR}/CMakeTmp")
|
|
set(_test_out "${_test_dir}/test_clc.o")
|
|
file(MAKE_DIRECTORY "${_test_dir}")
|
|
|
|
message(STATUS "Check for working CLC compiler: ${CMAKE_CLC_COMPILER}")
|
|
|
|
execute_process(
|
|
COMMAND "${CMAKE_CLC_COMPILER}" -x cl -c -flto
|
|
-o "${_test_out}" "${_test_file}"
|
|
RESULT_VARIABLE _clc_result
|
|
ERROR_VARIABLE _clc_error
|
|
)
|
|
|
|
if(_clc_result EQUAL 0)
|
|
set(CMAKE_CLC_COMPILER_WORKS TRUE)
|
|
message(STATUS "Check for working CLC compiler: ${CMAKE_CLC_COMPILER} - works")
|
|
file(REMOVE "${_test_out}")
|
|
else()
|
|
message(FATAL_ERROR
|
|
"The CLC compiler\n"
|
|
" ${CMAKE_CLC_COMPILER}\n"
|
|
"is not able to compile a simple OpenCL test program.\n"
|
|
"Output:\n${_clc_error}")
|
|
endif()
|