CMake: skia_link_arguments.txt repects BUILD_SHARED_LIBS

.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2007093002
CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac-Clang-x86_64-Release-CMake-Trybot

Review-Url: https://codereview.chromium.org/2007093002
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index ed8ec67..ef0856a 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -302,9 +302,21 @@
 
 # skia_link_arguments.txt
 set (link_arguments ${CMAKE_BINARY_DIR}/skia_link_arguments.txt)
-file (WRITE ${link_arguments} "-L${CMAKE_BINARY_DIR}\n")
-file (APPEND ${link_arguments} "-lskia\n")
-file (APPEND ${link_arguments} "-Wl,-rpath,${CMAKE_BINARY_DIR}\n")
+if (BUILD_SHARED_LIBS)
+  file (WRITE ${link_arguments} "-L${CMAKE_BINARY_DIR}\n")
+  file (APPEND ${link_arguments} "-lskia\n")
+  file (APPEND ${link_arguments} "-Wl,-rpath,${CMAKE_BINARY_DIR}\n")
+else()
+  file (WRITE ${link_arguments} "${CMAKE_BINARY_DIR}/libskia.a\n")
+  foreach (lib ${libs})
+    if (EXISTS ${lib})
+      get_filename_component(lib_path ${lib} ABSOLUTE)
+      file (APPEND ${link_arguments} "${lib_path}\n")
+    else()
+      file (APPEND ${link_arguments} "-l${lib}\n")
+    endif()
+  endforeach()
+endif()
 
 # skia_compile_arguments.txt
 set (compile_arguments ${CMAKE_BINARY_DIR}/skia_compile_arguments.txt)
diff --git a/cmake/README.md b/cmake/README.md
index f8a54f3..59375609 100644
--- a/cmake/README.md
+++ b/cmake/README.md
@@ -32,4 +32,5 @@
       * Configure with `cmake . -G "Visual Studio 14 2015"` .
       * Compile with `cmake --build . --config Release` .
       * Still has too many warnings.
-      * Poorly tested as yet.
\ No newline at end of file
+      * Poorly tested as yet.
+