diff --git a/components/operators/CMakeLists.txt b/components/operators/CMakeLists.txt
index 15dfb638e89e0ed37916d46b674d6471b245df09..4bdf407c481334459285e1cf5589449375f4185a 100644
--- a/components/operators/CMakeLists.txt
+++ b/components/operators/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_library(ftloperators
+set(OPERSRC
 	src/smoothing.cpp
 	src/smoothing.cu
 	src/mls.cu
@@ -10,9 +10,14 @@ add_library(ftloperators
 	src/filling.cu
 	src/segmentation.cu
 	src/segmentation.cpp
-	src/nvopticalflow.cpp
 )
 
+if (HAVE_OPTFLOW)
+	list(APPEND OPERSRC src/nvopticalflow.cpp)
+endif()
+
+add_library(ftloperators ${OPERSRC})
+
 # These cause errors in CI build and are being removed from PCL in newer versions
 # target_compile_options(ftlrender PUBLIC ${PCL_DEFINITIONS})
 
diff --git a/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp b/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp
index b7c0c73c8af2bf5d66d9b2572f849e4d1a794b20..dc23f42e5d0fc4d847dd39e5bdf2e9117120a745 100644
--- a/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp
+++ b/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp
@@ -2,7 +2,10 @@
 #include "stereovideo.hpp"
 
 #include <ftl/configuration.hpp>
+
+#ifdef HAVE_OPTFLOW
 #include <ftl/operators/opticalflow.hpp>
+#endif
 
 #include <ftl/threads.hpp>
 #include "calibrate.hpp"