1if(CMAKE_CLC_COMPILER_FORCED)
2  # The compiler configuration was forced by the user.
3  # Assume the user has configured all compiler information.
4  set(CMAKE_CLC_COMPILER_WORKS TRUE)
5  return()
6endif()
7
8include(CMakeTestCompilerCommon)
9
10# Remove any cached result from an older CMake version.
11# We now store this in CMakeCCompiler.cmake.
12unset(CMAKE_CLC_COMPILER_WORKS CACHE)
13
14# This file is used by EnableLanguage in cmGlobalGenerator to
15# determine that that selected CLC compiler can actually compile
16# and link the most basic of programs. If not, a fatal error
17# is set and cmake stops processing commands and will not generate
18# any makefiles or projects.
19if(NOT CMAKE_CLC_COMPILER_WORKS)
20  PrintTestCompilerStatus("CLC" "")
21  file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCLCCompiler.cl
22    "__kernel void test_k(global int * a)\n"
23    "{ *a = 1; }\n")
24  try_compile(CMAKE_CLC_COMPILER_WORKS ${CMAKE_BINARY_DIR}
25    ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCLCCompiler.cl
26    # We never generate executable so bypass the link step
27    CMAKE_FLAGS -DCMAKE_CLC_LINK_EXECUTABLE='echo'
28    OUTPUT_VARIABLE __CMAKE_CLC_COMPILER_OUTPUT)
29  # Move result from cache to normal variable.
30  set(CMAKE_CLC_COMPILER_WORKS ${CMAKE_CLC_COMPILER_WORKS})
31  unset(CMAKE_CLC_COMPILER_WORKS CACHE)
32  set(CLC_TEST_WAS_RUN 1)
33endif()
34
35if(NOT CMAKE_CLC_COMPILER_WORKS)
36  PrintTestCompilerStatus("CLC" " -- broken")
37  file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
38    "Determining if the CLC compiler works failed with "
39    "the following output:\n${__CMAKE_CLC_COMPILER_OUTPUT}\n\n")
40  message(FATAL_ERROR "The CLC compiler \"${CMAKE_CLC_COMPILER}\" "
41    "is not able to compile a simple test program.\nIt fails "
42    "with the following output:\n ${__CMAKE_CLC_COMPILER_OUTPUT}\n\n"
43    "CMake will not be able to correctly generate this project.")
44else()
45  if(CLC_TEST_WAS_RUN)
46    PrintTestCompilerStatus("CLC" " -- works")
47    file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
48      "Determining if the CLC compiler works passed with "
49      "the following output:\n${__CMAKE_CLC_COMPILER_OUTPUT}\n\n")
50  endif()
51
52  include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCLCCompiler.cmake)
53
54endif()
55
56unset(__CMAKE_CLC_COMPILER_OUTPUT)
57