From 9a647efa0c8d2ace7dee1e51b74bc3aa9f09b6f3 Mon Sep 17 00:00:00 2001
From: Arnaud Degroote <arnaud.degroote@laas.fr>
Date: Fri, 13 Jan 2012 11:53:57 +0100
Subject: [PATCH] [wip/MPC] Add a patch to fix incorrect use of substring on
 cmake < 2.8

---
 MPC/distinfo         |  1 +
 MPC/patches/patch-ab | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)
 create mode 100644 MPC/patches/patch-ab

diff --git a/MPC/distinfo b/MPC/distinfo
index 5bd57aaa..ed44ef93 100644
--- a/MPC/distinfo
+++ b/MPC/distinfo
@@ -2,3 +2,4 @@ SHA1 (MPC-1.0.tar.gz) = a45fe2e16fb0d93673b014ddff38c074218a0517
 RMD160 (MPC-1.0.tar.gz) = 0383006d9f413d201b7b3dc6da8d6169beaf5a4e
 Size (MPC-1.0.tar.gz) = 803443 bytes
 SHA1 (patch-aa) = 66e1c649e6adbb86e6c49256ce8abcc4293f2bc5
+SHA1 (patch-ab) = 6883ab33b9e2e1a469c872d6cbb05ca6c5dc43e3
diff --git a/MPC/patches/patch-ab b/MPC/patches/patch-ab
new file mode 100644
index 00000000..ce2b3f99
--- /dev/null
+++ b/MPC/patches/patch-ab
@@ -0,0 +1,19 @@
+[CMakeLists.txt] Fix it for cmake < 2.8
+
+cmake 2.8 allows a length of -1 in substring, but not previous
+version.  So do manually the size computation before calling
+substring !
+
+--- MPC/CMakeLists.txt
++++ MPC/CMakeLists.txt
+@@ -5,7 +5,9 @@ set(PACKAGE_VERSION 1.0)
+ 
+ macro(GET_LIBRARY_NAME LIBRARY_FULL LIBRARY_NAME)
+ 	get_filename_component(LIBRARY_BASE ${LIBRARY_FULL} NAME_WE)
+-	string(SUBSTRING ${LIBRARY_BASE} 3 -1 PIPO)
++	string(LENGTH ${LIBRARY_BASE} LEN)
++	math(EXPR SUB_LEN "${LEN} - 3")
++	string(SUBSTRING ${LIBRARY_BASE} 3 ${SUB_LEN} PIPO)
+ 	set(${LIBRARY_NAME} ${PIPO})
+ endmacro()
+ 
-- 
GitLab