blob: 059f088b742b79fed12b9cd42f9e3373c0556767 [file] [edit]
file(READ "${RunCMake_TEST_BINARY_DIR}/compile_commands.json" commands)
string(JSON count LENGTH "${commands}")
math(EXPR last "${count} - 1")
foreach(i RANGE 0 ${last})
string(JSON command ERROR_VARIABLE error GET "${commands}" ${i} command)
if(error)
set(command "")
string(JSON argc LENGTH "${commands}" ${i} arguments)
math(EXPR last_arg "${argc} - 1")
foreach(a RANGE 0 ${last_arg})
string(JSON arg GET "${commands}" ${i} arguments ${a})
string(APPEND command "${arg} ")
endforeach()
endif()
string(JSON output GET "${commands}" ${i} output)
if(output MATCHES "selected(_native)?\\.dir")
include("${RunCMake_TEST_BINARY_DIR}/targets.cmake")
if(compiler STREQUAL "AdaptiveCpp")
set(option "--acpp-targets=${expected_targets}")
elseif(compiler MATCHES "^(DPClang|IntelLLVM)$")
string(REPLACE ";" "," value "${expected_targets}")
set(option "-fsycl-targets=${value}")
else()
string(REPLACE ";" "," value "${expected_targets}")
set(option "--offload-targets=${value}")
endif()
string(FIND "${command}" "${option}" pos)
if(pos LESS 0)
set(RunCMake_TEST_FAILED "Missing '${option}' in '${command}'")
return()
endif()
if(compiler STREQUAL "AdaptiveCpp")
if(command MATCHES "-x c\\+\\+")
set(RunCMake_TEST_FAILED "C++ language forcing overrides AdaptiveCpp multipass: ${command}")
return()
endif()
elseif(NOT command MATCHES "-x c\\+\\+")
set(RunCMake_TEST_FAILED "Missing C++ source language: ${command}")
return()
endif()
elseif(output MATCHES "(disabled|host)\\.dir" AND
command MATCHES "(acpp-targets|fsycl-targets|offload-targets)=")
set(RunCMake_TEST_FAILED "Unexpected device selection: ${command}")
return()
elseif(output MATCHES "baseline\\.dir" AND
NOT command MATCHES "(acpp-targets|fsycl-targets|offload-targets)=")
set(RunCMake_TEST_FAILED "Missing baseline device selection: ${command}")
return()
endif()
endforeach()