aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmake/RegexUtils.cmake
diff options
context:
space:
mode:
authorGravatar Frederic Gosselin <gosselin.frederic@ireq.ca>2010-11-22 10:47:07 -0500
committerGravatar Frederic Gosselin <gosselin.frederic@ireq.ca>2010-11-22 10:47:07 -0500
commit4c5932f8f57e8bb63bd7cf12ad03c7ffec0e39fd (patch)
tree3fc5e76820d083aabdd1a8bdd7e905cef94df3f6 /cmake/RegexUtils.cmake
parent5a65d7970a8b4df86a6f5a2759a69a01df8f144d (diff)
Improves the filter for hidden files in "Eigen" and "Eigen/src".
This generic solution prevent cmake from having an error .svn folders when the source folder is under subversion.
Diffstat (limited to 'cmake/RegexUtils.cmake')
-rw-r--r--cmake/RegexUtils.cmake19
1 files changed, 19 insertions, 0 deletions
diff --git a/cmake/RegexUtils.cmake b/cmake/RegexUtils.cmake
new file mode 100644
index 000000000..b59dfc340
--- /dev/null
+++ b/cmake/RegexUtils.cmake
@@ -0,0 +1,19 @@
+function(escape_string_as_regex _str_out _str_in)
+ STRING(REGEX REPLACE "\\\\" "\\\\\\\\" FILETEST2 "${_str_in}")
+ STRING(REGEX REPLACE "([.$+*?|-])" "\\\\\\1" FILETEST2 "${FILETEST2}")
+ STRING(REGEX REPLACE "\\^" "\\\\^" FILETEST2 "${FILETEST2}")
+ STRING(REGEX REPLACE "\\(" "\\\\(" FILETEST2 "${FILETEST2}")
+ STRING(REGEX REPLACE "\\)" "\\\\)" FILETEST2 "${FILETEST2}")
+ STRING(REGEX REPLACE "\\[" "\\\\[" FILETEST2 "${FILETEST2}")
+ STRING(REGEX REPLACE "\\]" "\\\\]" FILETEST2 "${FILETEST2}")
+ SET(${_str_out} "${FILETEST2}" PARENT_SCOPE)
+endfunction()
+
+function(test_escape_string_as_regex)
+ SET(test1 "\\.^$-+*()[]?|")
+ escape_string_as_regex(test2 "${test1}")
+ SET(testRef "\\\\\\.\\^\\$\\-\\+\\*\\(\\)\\[\\]\\?\\|")
+ if(NOT test2 STREQUAL testRef)
+ message("Error in the escape_string_for_regex function : \n ${test1} was escaped as ${test2}, should be ${testRef}")
+ endif(NOT test2 STREQUAL testRef)
+endfunction() \ No newline at end of file