The goal of this CL is to separate Obj-C/Obj-C++ code from targets which have
also C++ code (see https://bugs.chromium.org/p/webrtc/issues/detail?id=7743
for more information).

To achieve this we have created 2 targets (desktop_capture_objc and
desktop_capture_generic) and desktop_capture will act as a proxy between these
targets (this way we can avoid a circular dependency between
desktop_capture_generic and desktop_capture_objc).

BUG=webrtc:7743

Review-Url: https://codereview.webrtc.org/2989053002
Cr-Commit-Position: refs/heads/master@{#19607}
diff --git a/webrtc/modules/desktop_capture/BUILD.gn b/webrtc/modules/desktop_capture/BUILD.gn
index 92d670c..2f8f8bf 100644
--- a/webrtc/modules/desktop_capture/BUILD.gn
+++ b/webrtc/modules/desktop_capture/BUILD.gn
@@ -165,7 +165,45 @@
   }
 }
 
-rtc_static_library("desktop_capture") {
+rtc_source_set("desktop_capture") {
+  if (is_mac) {
+    public_deps = [
+      ":desktop_capture_objc",
+    ]
+  } else {
+    public_deps = [
+      ":desktop_capture_generic",
+    ]
+  }
+}
+
+if (is_mac) {
+  rtc_source_set("desktop_capture_objc") {
+    visibility = [ ":*" ]
+    sources = [
+      "mac/desktop_configuration.mm",
+      "mouse_cursor_monitor_mac.mm",
+      "screen_capturer_mac.mm",
+      "window_capturer_mac.mm",
+    ]
+    public_deps = [
+      ":desktop_capture_generic",
+    ]
+    deps = [
+      ":primitives",
+      "../../rtc_base:rtc_base",
+      "../../rtc_base:rtc_base_approved",
+    ]
+    libs = [
+      "AppKit.framework",
+      "IOKit.framework",
+      "OpenGL.framework",
+    ]
+  }
+}
+
+rtc_static_library("desktop_capture_generic") {
+  visibility = [ ":*" ]
   sources = [
     "blank_detector_desktop_capturer_wrapper.cc",
     "blank_detector_desktop_capturer_wrapper.h",
@@ -191,7 +229,6 @@
     "fallback_desktop_capturer_wrapper.cc",
     "fallback_desktop_capturer_wrapper.h",
     "mac/desktop_configuration.h",
-    "mac/desktop_configuration.mm",
     "mac/desktop_configuration_monitor.cc",
     "mac/desktop_configuration_monitor.h",
     "mac/full_screen_chrome_window_detector.cc",
@@ -203,7 +240,6 @@
     "mouse_cursor.cc",
     "mouse_cursor.h",
     "mouse_cursor_monitor.h",
-    "mouse_cursor_monitor_mac.mm",
     "mouse_cursor_monitor_win.cc",
     "resolution_tracker.cc",
     "resolution_tracker.h",
@@ -212,7 +248,6 @@
     "screen_capture_frame_queue.h",
     "screen_capturer_helper.cc",
     "screen_capturer_helper.h",
-    "screen_capturer_mac.mm",
     "screen_capturer_win.cc",
     "win/cursor.cc",
     "win/cursor.h",
@@ -251,7 +286,6 @@
     "win/screen_capturer_win_magnifier.h",
     "win/window_capture_utils.cc",
     "win/window_capture_utils.h",
-    "window_capturer_mac.mm",
     "window_capturer_win.cc",
     "window_finder.h",
     "window_finder_mac.h",
@@ -289,14 +323,6 @@
     ]
   }
 
-  if (is_mac) {
-    libs = [
-      "AppKit.framework",
-      "IOKit.framework",
-      "OpenGL.framework",
-    ]
-  }
-
   if (is_win) {
     libs = [
       "d3d11.lib",