From 1727228e5070a8b397c77a7ec921873ddd235b64 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= <jvallve@iri.upc.edu>
Date: Tue, 17 May 2022 13:06:06 +0200
Subject: [PATCH] dealing empty list

---
 CMakeLists.txt | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6736c5e..cecc888 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,20 +53,22 @@ FIND_PACKAGE(falkolib QUIET)
 find_package(PkgConfig)
 pkg_check_modules(csm QUIET csm )
 link_directories(${csm_LIBRARY_DIRS})
-message(csm_LIBRARY_DIRS: ${csm_LIBRARY_DIRS})
-# keep only the files in a lib folder: by default the "." is in csm_LIBRARY_DIRS, 
-# which is not acceptable for target_link_directories 
-foreach (my_entry IN LISTS csm_LIBRARY_DIRS)
-    message("csm_LIBRARY_DIRS has ${my_entry}")
-endforeach()
-list(FILTER csm_LIBRARY_DIRS INCLUDE REGEX "lib")
-foreach (my_entry IN LISTS csm_LIBRARY_DIRS)
-    message("csm_LIBRARY_DIRS has ${my_entry}")
-endforeach()
-
-
-
-
+if(csm_FOUND)
+  if(NOT csm_LIBRARY_DIRS)
+  message("csm_LIBRARY_DIRS is empty")
+  else()
+    # keep only the files in a lib folder: by default the "." is in csm_LIBRARY_DIRS, 
+    # which is not acceptable for target_link_directories 
+    message(csm_LIBRARY_DIRS:)
+    foreach (my_entry IN LISTS csm_LIBRARY_DIRS)
+        message("csm_LIBRARY_DIRS has ${my_entry}")
+    endforeach()
+    list(FILTER csm_LIBRARY_DIRS INCLUDE REGEX "lib")
+    foreach (my_entry IN LISTS csm_LIBRARY_DIRS)
+        message("csm_LIBRARY_DIRS has ${my_entry}")
+    endforeach()
+  endif()
+endif()
 
 # ============ INCLUDES ============ 
 INCLUDE_DIRECTORIES("include")
-- 
GitLab