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:3476
Change-Id: I8570e96cd1be3e7ab179c5f377c4dfd1c98a1fa2
(cherry picked from commit 28d2a2a77feb0a62a86b868712d7e4f42924d835)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6dcc70a..f999135 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()
 
@@ -734,7 +726,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)
diff --git a/test/test.cmake b/test/test.cmake
index ce61344..672edb3 100644
--- a/test/test.cmake
+++ b/test/test.cmake
@@ -484,16 +484,19 @@
       target_sources(test_libaom PRIVATE ${AOM_ENCODE_PERF_TEST_SOURCES})
     endif()
 
-    add_executable(test_intra_pred_speed ${AOM_TEST_INTRA_PRED_SPEED_SOURCES}
-                                         $<TARGET_OBJECTS:aom_common_app_util>)
-    set_property(TARGET test_intra_pred_speed
-                 PROPERTY FOLDER ${AOM_IDE_TEST_FOLDER})
-    target_link_libraries(test_intra_pred_speed ${AOM_LIB_LINK_TYPE} ${AOM_LIB}
-                          aom_gtest)
-    list(APPEND AOM_APP_TARGETS test_intra_pred_speed)
+    if(NOT BUILD_SHARED_LIBS)
+      add_executable(test_intra_pred_speed
+                     ${AOM_TEST_INTRA_PRED_SPEED_SOURCES}
+                     $<TARGET_OBJECTS:aom_common_app_util>)
+      set_property(TARGET test_intra_pred_speed
+                   PROPERTY FOLDER ${AOM_IDE_TEST_FOLDER})
+      target_link_libraries(test_intra_pred_speed ${AOM_LIB_LINK_TYPE} aom
+                            aom_gtest)
+      list(APPEND AOM_APP_TARGETS test_intra_pred_speed)
+    endif()
   endif()
 
-  target_link_libraries(test_libaom ${AOM_LIB_LINK_TYPE} ${AOM_LIB} aom_gtest)
+  target_link_libraries(test_libaom ${AOM_LIB_LINK_TYPE} aom aom_gtest)
 
   if(CONFIG_LIBYUV)
     target_sources(test_libaom PRIVATE $<TARGET_OBJECTS:yuv>)