Add support for lib_dirs to gn_to_cmake.py.

The vulcan code uses lib_dirs to point to the libs in the SDK.

Change-Id: I4a1a4235b8534f3f937640b10f9758b0c70434c9
Reviewed-on: https://skia-review.googlesource.com/4003
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/gn/gn_to_cmake.py b/gn/gn_to_cmake.py
index 86906f5..8b4f484 100644
--- a/gn/gn_to_cmake.py
+++ b/gn/gn_to_cmake.py
@@ -579,6 +579,10 @@
   # Non-OBJECT library dependencies.
   external_libraries = target.properties.get('libs', [])
   if target.cmake_type.is_linkable and (external_libraries or libraries):
+    library_dirs = target.properties.get('lib_dirs', [])
+    if library_dirs:
+      SetVariableList(out, '${target}__library_directories', library_dirs)
+
     system_libraries = []
     for external_library in external_libraries:
       if '/' in external_library:
@@ -586,12 +590,19 @@
       else:
         if external_library.endswith('.framework'):
           external_library = external_library[:-len('.framework')]
-        system_library = external_library + '__library'
+        system_library = 'library__' + external_library
+        if library_dirs:
+          system_library = system_library + '__for_${target}'
         out.write('find_library("')
         out.write(CMakeStringEscape(system_library))
         out.write('" "')
         out.write(CMakeStringEscape(external_library))
-        out.write('")\n')
+        out.write('"')
+        if library_dirs:
+          out.write(' PATHS "')
+          WriteVariable(out, '${target}__library_directories')
+          out.write('"')
+        out.write(')\n')
         system_libraries.append(system_library)
     out.write('target_link_libraries("${target}"')
     for library in libraries: