cmake: api-tests: Allow CROSS_COMPILE to set C compiler

Cmake currently falls back to the default C compiler on the system,
which may not be an appropriate embedded toolchain in every case.
This commit checks for a `CROSS_COMPILE` field that can be
passed in to indicate the specific GCC cross-compiler to use. If no
matching value is found, it defaults to the system C compiler,
as was the case previously.

Signed-off-by: Kevin Townsend <kevin.townsend@linaro.org>
diff --git a/api-tests/CMakeLists.txt b/api-tests/CMakeLists.txt
index 8dc6dab..02f46d2 100644
--- a/api-tests/CMakeLists.txt
+++ b/api-tests/CMakeLists.txt
@@ -435,6 +435,14 @@
         TEST_COMMAND ""
 )
 
+# Check if a specific cross compiler was passed in
+find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}-gcc)
+
+# Otherwise, let CMake look for a C compiler
+if(CMAKE_C_COMPILER STREQUAL "CMAKE_C_COMPILER-NOTFOUND")
+	project(TargetConfigGen LANGUAGES C)
+endif()
+
 # Add custom target to clean generated files of the external project
 add_custom_target(
         ${PSA_TARGET_GENERATE_DATABASE_POST}