Warning, /system/qtcurve/cmake/CMakeHelperMacros.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_utils_reconf_on 0028 # cmake_helper_clear_cache 0029 # cmake_helper_reg 0030 # cmake_helper_wrap_shell 0031 # cmake_helper_wrap_helper 0032 # cmake_helper_add_command 0033 # cmake_helper_set_command 0034 # cmake_helper_add_env 0035 0036 if(COMMAND cmake_helper_reg) 0037 return() 0038 endif() 0039 0040 include(CMakeArgumentMacros) 0041 include(CMakeStringMacros) 0042 include(CMakePathMacros) 0043 0044 ## reconfigure 0045 macro(__cmake_utils_reconf_on_foreach) 0046 string(MD5 fname "${__cmake_utils_reconf_on_value}") 0047 configure_file("${__cmake_utils_reconf_on_value}" 0048 "${reconf_cache}/${fname}" COPYONLY) 0049 # file(REMOVE "${reconf_cache}/${fname}") 0050 endmacro() 0051 0052 # cmake_utils_reconf_on([filenames...]) 0053 # @filenames: names of files to trigger reconfigure when changed. 0054 # 0055 # This function add @filenames to the configure dependencies so that 0056 # the configure stage (i.e. the cmake scripts) will be run again if these 0057 # files are modified. This is useful if the file is read/parsed/executed 0058 # in the configure stage which may produce a different configure result 0059 # when changed. 0060 function(cmake_utils_reconf_on) 0061 cmake_utils_get_global(___CMAKE_UTILS_RECONF_CACHE reconf_cache) 0062 cmake_array_foreach(__cmake_utils_reconf_on_value 0063 __cmake_utils_reconf_on_foreach) 0064 endfunction() 0065 0066 ## clear cache 0067 macro(__cmake_helper_clear_cache_foreach) 0068 execute_process(COMMAND "${helper_wrapper}" 0069 --clear-cache "${__cmake_helper_clear_cache_value}") 0070 endmacro() 0071 0072 # cmake_helper_clear_cache([dirs...]) 0073 # @dirs: directories names to be cleared. 0074 # 0075 # This function removes the content and recreate @dirs. 0076 # Used for cache dir cleanup. 0077 function(cmake_helper_clear_cache) 0078 cmake_utils_get_global(_CMAKE_HELPER_RUN_HELPER_WRAPPER helper_wrapper) 0079 cmake_array_foreach(__cmake_helper_clear_cache_value 0080 __cmake_helper_clear_cache_foreach) 0081 endfunction() 0082 0083 ## write shell script helpers 0084 ### init 0085 macro(__cmake_helper_init_script_foreach) 0086 file(WRITE "${fname}" 0087 "#!/bin/sh\n# Automatically generated. DO NOT EDIT\n") 0088 endmacro() 0089 0090 function(_cmake_helper_init_script) 0091 cmake_array_foreach(fname __cmake_helper_init_script_foreach) 0092 endfunction() 0093 0094 ### command 0095 macro(__cmake_helper_escape_cmd var) 0096 macro(__cmake_helper_escape_cmd_foreach) 0097 cmake_str_quote_shell("${arg}" arg) 0098 if(_first_arg) 0099 set("${var}" "${${var}}${arg}") 0100 set(_first_arg False) 0101 else() 0102 set("${var}" "${${var}} ${arg}") 0103 endif() 0104 endmacro() 0105 foreach(_first_arg True) 0106 cmake_array_foreach(arg __cmake_helper_escape_cmd_foreach ${ARGN}) 0107 endforeach() 0108 endmacro() 0109 0110 function(_cmake_helper_escape_cmd var) 0111 set(escaped_cmd "${${var}}") 0112 __cmake_helper_escape_cmd(escaped_cmd 1) 0113 set("${var}" "${escaped_cmd}" PARENT_SCOPE) 0114 endfunction() 0115 0116 macro(__cmake_helper_escape_envs varname) 0117 macro(__cmake_helper_escape_envs_foreach) 0118 if(__cmake_helper_add_env_is_name) 0119 set(__cmake_helper_add_env_is_name 0) 0120 set(__cmake_helper_add_env_name "${__cmake_helper_escape_envs_value}") 0121 else() 0122 set(__cmake_helper_add_env_is_name 1) 0123 _cmake_helper_escape_cmd("${varname}" export 0124 "${__cmake_helper_add_env_name}=${__cmake_helper_escape_envs_value}") 0125 set("${varname}" "${${varname}}\n") 0126 endif() 0127 endmacro() 0128 foreach(__cmake_helper_add_env_is_name 1) 0129 foreach(__cmake_helper_add_env_name "") 0130 cmake_array_foreach(__cmake_helper_escape_envs_value 0131 __cmake_helper_escape_envs_foreach ${ARGN}) 0132 endforeach() 0133 endforeach() 0134 endmacro() 0135 0136 function(_cmake_helper_write_export file) 0137 set(escaped_envs) 0138 __cmake_helper_escape_envs(escaped_envs 1) 0139 file(APPEND "${file}" "${escaped_envs}") 0140 endfunction() 0141 0142 macro(__cmake_helper_wrap_shell command_ret) 0143 __cmake_helper_escape_cmd(quoted_command_line ${ARGN}) 0144 cmake_utils_get_global(___CMAKE_HELPER_UTILS_CACHE helper_cache) 0145 cmake_utils_get_global(_CMAKE_HELPER_SCRIPT_DIR 0146 cmake_run_helper_script_dir) 0147 cmake_utils_get_unique_name(cmake_helper_wrap_shell "${command_ret}") 0148 set("${command_ret}" "${helper_cache}/${${command_ret}}.sh") 0149 set(quoted_command_line "${quoted_command_line} \"\$@\"") 0150 configure_file( 0151 "${cmake_run_helper_script_dir}/cmake-utils-cmd-wrapper.sh.in" 0152 "${${command_ret}}" @ONLY) 0153 cmake_utils_reconf_on("${${command_ret}}") 0154 endmacro() 0155 0156 function(_cmake_helper_wrap_shell command_ret) 0157 __cmake_helper_wrap_shell(file_name 1) 0158 set("${command_ret}" "${file_name}" PARENT_SCOPE) 0159 endfunction() 0160 0161 ### variables 0162 function(__cmake_helper_write_vars fname name value) 0163 cmake_str_quote_shell("${value}" value) 0164 file(APPEND "${fname}" "${name}=${value}\n") 0165 endfunction() 0166 0167 ### execute with environment 0168 macro(____cmake_helper_wrap_commands_foreach) 0169 foreach(command_str "") 0170 __cmake_helper_escape_cmd(command_str "${command}") 0171 file(APPEND "${fname}" " ${command_str} \"$@\"\n") 0172 endforeach() 0173 endmacro() 0174 0175 function(__cmake_helper_wrap_commands_write_commands fname name commands) 0176 file(APPEND "${fname}" "__command_${name}_run() {\n") 0177 cmake_array_foreach(command ____cmake_helper_wrap_commands_foreach 0178 "${commands}") 0179 file(APPEND "${fname}" "}\n") 0180 endfunction() 0181 0182 function(__cmake_helper_wrap_commands env_fname name 0183 commands working_dir input output error envs) 0184 cmake_utils_get_global(___CMAKE_HELPER_UTILS_CACHE helper_cache) 0185 set(fname "${helper_cache}/command_${name}_setting.sh") 0186 _cmake_helper_init_script("${fname}") 0187 # envs 0188 if(NOT "x${env_fname}x" STREQUAL xx) 0189 if((NOT "x${envs}x" STREQUAL xx) AND DEFINED "${envs}.length" 0190 AND "${${envs}.length}") 0191 __cmake_helper_escape_envs(envs_string "${envs}") 0192 file(APPEND "${env_fname}" "${envs_string}") 0193 endif() 0194 __cmake_helper_write_vars("${fname}" "__command_${name}_env_file" 0195 "${env_fname}") 0196 endif() 0197 # settings 0198 __cmake_helper_write_vars("${fname}" "__command_${name}_input_file" 0199 "${input}") 0200 __cmake_helper_write_vars("${fname}" "__command_${name}_output_file" 0201 "${output}") 0202 __cmake_helper_write_vars("${fname}" "__command_${name}_error_file" 0203 "${error}") 0204 __cmake_helper_write_vars("${fname}" "__command_${name}_working_dir" 0205 "${working_dir}") 0206 # commands 0207 __cmake_helper_wrap_commands_write_commands("${fname}" "${name}" 0208 "${commands}") 0209 cmake_utils_reconf_on("${fname}") 0210 endfunction() 0211 0212 function(cmake_helper_to_cur_file abs_path file) 0213 if(IS_ABSOLUTE "${file}") 0214 set("${abs_path}" "${file}" PARENT_SCOPE) 0215 else() 0216 get_filename_component(list_file_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) 0217 set(file_path "${list_file_dir}/${file}") 0218 cmake_utils_to_abs(file_path) 0219 set("${abs_path}" "${file_path}" PARENT_SCOPE) 0220 endif() 0221 endfunction() 0222 0223 function(__cmake_helper_macro_init) 0224 cmake_utils_get_global(CMAKE_GENERAL_BASE base_dir) 0225 0226 # helper cache 0227 cmake_utils_set_and_make_dir("${base_dir}/cmake_helper_cache" 0228 ___CMAKE_HELPER_UTILS_CACHE helper_cache) 0229 get_filename_component(cmake_run_helper_script_dir 0230 "${CMAKE_CURRENT_LIST_FILE}" PATH) 0231 set(cmake_run_helper_script 0232 "${cmake_run_helper_script_dir}/cmake-utils-run-helper.sh") 0233 cmake_str_quote_shell("${helper_cache}" cmake_helper_utils_cache_quoted) 0234 cmake_str_quote_shell("${cmake_run_helper_script_dir}" 0235 cmake_helper_script_dir_quoted) 0236 cmake_str_quote_shell("${base_dir}" base_dir_quoted) 0237 set(cmake_run_helper_wrapper "${base_dir}/cmake-utils-run-helper-wrapper.sh") 0238 configure_file( 0239 "${cmake_run_helper_script_dir}/cmake-utils-run-helper-wrapper.sh.in" 0240 "${cmake_run_helper_wrapper}" @ONLY) 0241 cmake_utils_set_global(_CMAKE_HELPER_RUN_HELPER_WRAPPER 0242 "${cmake_run_helper_wrapper}") 0243 cmake_utils_set_global(_CMAKE_HELPER_SCRIPT_DIR 0244 "${cmake_run_helper_script_dir}") 0245 set(general_export_script "${base_dir}/cmake_helper_general_export.sh") 0246 _cmake_helper_init_script("${general_export_script}") 0247 _cmake_helper_write_export("${general_export_script}" 0248 CMAKE_HELPER_CMAKE_COMMAND "${CMAKE_COMMAND}") 0249 cmake_helper_clear_cache("${helper_cache}") 0250 0251 # reconfigure 0252 cmake_utils_set_and_make_dir("${base_dir}/cmake_reconf_cache" 0253 ___CMAKE_UTILS_RECONF_CACHE reconf_cache) 0254 cmake_helper_clear_cache("${reconf_cache}") 0255 cmake_utils_reconf_on("${cmake_run_helper_script}") 0256 cmake_utils_reconf_on("${cmake_run_helper_wrapper}") 0257 cmake_utils_reconf_on("${general_export_script}") 0258 endfunction() 0259 cmake_utils_call_once(__cmake_helper_macro_init) 0260 0261 # cmake_helper_reg(name file command_ret 0262 # [ENVS:] (env_name env_value)... 0263 # WORKING_DIR: working_directory) 0264 # @name: name of the helper. 0265 # @file: executable file name of the helper. Relative path 0266 # is resolved using the directory of the current script. 0267 # @command_ret: variable to return the wrapper command used to 0268 # run the helper. 0269 # @env_name: name of environment variable. 0270 # @env_value: value of environment variable. 0271 # @working_directory: working directory to run the helper. 0272 # default to the directory of the current script. 0273 # 0274 # This function registers a helper script @file as @name. The variable 0275 # @command_ret will be set to command prefix that can be used to run the 0276 # helper. The difference between a helper and a normal command is that 0277 # a set of environment variable defined using @env_name and @env_value 0278 # can be passed to the helper script when ever it is executed. These 0279 # variables can be useful for a cmake helper script to access cmake 0280 # variables. More environment variables can also be added later using 0281 # #cmake_helper_add_env. There are also pre-defined variables that 0282 # will be defined for every script. These are the variables that are 0283 # currently defined: 0284 # CMAKE_HELPER_CMAKE_COMMAND: defined to the full path to the 0285 # cmake command. Use this variable instead of `cmake` to run 0286 # cmake (e.g. for `cmake -E`). 0287 # CMAKE_GENERAL_BASE: defined to the cache directory for build files. 0288 # See also #cmake_helper_add_env. 0289 function(cmake_helper_reg name file command_ret) 0290 set(bool_name "__cmake_helper_reg_${name}") 0291 cmake_utils_check_and_set_bool("${bool_name}" registered) 0292 if(registered) 0293 message(WARNING 0294 "Helper script ${name} already registered. Will not register again.") 0295 return() 0296 endif() 0297 cmake_utils_get_global(___CMAKE_HELPER_UTILS_CACHE helper_cache) 0298 cmake_utils_get_global(_CMAKE_HELPER_RUN_HELPER_WRAPPER helper_wrapper) 0299 0300 set(OPTIONS) 0301 set(SINGLES 0302 WORKING_DIR) 0303 set(MULTIPLES 0304 ENVS) 0305 set(LISTS) 0306 cmake_parse_array_default(REG_HELPER 3) 0307 cmake_array_concat("${REG_HELPER_ENVS}" "${REG_HELPER_UNUSED}") 0308 cmake_helper_to_cur_file(file "${file}") 0309 cmake_helper_to_cur_file(REG_HELPER_WORKING_DIR "${REG_HELPER_WORKING_DIR}") 0310 0311 cmake_utils_reconf_on("${file}") 0312 cmake_utils_get_unique_name("cmake_helper_${name}_default" default_dir_name) 0313 cmake_utils_get_unique_name("cmake_helper_${name}_raw" raw_name) 0314 cmake_array_new(command exec "${file}") 0315 cmake_array_new(commands "${command}") 0316 0317 set(env_fname "${helper_cache}/command_${name}_export.sh") 0318 _cmake_helper_init_script("${env_fname}") 0319 0320 __cmake_helper_wrap_commands("${env_fname}" 0321 "${default_dir_name}" "${commands}" "${REG_HELPER_WORKING_DIR}" 0322 "" "" "" "${REG_HELPER_ENVS}") 0323 __cmake_helper_wrap_commands("${env_fname}" 0324 "${raw_name}" "${commands}" "" "" "" "" "") 0325 0326 _cmake_helper_wrap_shell(wrapper_file "${helper_wrapper}" 0327 "--run-command" "${default_dir_name}") 0328 _cmake_helper_wrap_shell(wrapper_file_raw "${helper_wrapper}" 0329 "--run-command" "${raw_name}") 0330 0331 cmake_utils_set_global("_cmake_helper_${name}_script" "${file}") 0332 cmake_utils_set_global("_cmake_helper_${name}_working_dir" 0333 "${REG_HELPER_WORKING_DIR}") 0334 cmake_utils_set_global("_cmake_helper_${name}_wrapper_raw" 0335 "${wrapper_file_raw}") 0336 cmake_utils_set_global("_cmake_helper_${name}_wrapper" "${wrapper_file}") 0337 # cmake_utils_set_global("_cmake_helper_${name}_setting_raw" "${raw_name}") 0338 # cmake_utils_set_global("_cmake_helper_${name}_setting" "${default_dir_name}") 0339 set("${command_ret}" "${wrapper_file}" PARENT_SCOPE) 0340 cmake_utils_reconf_on("${env_fname}") 0341 endfunction() 0342 0343 macro(_cmake_helper_save_commands name save_commands_list) 0344 cmake_array_set_global("_cmake_helper_save_commands_${name}" 0345 "${save_commands_list}" 2) 0346 endmacro() 0347 0348 macro(_cmake_helper_retrieve_commands name save_commands_list) 0349 cmake_array_get_global("_cmake_helper_save_commands_${name}" 0350 "${save_commands_list}" 2) 0351 endmacro() 0352 0353 # cmake_helper_wrap_shell(command_ret 0354 # (COMMAND: command...)... 0355 # [WORKING_DIR: working_dir] 0356 # [ID_RET: id_ret] 0357 # [INPUT_FILE: input_file] 0358 # [OUTPUT_FILE: output_file] 0359 # [ERROR_FILE: error_file] 0360 # [ENVS: (env_name env_value)...]) 0361 # @command_ret: variable to return the wrapper command used to 0362 # run the original command. 0363 # @command: a single shell command to be wrapped, 0364 # 0365 # This function wrap a shell command and return a wrapper command. All 0366 # the arguments including the command itself will be quoted properly. 0367 # See also #cmake_helper_wrap_helper. 0368 function(cmake_helper_wrap_shell command_ret) 0369 set(OPTIONS) 0370 set(SINGLES INPUT_FILE OUTPUT_FILE ERROR_FILE WORKING_DIR ID_RET) 0371 set(MULTIPLES ENVS) 0372 set(LISTS COMMAND) 0373 cmake_parse_array_default(WRAP_SHELL 1) 0374 if("${WRAP_SHELL_UNUSED}.length") 0375 cmake_array_append("${WRAP_SHELL_COMMAND}" "${WRAP_SHELL_UNUSED}") 0376 endif() 0377 cmake_utils_to_abs(WRAP_SHELL_WORKING_DIR WRAP_SHELL_INPUT_FILE 0378 WRAP_SHELL_OUTPUT_FILE WRAP_SHELL_ERROR_FILE) 0379 0380 cmake_utils_get_global(___CMAKE_HELPER_UTILS_CACHE helper_cache) 0381 cmake_utils_get_global(_CMAKE_HELPER_RUN_HELPER_WRAPPER helper_wrapper) 0382 0383 cmake_utils_get_unique_name(cmake_helper_wrap_shell wrapper_name) 0384 set(env_fname "${helper_cache}/command_${wrapper_name}_export.sh") 0385 _cmake_helper_init_script("${env_fname}") 0386 __cmake_helper_wrap_commands("${env_fname}" "${wrapper_name}" 0387 "${WRAP_SHELL_COMMAND}" "${WRAP_SHELL_WORKING_DIR}" 0388 "${WRAP_SHELL_INPUT_FILE}" "${WRAP_SHELL_OUTPUT_FILE}" 0389 "${WRAP_SHELL_ERROR_FILE}" "${WRAP_SHELL_ENVS}") 0390 _cmake_helper_save_commands("${wrapper_name}" "${WRAP_SHELL_COMMAND}") 0391 _cmake_helper_wrap_shell(wrapper_file "${helper_wrapper}" "--run-command" 0392 "${wrapper_name}") 0393 set("${command_ret}" "${wrapper_file}" PARENT_SCOPE) 0394 if(NOT "x${WRAP_SHELL_ID_RET}x" STREQUAL xx) 0395 set("${WRAP_SHELL_ID_RET}" "${wrapper_name}" PARENT_SCOPE) 0396 endif() 0397 cmake_utils_reconf_on("${env_fname}") 0398 endfunction() 0399 0400 # cmake_helper_wrap_helper(name command_ret [args...] 0401 # (ARGS: args...)... 0402 # [WORKING_DIR: working_dir] 0403 # [INPUT_FILE: input_file] 0404 # [OUTPUT_FILE: output_file] 0405 # [ERROR_FILE: error_file] 0406 # [ENVS: (env_name env_value)...]) 0407 # @name: name of the helper. 0408 # @command_ret: variable to return the wrapper command used to 0409 # run the original command. 0410 # @args: arguments passed to the helper script. 0411 # 0412 # This function wrap a helper command and return a wrapper command. All 0413 # the arguments will be quoted properly. See also #cmake_helper_wrap_shell. 0414 function(cmake_helper_wrap_helper name command_ret) 0415 set(bool_name "__cmake_helper_reg_${name}") 0416 cmake_utils_get_bool("${bool_name}" registered) 0417 if(NOT registered) 0418 message(FATAL_ERROR 0419 "Helper script ${name} have not been registered yet.") 0420 return() 0421 endif() 0422 0423 set(OPTIONS) 0424 set(SINGLES INPUT_FILE OUTPUT_FILE ERROR_FILE WORKING_DIR ID_RET) 0425 set(MULTIPLES ENVS) 0426 set(LISTS ARGS) 0427 cmake_parse_array_default(WRAP_HELPER 2) 0428 cmake_utils_to_abs(WRAP_HELPER_WORKING_DIR WRAP_HELPER_INPUT_FILE 0429 WRAP_HELPER_OUTPUT_FILE WRAP_HELPER_ERROR_FILE) 0430 if(DEFINED "${WRAP_HELPER_UNUSED}.length" AND 0431 "${${WRAP_HELPER_UNUSED}.length}") 0432 cmake_array_append("${WRAP_HELPER_ARGS}" "${WRAP_HELPER_UNUSED}") 0433 endif() 0434 0435 cmake_utils_get_global(___CMAKE_HELPER_UTILS_CACHE helper_cache) 0436 cmake_utils_get_global(_CMAKE_HELPER_RUN_HELPER_WRAPPER helper_wrapper) 0437 0438 if("x${WRAP_HELPER_WORKING_DIR}x" STREQUAL "xx") 0439 cmake_utils_get_global("_cmake_helper_${name}_wrapper" wrapper_file) 0440 else() 0441 cmake_utils_get_global("_cmake_helper_${name}_wrapper_raw" wrapper_file) 0442 endif() 0443 cmake_array_new(command_prefix "${wrapper_file}") 0444 0445 cmake_array_new(commands) 0446 macro(__cmake_helper_wrap_helper_foreach) 0447 foreach(array_name "") 0448 cmake_array_copy("${command_prefix}" array_name) 0449 cmake_array_concat("${array_name}" "${helper_arg}") 0450 cmake_array_append("${commands}" "${array_name}") 0451 endforeach() 0452 endmacro() 0453 cmake_array_foreach(helper_arg __cmake_helper_wrap_helper_foreach 0454 "${WRAP_HELPER_ARGS}") 0455 0456 cmake_utils_get_unique_name(cmake_helper_wrap_helper wrapper_name) 0457 set(env_fname "${helper_cache}/command_${wrapper_name}_export.sh") 0458 _cmake_helper_init_script("${env_fname}") 0459 __cmake_helper_wrap_commands("${env_fname}" "${wrapper_name}" 0460 "${commands}" "${WRAP_HELPER_WORKING_DIR}" "${WRAP_HELPER_INPUT_FILE}" 0461 "${WRAP_HELPER_OUTPUT_FILE}" "${WRAP_HELPER_ERROR_FILE}" 0462 "${WRAP_HELPER_ENVS}") 0463 _cmake_helper_save_commands("${wrapper_name}" "${commands}") 0464 _cmake_helper_wrap_shell(wrapper_file "${helper_wrapper}" "--run-command" 0465 "${wrapper_name}") 0466 set("${command_ret}" "${wrapper_file}" PARENT_SCOPE) 0467 if(NOT "x${WRAP_HELPER_ID_RET}x" STREQUAL xx) 0468 set("${WRAP_HELPER_ID_RET}" "${wrapper_name}" PARENT_SCOPE) 0469 endif() 0470 cmake_utils_reconf_on("${env_fname}") 0471 endfunction() 0472 0473 function(_cmake_helper_set_command name commands) 0474 _cmake_helper_save_commands("${name}" "${commands}") 0475 cmake_utils_get_global(_CMAKE_HELPER_RUN_HELPER_WRAPPER helper_wrapper) 0476 execute_process(COMMAND "${helper_wrapper}" --rewrite-cmd-settings "${name}") 0477 cmake_utils_get_global(___CMAKE_HELPER_UTILS_CACHE helper_cache) 0478 set(fname "${helper_cache}/command_${name}_setting.sh") 0479 __cmake_helper_wrap_commands_write_commands("${fname}" "${name}" 0480 "${commands}") 0481 cmake_utils_reconf_on("${fname}") 0482 endfunction() 0483 0484 macro(cmake_helper_get_command name ret_commands) 0485 _cmake_helper_retrieve_commands("${name}" "${ret_commands}") 0486 endmacro() 0487 0488 function(cmake_helper_add_command name) 0489 set(OPTIONS) 0490 set(SINGLES) 0491 set(MULTIPLES) 0492 set(LISTS COMMAND) 0493 cmake_parse_array_default(ADD_COMMAND 1) 0494 _cmake_helper_retrieve_commands("${name}" retrieved_commands) 0495 cmake_array_concat("${retrieved_commands}" "${ADD_COMMAND_COMMAND}") 0496 _cmake_helper_set_command("${name}" "${retrieved_commands}") 0497 endfunction() 0498 0499 function(cmake_helper_set_command name) 0500 set(OPTIONS) 0501 set(SINGLES) 0502 set(MULTIPLES) 0503 set(LISTS COMMAND) 0504 cmake_parse_array_default(SET_COMMAND 1) 0505 _cmake_helper_set_command("${name}" "${SET_COMMAND_COMMAND}") 0506 endfunction() 0507 0508 # cmake_helper_add_env(name [[env_name env_value]...]) 0509 # @name: name of the helper. 0510 # @env_name: name of environment variable. 0511 # @env_value: value of environment variable. 0512 # 0513 # This function add more environment variables for a previously 0514 # registered helper script @name. See #cmake_helper_reg for more detail. 0515 function(cmake_helper_add_env name) 0516 cmake_utils_get_global(___CMAKE_HELPER_UTILS_CACHE helper_cache) 0517 set(env_fname "${helper_cache}/command_${name}_export.sh") 0518 __cmake_helper_escape_envs(envs_string 1) 0519 file(APPEND "${env_fname}" "${envs_string}") 0520 cmake_utils_reconf_on("${env_fname}") 0521 endfunction()