From eedce73cdb841fd8d5643afe4e19104c29266091 Mon Sep 17 00:00:00 2001
From: fherrero <fherrero@iri.upc.edu>
Date: Wed, 13 May 2020 12:54:39 +0200
Subject: [PATCH] Update Find cmake with correct paths and path order

---
 Findfirewire_camera.cmake | 40 +++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/Findfirewire_camera.cmake b/Findfirewire_camera.cmake
index 367e6af..6aac029 100644
--- a/Findfirewire_camera.cmake
+++ b/Findfirewire_camera.cmake
@@ -1,22 +1,26 @@
-FIND_PATH(firewire_camera_INCLUDE_DIRS firewirecamera.h firewireserver.h firewireexceptions.h ptg_camera.h bumblebee.h ladybug.h /usr/local/include/iri/firewire_camera /usr/include/iri/firewire_camera)
+SET(name battery_monitor)
+#edit the following line to add the librarie's header files
+SET(header_files firewirecamera.h firewireserver.h firewireexceptions.h ptg_camera.h bumblebee.h ladybug.h)
 
-FIND_LIBRARY(firewire_camera_LIBRARIES
-    NAMES firewire_camera
-    PATHS /usr/local/lib/iri/firewire_camera /usr/lib/iri/firewire_camera)
+FIND_PATH(${name}_INCLUDE_DIRS ${header_files} /usr/local/include/iri/${name} /usr/include/iri/${name})
+
+FIND_LIBRARY(${name}_LIBRARIES
+    NAMES ${name}
+    PATHS /usr/local/lib/iri/${name} /usr/lib/iri/${name})
     
-SET(firewire_camera_INCLUDE_DIR ${firewire_camera_INCLUDE_DIRS})
-SET(firewire_camera_LIBRARY     ${firewire_camera_LIBRARIES})
+SET(${name}_INCLUDE_DIR ${${name}_INCLUDE_DIRS})
+SET(${name}_LIBRARY     ${${name}_LIBRARIES})
 
-IF (firewire_camera_INCLUDE_DIRS AND firewire_camera_LIBRARIES)
-   SET(firewire_camera_FOUND TRUE)
-ENDIF (firewire_camera_INCLUDE_DIRS AND firewire_camera_LIBRARIES)
+IF (${name}_INCLUDE_DIRS AND ${name}_LIBRARIES)
+   SET(${name}_FOUND TRUE)
+ENDIF (${name}_INCLUDE_DIRS AND ${name}_LIBRARIES)
 
-IF (firewire_camera_FOUND)
-   IF (NOT firewire_camera_FIND_QUIETLY)
-      MESSAGE(STATUS "Found firewire_camera camera driver: ${firewire_camera_LIBRARIES}")
-   ENDIF (NOT firewire_camera_FIND_QUIETLY)
-ELSE (firewire_camera_FOUND)
-   IF (firewire_camera_FIND_REQUIRED)
-      MESSAGE(FATAL_ERROR "Could not find firewire_camera camera driver")
-   ENDIF (firewire_camera_FIND_REQUIRED)
-ENDIF (firewire_camera_FOUND)
+IF (${name}_FOUND)
+   IF (NOT ${name}_FIND_QUIETLY)
+      MESSAGE(STATUS "Found ${name}: ${${name}_LIBRARIES}")
+   ENDIF (NOT ${name}_FIND_QUIETLY)
+ELSE (${name}_FOUND)
+   IF (${name}_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find ${name}")
+   ENDIF (${name}_FIND_REQUIRED)
+ENDIF (${name}_FOUND)
\ No newline at end of file
-- 
GitLab