Use 'alwayslink' helpers from iree_cc_binary in iree_cc_test.

Fixes #1081.

Closes https://github.com/google/iree/pull/1084

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/iree/pull/1084 from ScottTodd:cmake-cc-test 46b2f898fa0ae1af53bd045be4bf8874c736fd1e
PiperOrigin-RevId: 301259047
diff --git a/build_tools/cmake/iree_cc_test.cmake b/build_tools/cmake/iree_cc_test.cmake
index 8909957..8a27f47 100644
--- a/build_tools/cmake/iree_cc_test.cmake
+++ b/build_tools/cmake/iree_cc_test.cmake
@@ -89,13 +89,6 @@
     PRIVATE
       ${_RULE_COPTS}
   )
-  target_link_libraries(${_NAME}
-    PUBLIC
-      ${_RULE_DEPS}
-      gmock
-    PRIVATE
-      ${_RULE_LINKOPTS}
-  )
   iree_add_data_dependencies(NAME ${_NAME} DATA ${_RULE_DATA})
   # Add all IREE targets to a folder in the IDE for organization.
   set_property(TARGET ${_NAME} PROPERTY FOLDER ${IREE_IDE_FOLDER}/test)
@@ -103,6 +96,13 @@
   set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${IREE_CXX_STANDARD})
   set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
 
+  # Defer computing transitive dependencies and calling target_link_libraries()
+  # until all libraries have been declared.
+  # Track target and deps, use in iree_complete_binary_link_options() later.
+  list(APPEND _RULE_DEPS "gmock")
+  set_property(GLOBAL APPEND PROPERTY _IREE_CC_BINARY_NAMES "${_NAME}")
+  set_property(TARGET ${_NAME} PROPERTY DIRECT_DEPS ${_RULE_DEPS})
+
   # We run all our tests through a custom test runner to allow temp directory
   # cleanup upon test completion.
   add_test(
diff --git a/build_tools/cmake/test.sh b/build_tools/cmake/test.sh
index bf8e08a..2b86632 100755
--- a/build_tools/cmake/test.sh
+++ b/build_tools/cmake/test.sh
@@ -29,12 +29,6 @@
 EXCLUDED_TESTS=(
     iree_compiler_Translation_SPIRV_LinalgToSPIRV_test_pw_add.mlir.test
     iree_hal_vulkan_dynamic_symbols_test
-    iree_modules_check_check_test
-    iree_modules_tensorlist_tensorlist_test
-    iree_tools_test_multiple_args.mlir.test
-    iree_tools_test_scalars.mlir.test
-    iree_tools_test_simple.mlir.test
-    iree_tools_vm_util_test
     iree_vm_bytecode_module_benchmark # Make this test not take an eternity
 )