diff options
author | Bill Somerville <bill@classdesign.com> | 2015-07-29 16:05:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-07-31 13:50:32 (GMT) |
commit | afb674ab46a7d6ff3d1801315f3d852bdba79d0c (patch) | |
tree | 475a5d2b28aee7d795dda147e422c91af6eb04fb /Modules/GetPrerequisites.cmake | |
parent | 1c46b6aed0db88c97189713f291164f98df780a9 (diff) | |
download | CMake-afb674ab46a7d6ff3d1801315f3d852bdba79d0c.zip CMake-afb674ab46a7d6ff3d1801315f3d852bdba79d0c.tar.gz CMake-afb674ab46a7d6ff3d1801315f3d852bdba79d0c.tar.bz2 |
GetPrerequisites: Add error checks for execute_process() calls
Add return status checks to external command invocations so that they do
not fail silently producing incomplete install packages.
Diffstat (limited to 'Modules/GetPrerequisites.cmake')
-rw-r--r-- | Modules/GetPrerequisites.cmake | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 23d486e..a359d2c 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -229,9 +229,14 @@ function(is_file_executable file result_var) if(file_cmd) execute_process(COMMAND "${file_cmd}" "${file_full}" + RESULT_VARIABLE file_rv OUTPUT_VARIABLE file_ov + ERROR_VARIABLE file_ev OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(NOT file_rv STREQUAL "0") + message(FATAL_ERROR "${file_cmd} failed: ${file_rv}\n${file_ev}") + endif() # Replace the name of the file in the output with a placeholder token # (the string " _file_full_ ") so that just in case the path name of @@ -543,11 +548,21 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) if(CYGPATH_EXECUTABLE) execute_process(COMMAND ${CYGPATH_EXECUTABLE} -W + RESULT_VARIABLE env_rv OUTPUT_VARIABLE env_windir + ERROR_VARIABLE env_ev OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT env_rv STREQUAL "0") + message(FATAL_ERROR "${CYGPATH_EXECUTABLE} -W failed: ${env_rv}\n${env_ev}") + endif() execute_process(COMMAND ${CYGPATH_EXECUTABLE} -S + RESULT_VARIABLE env_rv OUTPUT_VARIABLE env_sysdir + ERROR_VARIABLE env_ev OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT env_rv STREQUAL "0") + message(FATAL_ERROR "${CYGPATH_EXECUTABLE} -S failed: ${env_rv}\n${env_ev}") + endif() string(TOLOWER "${env_windir}" windir) string(TOLOWER "${env_sysdir}" sysroot) @@ -765,8 +780,18 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa # execute_process( COMMAND ${gp_cmd} ${gp_cmd_args} ${target} + RESULT_VARIABLE gp_rv OUTPUT_VARIABLE gp_cmd_ov + ERROR_VARIABLE gp_ev ) + if(NOT gp_rv STREQUAL "0") + if(gp_tool STREQUAL "dumpbin") + # dumpbin error messages seem to go to stdout + message(FATAL_ERROR "${gp_cmd} failed: ${gp_rv}\n${gp_ev}\n${gp_cmd_ov}") + else() + message(FATAL_ERROR "${gp_cmd} failed: ${gp_rv}\n${gp_ev}") + endif() + endif() if(gp_tool STREQUAL "ldd") set(ENV{LD_LIBRARY_PATH} "${old_ld_env}") @@ -791,8 +816,13 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa if(gp_tool STREQUAL "otool") execute_process( COMMAND otool -D ${target} + RESULT_VARIABLE otool_rv OUTPUT_VARIABLE gp_install_id_ov + ERROR_VARIABLE otool_ev ) + if(NOT otool_rv STREQUAL "0") + message(FATAL_ERROR "otool -D failed: ${otool_rv}\n${otool_ev}") + endif() # second line is install name string(REGEX REPLACE ".*:\n" "" gp_install_id "${gp_install_id_ov}") if(gp_install_id) |