Warning, /system/qtcurve/cmake/CMakeStringMacros.cmake is written in an unsupported language. File is not indexed.
0001 # Copyright (C) 2013~2014 by Yichao Yu 0002 # yyc1992@gmail.com 0003 # 0004 # Redistribution and use in source and binary forms, with or without 0005 # modification, are permitted provided that the following conditions 0006 # are met: 0007 # 0008 # 1. Redistributions of source code must retain the above copyright 0009 # notice, this list of conditions and the following disclaimer. 0010 # 2. Redistributions in binary form must reproduce the above copyright 0011 # notice, this list of conditions and the following disclaimer in the 0012 # documentation and/or other materials provided with the distribution. 0013 # 0014 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0015 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0016 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0017 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0018 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0019 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0020 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0021 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0022 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0023 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0024 0025 # Public functions and macros provided by this file 0026 # (See comment of each for more detail): 0027 # cmake_str_quote_cmake 0028 # cmake_str_quote_shell 0029 0030 if(COMMAND cmake_str_quote_cmake) 0031 return() 0032 endif() 0033 0034 # cmake_str_quote_cmake(string var_name) 0035 # @string: the string to be quoted 0036 # @var_name: the variable to save the result 0037 # 0038 # This function quote the @string and save it into @var_name so that 0039 # it can be used directly as an argument in a cmake command. 0040 function(cmake_str_quote_cmake str var) 0041 string(REGEX REPLACE "\\\\" "\\\\\\\\" str "${str}") 0042 string(REGEX REPLACE "\\(" "\\\\\(" str "${str}") 0043 string(REGEX REPLACE "\\)" "\\\\\)" str "${str}") 0044 string(REGEX REPLACE "\\\$" "\\\\\$" str "${str}") 0045 string(REGEX REPLACE "\n" "\\\\n" str "${str}") 0046 string(REGEX REPLACE "\"" "\\\\\"" str "${str}") 0047 set("${var}" "\"${str}\"" PARENT_SCOPE) 0048 endfunction() 0049 0050 # cmake_str_quote_shell(string var_name) 0051 # @string: the string to be quoted 0052 # @var_name: the variable to save the result 0053 # 0054 # This function quote the @string and save it into @var_name so that 0055 # it can be used directly as an argument in a shell command. 0056 function(cmake_str_quote_shell str var) 0057 if("x${str}x" MATCHES "^x[-_a-zA-Z0-9]+x\$") 0058 set("${var}" "${str}" PARENT_SCOPE) 0059 else() 0060 string(REGEX REPLACE "'" "'\\\\''" escaped "${str}") 0061 set("${var}" "'${escaped}'" PARENT_SCOPE) 0062 endif() 0063 endfunction()