Warning, /system/qtcurve/cmake/CMakePathMacros.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 0028 include(CMakeArrayMacros) 0029 0030 function(cmake_utils_abs_path var path) 0031 get_filename_component(abs_path "${path}" ABSOLUTE) 0032 if("x${abs_path}x" MATCHES "^x//") 0033 string(SUBSTRING "${abs_path}" 1 -1 abs_path) 0034 endif() 0035 set("${var}" "${abs_path}" PARENT_SCOPE) 0036 endfunction() 0037 0038 macro(__cmake_utils_to_abs_foreach) 0039 if("x${${__cmake_utils_to_abs_path_value}}x" STREQUAL xx) 0040 return() 0041 endif() 0042 cmake_utils_abs_path("${__cmake_utils_to_abs_path_value}" 0043 "${${__cmake_utils_to_abs_path_value}}") 0044 set("${__cmake_utils_to_abs_path_value}" 0045 "${${__cmake_utils_to_abs_path_value}}" PARENT_SCOPE) 0046 endmacro() 0047 0048 function(cmake_utils_to_abs) 0049 cmake_array_foreach(__cmake_utils_to_abs_path_value 0050 __cmake_utils_to_abs_foreach) 0051 endfunction() 0052 0053 function(cmake_utils_is_subpath ret_var parent child) 0054 cmake_utils_to_abs(parent child) 0055 file(RELATIVE_PATH rel_path "${parent}" "${child}") 0056 string(REGEX MATCH "^\\.\\./" match "${rel_path}") 0057 if(match) 0058 set("${ret_var}" False PARENT_SCOPE) 0059 else() 0060 set("${ret_var}" True PARENT_SCOPE) 0061 endif() 0062 endfunction() 0063 0064 function(__cmake_utils_src_to_bin_with_path out path src_path bin_path) 0065 cmake_utils_is_subpath(issub "${src_path}" "${path}") 0066 if(issub) 0067 file(RELATIVE_PATH rel_path "${src_path}" "${path}") 0068 cmake_utils_abs_path(path "${bin_path}/${rel_path}") 0069 set("${out}" "${path}" PARENT_SCOPE) 0070 endif() 0071 endfunction() 0072 0073 function(cmake_utils_src_to_bin out path) 0074 set(bin_path) 0075 __cmake_utils_src_to_bin_with_path(bin_path "${path}" 0076 "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") 0077 if(NOT "x${bin_path}" STREQUAL "x") 0078 set("${out}" "${bin_path}" PARENT_SCOPE) 0079 return() 0080 endif() 0081 __cmake_utils_src_to_bin_with_path(bin_path "${path}" 0082 "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}") 0083 if(NOT "x${bin_path}" STREQUAL "x") 0084 set("${out}" "${bin_path}" PARENT_SCOPE) 0085 return() 0086 endif() 0087 __cmake_utils_src_to_bin_with_path(bin_path "${path}" 0088 "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}") 0089 if(NOT "x${bin_path}" STREQUAL "x") 0090 set("${out}" "${bin_path}" PARENT_SCOPE) 0091 return() 0092 endif() 0093 set("${out}" "${path}" PARENT_SCOPE) 0094 endfunction() 0095 0096 function(_cmake_utils_std_fname_with_dirs var bin src fname) 0097 cmake_utils_is_subpath(is_bin "${bin}" "${fname}") 0098 cmake_utils_is_subpath(is_src "${src}" "${fname}") 0099 if(is_bin OR is_src) 0100 if(NOT is_src) 0101 file(RELATIVE_PATH rel_path "${bin}" "${fname}") 0102 elseif(NOT is_bin) 0103 file(RELATIVE_PATH rel_path "${src}" "${fname}") 0104 else() 0105 cmake_utils_is_subpath(bin_in_src "${src}" "${bin}") 0106 if(bin_in_src) 0107 file(RELATIVE_PATH rel_path "${bin}" "${fname}") 0108 else() 0109 file(RELATIVE_PATH rel_path "${src}" "${fname}") 0110 endif() 0111 endif() 0112 set("${var}" "${rel_path}" PARENT_SCOPE) 0113 else() 0114 set("${var}" "" PARENT_SCOPE) 0115 endif() 0116 endfunction() 0117 0118 function(cmake_utils_std_fname var fname) 0119 cmake_utils_to_abs(fname) 0120 _cmake_utils_std_fname_with_dirs(cur_rel_path "${CMAKE_CURRENT_BINARY_DIR}" 0121 "${CMAKE_CURRENT_SOURCE_DIR}" "${fname}") 0122 if(NOT "x${cur_rel_path}x" STREQUAL "xx") 0123 set("${var}" "${cur_rel_path}" PARENT_SCOPE) 0124 return() 0125 endif() 0126 _cmake_utils_std_fname_with_dirs(pro_rel_path "${PROJECT_BINARY_DIR}" 0127 "${PROJECT_SOURCE_DIR}" "${fname}") 0128 if(NOT "x${pro_rel_path}x" STREQUAL "xx") 0129 set("${var}" "${pro_rel_path}" PARENT_SCOPE) 0130 return() 0131 endif() 0132 _cmake_utils_std_fname_with_dirs(cmake_rel_path "${CMAKE_BINARY_DIR}" 0133 "${CMAKE_SOURCE_DIR}" "${fname}") 0134 if(NOT "x${cmake_rel_path}x" STREQUAL "xx") 0135 set("${var}" "${cmake_rel_path}" PARENT_SCOPE) 0136 return() 0137 endif() 0138 set("${var}" "${fname}" PARENT_SCOPE) 0139 endfunction()