diff --git a/.appveyor/install.bat b/.appveyor/install.bat
index f9f53a73d..3474375b4 100644
--- a/.appveyor/install.bat
+++ b/.appveyor/install.bat
@@ -27,10 +27,6 @@ GOTO:EOF
     call:logInfo "Clone dependencies repository"
     git clone -q --branch=master https://github.com/telegramdesktop/dependencies_windows.git %LIB_DIR%
     cd %LIB_DIR%
-
-    call:logInfo "Clone GSL"
-    git clone https://github.com/Microsoft/GSL.git
-
     call prepare.bat
 GOTO:EOF
 
@@ -39,6 +35,9 @@ GOTO:EOF
     cd %LIB_DIR%
     git clone https://chromium.googlesource.com/external/gyp
     SET PATH=%PATH%;C:\TBuild\Libraries\gyp;C:\TBuild\Libraries\ninja;
+    cd %SRC_DIR%
+    git submodule init
+    git submodule update
     cd %SRC_DIR%\Telegram
     call gyp\refresh.bat
 GOTO:EOF
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 000000000..fd09b6bea
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "third_party/GSL"]
+	path = third_party/GSL
+	url = https://github.com/Microsoft/GSL.git
diff --git a/.travis/build.sh b/.travis/build.sh
index f6e97b10d..320c8a873 100755
--- a/.travis/build.sh
+++ b/.travis/build.sh
@@ -543,8 +543,9 @@ buildCustomQt() {
 }
 
 getGSL() {
-  cd "$EXTERNAL"
-  git clone https://github.com/Microsoft/GSL.git
+  cd "$UPSTREAM"
+  git submodule init
+  git submodule update
 }
 
 getGYP() {
@@ -602,7 +603,6 @@ buildTelegram() {
   cd "$UPSTREAM/Telegram/gyp"
   "$GYP_PATH/gyp" \
       -Dbuild_defines=${GYP_DEFINES:1} \
-      -Dlinux_path_gsl=$EXTERNAL/GSL \
       -Dlinux_path_xkbcommon=$XKB_PATH \
       -Dlinux_path_va=$VA_PATH \
       -Dlinux_path_vdpau=$VDPAU_PATH \
diff --git a/Telegram/gyp/Telegram.gyp b/Telegram/gyp/Telegram.gyp
index 636b6842a..cbb9e047c 100644
--- a/Telegram/gyp/Telegram.gyp
+++ b/Telegram/gyp/Telegram.gyp
@@ -30,6 +30,7 @@
       'libs_loc': '<(libs_loc)',
       'src_loc': '../SourceFiles',
       'res_loc': '../Resources',
+      'submodules_loc': '../../third_party',
       'third_party_loc': '../ThirdParty',
       'minizip_loc': '<(third_party_loc)/minizip',
       'sp_media_key_tap_loc': '<(third_party_loc)/SPMediaKeyTap',
@@ -94,7 +95,7 @@
       '<(libs_loc)/openal-soft/include',
       '<(minizip_loc)',
       '<(sp_media_key_tap_loc)',
-      '<(libs_loc)/GSL/include',
+      '<(submodules_loc)/GSL/include',
     ],
     'sources': [
       '<@(qrc_files)',
diff --git a/Telegram/gyp/telegram_linux.gypi b/Telegram/gyp/telegram_linux.gypi
index dd17ac26d..b42e7443f 100644
--- a/Telegram/gyp/telegram_linux.gypi
+++ b/Telegram/gyp/telegram_linux.gypi
@@ -33,14 +33,12 @@
       'linux_path_va%': '/usr/local',
       'linux_path_vdpau%': '/usr/local',
       'linux_path_breakpad%': '<(libs_loc)/breakpad',
-      'linux_path_gsl%': '<(libs_loc)/GSL',
     },
     'include_dirs': [
       '/usr/local/include',
       '<(linux_path_ffmpeg)/include',
       '<(linux_path_openal)/include',
       '<(linux_path_breakpad)/include/breakpad',
-      '<(linux_path_gsl)/include',
     ],
     'library_dirs': [
       '/usr/local/lib',
diff --git a/doc/building-cmake.md b/doc/building-cmake.md
index 5bbe35f10..ddcdb0534 100644
--- a/doc/building-cmake.md
+++ b/doc/building-cmake.md
@@ -21,7 +21,7 @@ Choose a folder for the future build, for example **/home/user/TBuild** There yo
 
 By git – in Terminal go to **/home/user/TBuild** and run
 
-    git clone https://github.com/telegramdesktop/tdesktop.git
+    git clone --recursive https://github.com/telegramdesktop/tdesktop.git
 
 ###Prepare libraries
 
@@ -29,10 +29,6 @@ Install dev libraries
 
     sudo apt-get install libexif-dev liblzma-dev libz-dev libssl-dev libappindicator-dev libunity-dev libicu-dev libdee-dev
 
-From **/home/user/TBuild/Libraries** run
-
-    git clone https://github.com/Microsoft/GSL.git
-
 ####zlib 1.2.8
 
 http://www.zlib.net/ > Download [**zlib source code, version 1.2.8, zipfile format**](http://zlib.net/zlib128.zip)
diff --git a/doc/building-msvc.md b/doc/building-msvc.md
index ab29022a9..431f61d8e 100644
--- a/doc/building-msvc.md
+++ b/doc/building-msvc.md
@@ -46,15 +46,11 @@ Go to **D:\\TBuild**
 
 and run
 
-    git clone https://github.com/telegramdesktop/tdesktop.git
+    git clone --recursive https://github.com/telegramdesktop/tdesktop.git
     mkdir Libraries
 
 ## Prepare libraries
 
-From **D:\\TBuild\\Libraries** run
-
-    git clone https://github.com/Microsoft/GSL.git
-
 ### OpenSSL
 
 Go to **D:\\TBuild\\Libraries** and run
diff --git a/doc/building-qtcreator.md b/doc/building-qtcreator.md
index 0c27ad5a8..ff8a1154e 100644
--- a/doc/building-qtcreator.md
+++ b/doc/building-qtcreator.md
@@ -24,7 +24,7 @@ Choose a folder for the future build, for example **/home/user/TBuild** There yo
 
 By git – in Terminal go to **/home/user/TBuild** and run
 
-    git clone https://github.com/telegramdesktop/tdesktop.git
+    git clone --recursive https://github.com/telegramdesktop/tdesktop.git
 
 ###Prepare libraries
 
@@ -32,10 +32,6 @@ Install dev libraries
 
     sudo apt-get install libexif-dev liblzma-dev libz-dev libssl-dev libappindicator-dev libunity-dev
 
-From **/home/user/TBuild/Libraries** run
-
-    git clone https://github.com/Microsoft/GSL.git
-
 ####zlib 1.2.8
 
 http://www.zlib.net/ > Download [**zlib source code, version 1.2.8, zipfile format**](http://zlib.net/zlib128.zip)
diff --git a/doc/building-xcode-old.md b/doc/building-xcode-old.md
index 1ff67df0b..215f9e567 100644
--- a/doc/building-xcode-old.md
+++ b/doc/building-xcode-old.md
@@ -10,7 +10,7 @@ Choose a folder for the future build, for example **/Users/user/TBuild** There y
 
 By git – in Terminal go to **/Users/user/TBuild** and run
 
-    git clone https://github.com/telegramdesktop/tdesktop.git
+    git clone --recursive https://github.com/telegramdesktop/tdesktop.git
 
 then go to **/Users/user/TBuild/tdesktop** and run
 
@@ -32,10 +32,6 @@ In your build Terminal run
 
 to set minimal supported OS version to 10.6 for future console builds.
 
-From **/Users/user/TBuild/Libraries** run
-
-    git clone https://github.com/Microsoft/GSL.git
-
 ####custom build of libc++
 
 From **/Users/user/TBuild/Libraries/macold** run
diff --git a/doc/building-xcode.md b/doc/building-xcode.md
index c68f82367..43a543d98 100644
--- a/doc/building-xcode.md
+++ b/doc/building-xcode.md
@@ -12,7 +12,7 @@ There you will have two folders, **Libraries** for third-party libs and **tdeskt
 
 By git – in Terminal go to **/Users/user/TBuild** and run:
 
-    git clone https://github.com/telegramdesktop/tdesktop.git
+    git clone --recursive https://github.com/telegramdesktop/tdesktop.git
 
 ###Prepare libraries
 
@@ -22,10 +22,6 @@ In your build Terminal run:
 
 to set minimal supported OS version to 10.8 for future console builds.
 
-From **/Users/user/TBuild/Libraries** run
-
-    git clone https://github.com/Microsoft/GSL.git
-
 ####zlib 1.2.8
 
 http://www.zlib.net/ > Download [**zlib source code, version 1.2.8**](http://www.zlib.net/fossils/zlib-1.2.8.tar.gz)
diff --git a/third_party/GSL b/third_party/GSL
new file mode 160000
index 000000000..f9c47dd63
--- /dev/null
+++ b/third_party/GSL
@@ -0,0 +1 @@
+Subproject commit f9c47dd63fe25cc216294fbe7e2fbe4f9a302ca3