From 77fef0bd4ee8225dd004e20298d3dfc83cbd0927 Mon Sep 17 00:00:00 2001
From: Rashad Kanavath <rashad.kanavath@c-s.fr>
Date: Thu, 19 Jan 2017 11:19:02 +0100
Subject: [PATCH] BUG: wrong variable used in itk post install patch script

---
 SuperBuild/CMake/post_install.cmake | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/SuperBuild/CMake/post_install.cmake b/SuperBuild/CMake/post_install.cmake
index e211e653fd..75572f4f74 100644
--- a/SuperBuild/CMake/post_install.cmake
+++ b/SuperBuild/CMake/post_install.cmake
@@ -3,9 +3,12 @@ string(REPLACE "|" ";" P_DIRS ${P_DIRS})
 foreach( p_dir ${P_DIRS} )
 set(file_list)
 file( GLOB file_list "${p_dir}/*.cmake" )
+list(SORT file_list)
 foreach( cmake_file ${file_list} )
-  file(STRINGS "${cmake_file}" MATCH_FOUND REGEX "${MATCH}")
+
+  file(STRINGS "${cmake_file}" MATCH_FOUND REGEX "${P_MATCH}")
   if(MATCH_FOUND)
+    message("Replacing '${P_MATCH}' with '${P_REPLACE}' in ${cmake_file}")
     file(STRINGS "${cmake_file}" cmake_file_CONTENTS NEWLINE_CONSUME)
     string(REPLACE "${P_MATCH}" "$${}{${P_REPLACE}}" cmake_file_CONTENTS ${cmake_file_CONTENTS})
     file(WRITE "${cmake_file}"  "# This file is modified by OTB after installation.
-- 
GitLab