Link apps and test_libaom with shared library

If -DBUILD_SHARED_LIBS=1 is specified, link the apps (aomdec and aomenc)
and test_libaom with the shared library (libaom.so.3).

Bug: aomedia:3342
Change-Id: I8570e96cd1be3e7ab179c5f377c4dfd1c98a1fa2
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ff0b24..7086421 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -293,15 +293,7 @@
     # MSVC and MINGW both to FALSE).
     set_target_properties(aom PROPERTIES ARCHIVE_OUTPUT_NAME "aom_shared")
   endif()
-  # Tests and examples rely on having unexported AV1 symbols visible. This is
-  # not the case on Windows platforms due to enforcement of the module
-  # definition file.
-  set(AOM_LIB aom_static)
-else()
-  set(AOM_LIB aom)
-endif()
 
-if(BUILD_SHARED_LIBS)
   if(NOT MSVC)
     # Extract version string and set VERSION/SOVERSION for the aom target.
     extract_version_string("${AOM_CONFIG_DIR}/config/aom_version.h"
@@ -363,9 +355,9 @@
 setup_av1_targets()
 
 # Make all library targets depend on aom_rtcd to make sure it builds first.
-foreach(aom_tgt ${AOM_LIB_TARGETS})
-  if(NOT "${aom_tgt}" STREQUAL "aom_rtcd")
-    add_dependencies(${aom_tgt} aom_rtcd)
+foreach(aom_lib ${AOM_LIB_TARGETS})
+  if(NOT "${aom_lib}" STREQUAL "aom_rtcd")
+    add_dependencies(${aom_lib} aom_rtcd)
   endif()
 endforeach()
 
@@ -738,7 +730,7 @@
 endif()
 
 foreach(aom_app ${AOM_APP_TARGETS})
-  target_link_libraries(${aom_app} ${AOM_LIB_LINK_TYPE} ${AOM_LIB})
+  target_link_libraries(${aom_app} ${AOM_LIB_LINK_TYPE} aom)
 endforeach()
 
 if(ENABLE_EXAMPLES OR ENABLE_TESTS OR ENABLE_TOOLS)