[SPEC2017] Fix image_validator build when cross-compiling.

When cross-compiling and running benchmarks on a different device,
verification happens on-device, but currently the image validator
binaries are built for the host system.

This breaks verification, because the host binary cannot necessarily be
executed on-device (e.g. cross-compiling for ARM64 on X86 and executing
on a ARM64 device).

I tested this with cross-compiling to ARM64 and it works as expected.
When not cross-compiling, the behavior should not change.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D95358
diff --git a/External/SPEC/SpecCPU2017.cmake b/External/SPEC/SpecCPU2017.cmake
index 9465ef8..fb4ddb8 100644
--- a/External/SPEC/SpecCPU2017.cmake
+++ b/External/SPEC/SpecCPU2017.cmake
@@ -252,14 +252,14 @@
 macro(speccpu2017_validate_image _imgfile _cmpfile _outfile)
   cmake_parse_arguments(_carg "" "RUN_TYPE" "SUITE_TYPE" ${ARGN})
 
-  set(VALIDATOR imagevalidate_${BENCHMARK_NO})
-  if (NOT TARGET ${VALIDATOR}-host)
+  set(VALIDATOR imagevalidate_${BENCHMARK_NO}-target)
+  if (NOT TARGET ${VALIDATOR})
     file(GLOB_RECURSE _validator_sources "${SRC_DIR}/image_validator/*.c")
-    llvm_add_host_executable(
-      ${VALIDATOR}-host ${VALIDATOR} ${_validator_sources}
-      LDFLAGS -lm
-      CPPFLAGS -DSPEC
-    )
+
+    add_executable(${VALIDATOR} ${_validator_sources})
+    target_link_libraries(${VALIDATOR} m)
+    set_target_properties(${VALIDATOR} PROPERTIES COMPILE_FLAGS "-DSPEC")
+    add_dependencies(${VALIDATOR} timeit-target)
   endif ()
 
   if ((NOT DEFINED _carg_SUITE_TYPE) OR (${BENCHMARK_SUITE_TYPE} IN_LIST _carg_SUITE_TYPE))
@@ -331,8 +331,8 @@
 
   llvm_test_executable(${PROG} ${_sources})
 
-  if (TARGET ${VALIDATOR}-host)
-    add_dependencies(${PROG} ${VALIDATOR}-host)
+  if (TARGET ${VALIDATOR})
+    add_dependencies(${PROG} ${VALIDATOR})
   endif ()
 endmacro()