diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt
index 34eb7f7..7ca30a1 100644
--- a/thirdparty/CMakeLists.txt
+++ b/thirdparty/CMakeLists.txt
@@ -59,10 +59,12 @@ if (CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
     include_with_scope (libbacktrace.cmake)
 endif ()
 
-# We use non-standard C++ flags, so we can't just use GTest's CMakeLists.txt
-if (NOT GTEST_FOUND)
-    message (STATUS "Using bundled GTest")
-    include_with_scope (gtest.cmake)
+if (BUILD_TESTING)
+  # We use non-standard C++ flags, so we can't just use GTest's CMakeLists.txt
+  if (NOT GTEST_FOUND)
+      message (STATUS "Using bundled GTest")
+      include_with_scope (gtest.cmake)
+  endif ()
 endif ()
 
 if (MSVC)
