Make building with X11 libraries optional.

Desktop capturing on Linux will be disabled in this case, but everything
can be built without any X11 development libraries installed.

BUG=webrtc:5716,webrtc:8319

Change-Id: I01bd6a4b02816b407be19476e22ff073d264b496
Reviewed-on: https://webrtc-review.googlesource.com/32360
Reviewed-by: Henrik Andreassson (OOO until Jan 2) <henrika@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Commit-Queue: Joachim Bauch <jbauch@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21462}
diff --git a/modules/BUILD.gn b/modules/BUILD.gn
index 33394f4..1f93e99 100644
--- a/modules/BUILD.gn
+++ b/modules/BUILD.gn
@@ -17,7 +17,6 @@
     "audio_processing",
     "bitrate_controller",
     "congestion_controller",
-    "desktop_capture",
     "media_file",
     "pacing",
     "remote_bitrate_estimator",
@@ -26,6 +25,10 @@
     "video_coding",
     "video_processing",
   ]
+
+  if (rtc_desktop_capture_supported) {
+    deps += [ "desktop_capture" ]
+  }
 }
 
 rtc_source_set("module_api_public") {
@@ -83,13 +86,16 @@
       "../test:test_main",
       "../test:video_test_common",
       "audio_coding:audio_coding_modules_tests",
-      "desktop_capture:desktop_capture_modules_tests",
       "rtp_rtcp:rtp_rtcp_modules_tests",
       "video_coding:video_coding_modules_tests",
       "//testing/gmock",
       "//testing/gtest",
     ]
 
+    if (rtc_desktop_capture_supported) {
+      deps += [ "desktop_capture:desktop_capture_modules_tests" ]
+    }
+
     data = modules_tests_resources
 
     if (is_android) {
@@ -253,7 +259,6 @@
       "audio_processing:audio_processing_unittests",
       "bitrate_controller:bitrate_controller_unittests",
       "congestion_controller:congestion_controller_unittests",
-      "desktop_capture:desktop_capture_unittests",
       "media_file:media_file_unittests",
       "pacing:pacing_unittests",
       "remote_bitrate_estimator:remote_bitrate_estimator_unittests",
@@ -264,6 +269,10 @@
       "video_processing:video_processing_unittests",
     ]
 
+    if (rtc_desktop_capture_supported) {
+      deps += [ "desktop_capture:desktop_capture_unittests" ]
+    }
+
     data = modules_unittests_resources
 
     if (is_android) {