programs: Link to tests common code

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/programs/pkey/CMakeLists.txt b/programs/pkey/CMakeLists.txt
index 17a252d..b4b3d30 100644
--- a/programs/pkey/CMakeLists.txt
+++ b/programs/pkey/CMakeLists.txt
@@ -4,7 +4,7 @@
 )
 
 foreach(exe IN LISTS executables_mbedtls)
-    add_executable(${exe} ${exe}.c)
+    add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
     target_link_libraries(${exe} mbedtls)
 endforeach()
 
@@ -30,7 +30,7 @@
 )
 
 foreach(exe IN LISTS executables_mbedcrypto)
-    add_executable(${exe} ${exe}.c)
+    add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>)
     target_link_libraries(${exe} mbedcrypto)
 endforeach()