diff --git a/SuperBuild/Packaging/PackageHelper.cmake b/SuperBuild/Packaging/PackageHelper.cmake
index 91eae8e359fe65c3efb313ba7a719674d4ee1f78..cfaedd82d6acde75b81269506fcdd2234178c18a 100644
--- a/SuperBuild/Packaging/PackageHelper.cmake
+++ b/SuperBuild/Packaging/PackageHelper.cmake
@@ -329,7 +329,9 @@ endfunction() #func_prepare_package
 
 function(func_process_deps input_file)
 
+  set(input_file_full_path)
   search_library(${input_file} PKG_SEARCHDIRS input_file_full_path)
+
   if(NOT input_file_full_path)
     if(LINUX)
       setif_value_in_list(is_gtk_lib "${input_file}" ALLOWED_SYSTEM_DLLS)
@@ -346,10 +348,13 @@ function(func_process_deps input_file)
 
   endif() #if(NOT input_file_full_path)
 
-  message("Processing ${input_file_full_path}")
+  if(NOT PKG_DEBUG)
+    message("Processing ${input_file_full_path}")
+  endif()
 
   set(is_executable FALSE)
   is_file_executable2(input_file_full_path is_executable)
+
   if(NOT is_executable)
     #copy back to input_file_full_path
     pkg_install_rule(${input_file_full_path})
@@ -376,23 +381,23 @@ function(func_process_deps input_file)
           OR  IS_DIRECTORY "${sofile}" )
         set(not_valid TRUE)
       endif()
-      
+
       if(not_valid)
         continue()
       endif()
-      
+
       func_is_file_a_symbolic_link("${sofile}" is_symlink linked_to_file)
-      
+
       if(is_symlink)
         add_to_symlink_list("${linked_to_file}" "${basename_of_sofile}")	
       endif() # is_symlink
-      
+
     endforeach()
-    
+
   endif(UNIX)
-  
+
   set(raw_items)
-     
+
   execute_process(
     COMMAND ${LOADER_PROGRAM} ${LOADER_PROGRAM_ARGS} "${input_file_full_path}"
     RESULT_VARIABLE loader_rv
@@ -410,10 +415,15 @@ function(func_process_deps input_file)
   get_filename_component(bn_name ${input_file_full_path} NAME)
   set(${bn_name}_USED TRUE CACHE INTERNAL "")
 
+  if(PKG_DEBUG)
+    message("Processing ${input_file} started. Set ${bn_name}_USED=${${bn_name}_USED}")
+  endif()
+
   foreach(candidate ${candidates})
     if(NOT candidate)
       continue()
     endif()
+
     if(NOT "${candidate}" MATCHES "${loader_program_regex}")
       continue()
     endif()
@@ -423,25 +433,25 @@ function(func_process_deps input_file)
     if(NOT raw_item)
       continue()
     endif()  
-      
+
     string(STRIP ${raw_item} raw_item)
     set(is_system FALSE)
     setif_value_in_list(is_system "${raw_item}" SYSTEM_DLLS)
 
     if(APPLE AND NOT is_system)
       if("${raw_item}" MATCHES "@rpath")
-	string(REGEX REPLACE "@rpath." "" raw_item "${raw_item}")
+        string(REGEX REPLACE "@rpath." "" raw_item "${raw_item}")
       else()
-	message(FATAL_ERROR "'${raw_item}' does not have @rpath")
+        message(FATAL_ERROR "'${raw_item}' does not have @rpath")
       endif()
     endif()
-    
-    if(is_system  OR ${raw_item}_RESOLVED OR ${raw_item}_USED)
-      continue()        
+
+    if(PKG_DEBUG AND ${raw_item}_RESOLVED)
+      message("${raw_item} is already resolved [${raw_item}_RESOLVED=${${raw_item}_RESOLVED}]")
     endif()
-   
-    if(PKG_DEBUG)
-      message("${raw_item} is not resolved, used. ${raw_item}_RESOLVED | ${raw_item}_USED")
+
+    if(is_system OR ${raw_item}_RESOLVED OR ${raw_item}_USED)
+      continue()
     endif()
     
     list(APPEND raw_items ${raw_item})
@@ -450,7 +460,7 @@ function(func_process_deps input_file)
 
   if(PKG_DEBUG)
     string(REPLACE ";" "\n" raw_items_pretty_print "${raw_items}")
-    message(FATAL_ERROR "raw_items=${raw_items_pretty_print}")
+    # message(FATAL_ERROR "raw_items=${raw_items_pretty_print}")
   endif(PKG_DEBUG)
 
   if(raw_items)
@@ -459,25 +469,25 @@ function(func_process_deps input_file)
       search_library(${item} PKG_SEARCHDIRS item_full_path)
       set(is_a_symlink FALSE)
       set(item_target_file)
-      if(PKG_DEBUG)
-	message("item0=${item_full_path}")
-      endif()
       func_is_file_a_symbolic_link("${item_full_path}" is_a_symlink item_target_file)      
       if(is_a_symlink)
-	set(${item}_RESOLVED TRUE CACHE INTERNAL "")
-	set(item ${item_target_file})
+        set(${item}_RESOLVED TRUE CACHE INTERNAL "")
+        set(item ${item_target_file})
       endif()
       if(PKG_DEBUG)
-	message("running func_process_deps on '${item}'")
+        message("${bn_name} depends on '${item}'. So we now process '${item}'") # [ ${item}_USED=${${item}_USED} ${item}_RESOLVED=${${item}_RESOLVED}]")
       endif()
       func_process_deps(${item})
-  endforeach()
-endif()
-
-set(${bn_name}_RESOLVED TRUE CACHE INTERNAL "")
+    endforeach()
+  endif()
 
-pkg_install_rule(${input_file_full_path})
+  set(${bn_name}_RESOLVED TRUE CACHE INTERNAL "")
+   if(PKG_DEBUG)
+     message("All dependencies of ${bn_name} are processed. Install file and set ${bn_name}_RESOLVED=${${bn_name}_RESOLVED}")
+   endif()
 
+   #Install the file with pkg_install_rule. This function has specific rules to decide wheather install file or not
+   pkg_install_rule(${input_file_full_path})
 
 endfunction() #function(func_process_deps infile)