[cmake] Extract whole archive link as a separate function (#3087)

This commit extracts out as a function the functionality for going
through a target's direct library dependencies and recursively
linking ALWAYSLINK libraries as whole archive. It can be reused
for iree_cc_library so that wen we pack shared libraries we can
make sure ALWAYSLINK markers are respected and we have the necessary
global static objects for registering various functionalities.

This change is mostly NFC, except for exposing whole archive link
in iree_cc_library.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 53aba14..2995809 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -236,6 +236,7 @@
 
 include(iree_macros)
 include(iree_copts)
+include(iree_whole_archive_link)
 include(iree_cc_binary)
 include(iree_cc_library)
 include(iree_cc_test)