From 931de1e878e8347ab4059763f1d2d363d5b9445c Mon Sep 17 00:00:00 2001
From: "Kilic, Deniz" <d.kilic@fz-juelich.de>
Date: Thu, 9 Jul 2020 10:24:02 +0200
Subject: [PATCH] Compiling libelas as static library

- petrack_core is no longer built using -fpermissive
- libelas is compiled as static library and then linked to petrack
- libelas is now turned OFF by default (since stereo functionality as a
whole is)
---
 CMakeLists.txt | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 74940e17d..98711456c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,7 +50,7 @@ print_var(STEREO)
 option(AVI "Use Avi File from Point Grey (currently not supported)" OFF)
 print_var(AVI)
 
-option(LIBELAS "Use Libelas" ON)
+option(LIBELAS "Use Libelas" OFF)
 print_var(LIBELAS)
 
 option(DISABLE_STEREO "Disable Stereo features (currently must be taken)" ON)
@@ -156,7 +156,7 @@ add_executable(petrack src/main.cpp)
 target_link_libraries(petrack PRIVATE petrack_core)
 
 # TODO we should remove this compile option and be more strict
-target_compile_options(petrack_core PRIVATE "-fpermissive" ${COMMON_COMPILE_OPTIONS})
+target_compile_options(petrack_core PRIVATE ${COMMON_COMPILE_OPTIONS})
 target_compile_definitions(petrack_core PUBLIC STEREO_DISABLED)
 
 #**********************************************************
@@ -205,13 +205,16 @@ target_sources(petrack_core PRIVATE src/analysePlot.cpp)
 #*************************************************************
 if(LIBELAS)
   target_compile_definitions(petrack_core PRIVATE LIBELAS)
-  target_sources(petrack_core PRIVATE
+  add_library(elas STATIC
     src/libelas/elasDescriptor.cpp
     src/libelas/elas.cpp
     src/libelas/elasFilter.cpp
     src/libelas/elasMatrix.cpp
     src/libelas/elasTriangle.cpp
   )
+  target_include_directories(elas PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
+  target_compile_options(elas PRIVATE "-fpermissive")
+  target_link_libraries(petrack_core PRIVATE elas)
 endif(LIBELAS)
 
 # TODO currently not available
-- 
GitLab