diff --git a/build.rs b/build.rs
new file mode 100644
index 000000000..ffc164650
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,23 @@
+fn main() {
+    #[cfg(not(any(
+        feature = "runtime-tokio-hyper",
+        feature = "runtime-tokio-hyper-rustls",
+        feature = "runtime-tokio-hyper-rustls-webpki",
+        feature = "runtime-blocking",
+        feature = "runtime-blocking-rustls",
+        feature = "runtime-blocking-rustls-webpki",
+        feature = "runtime-async-std-surf",
+    )))]
+    compile_error!(
+        r"one of the following runtime features must be enabled:
+        [
+            'runtime-tokio-hyper',
+            'runtime-tokio-hyper-rustls',
+            'runtime-tokio-hyper-rustls-webpki',
+            'runtime-blocking',
+            'runtime-blocking-rustls',
+            'runtime-blocking-rustls-webpki',
+            'runtime-async-std-surf'
+        ]"
+    );
+}
\ No newline at end of file
diff --git a/src/lib.rs b/src/lib.rs
index e83b56b10..11bcab1ec 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -61,28 +61,6 @@
 // a runtime feature, but that does not seem currently possible:
 // https://github.com/rust-lang/rust/issues/68838
 
-#[cfg(not(any(
-    feature = "runtime-tokio-hyper",
-    feature = "runtime-tokio-hyper-rustls",
-    feature = "runtime-tokio-hyper-rustls-webpki",
-    feature = "runtime-blocking",
-    feature = "runtime-blocking-rustls",
-    feature = "runtime-blocking-rustls-webpki",
-    feature = "runtime-async-std-surf",
-)))]
-compile_error!(
-    r"one of the following runtime features must be enabled:
-    [
-        'runtime-tokio-hyper',
-        'runtime-tokio-hyper-rustls',
-        'runtime-tokio-hyper-rustls-webpki',
-        'runtime-blocking',
-        'runtime-blocking-rustls',
-        'runtime-blocking-rustls-webpki',
-        'runtime-async-std-surf'
-    ]"
-);
-
 mod client;
 mod error;
 mod ids;