From 50498f347a212e6b01f28a7dd97eed03b6636e24 Mon Sep 17 00:00:00 2001
From: jcasals <jcasals@iri.upc.edu>
Date: Tue, 1 Oct 2019 10:57:30 +0200
Subject: [PATCH] Made CSM optional

---
 src/CMakeLists.txt | 19 ++++++++++++++-----
 src/icp.cpp        |  1 +
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 041a112..ee3f8e7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,10 +10,12 @@ IF(faramotics_FOUND)
     MESSAGE("Faramotics Library FOUND: Tests requiring it will be built.")
 ENDIF(faramotics_FOUND)
 
-FIND_PACKAGE(csm REQUIRED)
+FIND_PACKAGE(csm QUIET)
 #include directories
 INCLUDE_DIRECTORIES(.)
-INCLUDE_DIRECTORIES(${csm_INCLUDE_DIR})
+IF(csm_FOUND)
+    INCLUDE_DIRECTORIES(${csm_INCLUDE_DIR})
+ENDIF(csm_FOUND)
 IF(Ceres_FOUND)
     INCLUDE_DIRECTORIES(${CERES_INCLUDE_DIRS})
 ENDIF(Ceres_FOUND)
@@ -41,7 +43,11 @@ SET(HDRS
     point_set.h
     polyline.h
     scan_segment.h
-    icp.h)
+    )
+  IF(csm_FOUND)
+    SET(HDRS ${HDRS}
+      icp.h)
+  ENDIF(csm_FOUND)
 
 #sources
 SET(SRCS
@@ -60,8 +66,11 @@ SET(SRCS
     point_set.cpp
     polyline.cpp
     scan_segment.cpp
-    icp.cpp)
-
+    )
+  IF(csm_FOUND)
+    SET(SRCS ${SRCS}
+      icp.cpp)
+  ENDIF(csm_FOUND)
 # create the shared library
 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
 target_link_libraries(${PROJECT_NAME} ${csm_LIBRARY})
diff --git a/src/icp.cpp b/src/icp.cpp
index 4cd599a..b41958d 100644
--- a/src/icp.cpp
+++ b/src/icp.cpp
@@ -88,6 +88,7 @@ icpOutput ICP::align(const LaserScan &_last_ls, const LaserScan &_origin_ls, con
     csm_input.outliers_adaptive_order   = icp_params.outliers_adaptive_order;
     csm_input.outliers_adaptive_mult    = icp_params.outliers_adaptive_mult;
 
+
     csm_input.do_compute_covariance     = 1;
 
     sm_icp(&csm_input, &csm_output);
-- 
GitLab