diff --git a/components/operators/CMakeLists.txt b/components/operators/CMakeLists.txt
index f177aa59124c5e08a0321712ace7e9528eb3d7db..9526b69048d5cb74bf48131fc4ac01f594565dfa 100644
--- a/components/operators/CMakeLists.txt
+++ b/components/operators/CMakeLists.txt
@@ -10,7 +10,6 @@ set(OPERSRC
 	src/filling.cu
 	src/disparity/disp2depth.cu
 	src/disparity/disparity_to_depth.cpp
-	src/disparity/fixstars_sgm.cpp
 	src/disparity/bilateral_filter.cpp
 	src/segmentation.cu
 	src/segmentation.cpp
@@ -18,8 +17,14 @@ set(OPERSRC
 	src/mask.cpp
 	src/antialiasing.cpp
 	src/antialiasing.cu
+	src/edges.cpp
 )
 
+
+if (LIBSGM_FOUND)
+	list(APPEND OPERSRC src/disparity/fixstars_sgm.cpp)
+endif (LIBSGM_FOUND)
+
 if (HAVE_OPTFLOW)
 	list(APPEND OPERSRC
 		src/nvopticalflow.cpp
diff --git a/components/operators/include/ftl/operators/disparity.hpp b/components/operators/include/ftl/operators/disparity.hpp
index fa280871d15912a2eee8c384f0535ebbdfdcbc47..0c26c904fbfa8e2dce0d209347b612f6bb719b63 100644
--- a/components/operators/include/ftl/operators/disparity.hpp
+++ b/components/operators/include/ftl/operators/disparity.hpp
@@ -7,16 +7,18 @@
 #include <opencv2/cudaoptflow.hpp>
 #endif
 
+#ifdef HAVE_LIBSGM
 #include <libsgm.h>
+#endif
 
 namespace ftl {
 namespace operators {
 
+#ifdef HAVE_LIBSGM
 /*
  * FixstarsSGM https://github.com/fixstars/libSGM
  * 
  * Requires modified version https://gitlab.utu.fi/joseha/libsgm
- * 
  */
 class FixstarsSGM : public ftl::operators::Operator {
 	public:
@@ -41,6 +43,7 @@ class FixstarsSGM : public ftl::operators::Operator {
 	int max_disp_;
 	float uniqueness_;
 };
+#endif
 
 class DisparityBilateralFilter : public::ftl::operators::Operator {
 	public: