Merge topic 'GetPrerequisites-expansion'

d1903de8 GetPrerequisites: join if() clauses
c9e32b0b GetPrerequisites: remove needless variable dereferencing
This commit is contained in:
Brad King 2014-11-25 10:18:54 -05:00 committed by CMake Topic Stage
commit e993c384d9
1 changed files with 16 additions and 30 deletions

View File

@ -179,7 +179,7 @@ function(gp_append_unique list_var value)
set(contains 0) set(contains 0)
foreach(item ${${list_var}}) foreach(item ${${list_var}})
if("${item}" STREQUAL "${value}") if(item STREQUAL "${value}")
set(contains 1) set(contains 1)
break() break()
endif() endif()
@ -546,14 +546,14 @@ function(gp_resolved_file_type original_file file exepath dirs type_var)
if(NOT is_system) if(NOT is_system)
get_filename_component(original_path "${original_lower}" PATH) get_filename_component(original_path "${original_lower}" PATH)
get_filename_component(path "${lower}" PATH) get_filename_component(path "${lower}" PATH)
if("${original_path}" STREQUAL "${path}") if(original_path STREQUAL path)
set(is_local 1) set(is_local 1)
else() else()
string(LENGTH "${original_path}/" original_length) string(LENGTH "${original_path}/" original_length)
string(LENGTH "${lower}" path_length) string(LENGTH "${lower}" path_length)
if(${path_length} GREATER ${original_length}) if(${path_length} GREATER ${original_length})
string(SUBSTRING "${lower}" 0 ${original_length} path) string(SUBSTRING "${lower}" 0 ${original_length} path)
if("${original_path}/" STREQUAL "${path}") if("${original_path}/" STREQUAL path)
set(is_embedded 1) set(is_embedded 1)
endif() endif()
endif() endif()
@ -642,7 +642,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
# Try to choose the right tool by default. Caller can set gp_tool prior to # Try to choose the right tool by default. Caller can set gp_tool prior to
# calling this function to force using a different tool. # calling this function to force using a different tool.
# #
if("${gp_tool}" STREQUAL "") if(NOT gp_tool)
set(gp_tool "ldd") set(gp_tool "ldd")
if(APPLE) if(APPLE)
@ -666,45 +666,31 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
return() return()
endif() endif()
set(gp_tool_known 0) if(gp_tool STREQUAL "ldd")
if("${gp_tool}" STREQUAL "ldd")
set(gp_cmd_args "") set(gp_cmd_args "")
set(gp_regex "^[\t ]*[^\t ]+ => ([^\t\(]+) .*${eol_char}$") set(gp_regex "^[\t ]*[^\t ]+ => ([^\t\(]+) .*${eol_char}$")
set(gp_regex_error "not found${eol_char}$") set(gp_regex_error "not found${eol_char}$")
set(gp_regex_fallback "^[\t ]*([^\t ]+) => ([^\t ]+).*${eol_char}$") set(gp_regex_fallback "^[\t ]*([^\t ]+) => ([^\t ]+).*${eol_char}$")
set(gp_regex_cmp_count 1) set(gp_regex_cmp_count 1)
set(gp_tool_known 1) elseif(gp_tool STREQUAL "otool")
endif()
if("${gp_tool}" STREQUAL "otool")
set(gp_cmd_args "-L") set(gp_cmd_args "-L")
set(gp_regex "^\t([^\t]+) \\(compatibility version ([0-9]+.[0-9]+.[0-9]+), current version ([0-9]+.[0-9]+.[0-9]+)\\)${eol_char}$") set(gp_regex "^\t([^\t]+) \\(compatibility version ([0-9]+.[0-9]+.[0-9]+), current version ([0-9]+.[0-9]+.[0-9]+)\\)${eol_char}$")
set(gp_regex_error "") set(gp_regex_error "")
set(gp_regex_fallback "") set(gp_regex_fallback "")
set(gp_regex_cmp_count 3) set(gp_regex_cmp_count 3)
set(gp_tool_known 1) elseif(gp_tool STREQUAL "dumpbin")
endif()
if("${gp_tool}" STREQUAL "dumpbin")
set(gp_cmd_args "/dependents") set(gp_cmd_args "/dependents")
set(gp_regex "^ ([^ ].*[Dd][Ll][Ll])${eol_char}$") set(gp_regex "^ ([^ ].*[Dd][Ll][Ll])${eol_char}$")
set(gp_regex_error "") set(gp_regex_error "")
set(gp_regex_fallback "") set(gp_regex_fallback "")
set(gp_regex_cmp_count 1) set(gp_regex_cmp_count 1)
set(gp_tool_known 1) elseif(gp_tool STREQUAL "objdump")
endif()
if("${gp_tool}" STREQUAL "objdump")
set(gp_cmd_args "-p") set(gp_cmd_args "-p")
set(gp_regex "^\t*DLL Name: (.*\\.[Dd][Ll][Ll])${eol_char}$") set(gp_regex "^\t*DLL Name: (.*\\.[Dd][Ll][Ll])${eol_char}$")
set(gp_regex_error "") set(gp_regex_error "")
set(gp_regex_fallback "") set(gp_regex_fallback "")
set(gp_regex_cmp_count 1) set(gp_regex_cmp_count 1)
set(gp_tool_known 1) else()
endif()
if(NOT gp_tool_known)
message(STATUS "warning: gp_tool='${gp_tool}' is an unknown tool...") message(STATUS "warning: gp_tool='${gp_tool}' is an unknown tool...")
message(STATUS "CMake function get_prerequisites needs more code to handle '${gp_tool}'") message(STATUS "CMake function get_prerequisites needs more code to handle '${gp_tool}'")
message(STATUS "Valid gp_tool values are dumpbin, ldd, objdump and otool.") message(STATUS "Valid gp_tool values are dumpbin, ldd, objdump and otool.")
@ -712,7 +698,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
endif() endif()
if("${gp_tool}" STREQUAL "dumpbin") if(gp_tool STREQUAL "dumpbin")
# When running dumpbin, it also needs the "Common7/IDE" directory in the # When running dumpbin, it also needs the "Common7/IDE" directory in the
# PATH. It will already be in the PATH if being run from a Visual Studio # PATH. It will already be in the PATH if being run from a Visual Studio
# command prompt. Add it to the PATH here in case we are running from a # command prompt. Add it to the PATH here in case we are running from a
@ -727,7 +713,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
set(gp_found_cmd_dlls_dir 0) set(gp_found_cmd_dlls_dir 0)
file(TO_CMAKE_PATH "$ENV{PATH}" env_path) file(TO_CMAKE_PATH "$ENV{PATH}" env_path)
foreach(gp_env_path_element ${env_path}) foreach(gp_env_path_element ${env_path})
if("${gp_env_path_element}" STREQUAL "${gp_cmd_dlls_dir}") if(gp_env_path_element STREQUAL gp_cmd_dlls_dir)
set(gp_found_cmd_dlls_dir 1) set(gp_found_cmd_dlls_dir 1)
endif() endif()
endforeach() endforeach()
@ -741,7 +727,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
# #
# </setup-gp_tool-vars> # </setup-gp_tool-vars>
if("${gp_tool}" STREQUAL "ldd") if(gp_tool STREQUAL "ldd")
set(old_ld_env "$ENV{LD_LIBRARY_PATH}") set(old_ld_env "$ENV{LD_LIBRARY_PATH}")
set(new_ld_env "${exepath}") set(new_ld_env "${exepath}")
foreach(dir ${dirs}) foreach(dir ${dirs})
@ -763,7 +749,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
OUTPUT_VARIABLE gp_cmd_ov OUTPUT_VARIABLE gp_cmd_ov
) )
if("${gp_tool}" STREQUAL "ldd") if(gp_tool STREQUAL "ldd")
set(ENV{LD_LIBRARY_PATH} "${old_ld_env}") set(ENV{LD_LIBRARY_PATH} "${old_ld_env}")
endif() endif()
@ -783,7 +769,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
# check for install id and remove it from list, since otool -L can include a # check for install id and remove it from list, since otool -L can include a
# reference to itself # reference to itself
set(gp_install_id) set(gp_install_id)
if("${gp_tool}" STREQUAL "otool") if(gp_tool STREQUAL "otool")
execute_process( execute_process(
COMMAND otool -D ${target} COMMAND otool -D ${target}
OUTPUT_VARIABLE gp_install_id_ov OUTPUT_VARIABLE gp_install_id_ov
@ -833,7 +819,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
# #
set(add_item 1) set(add_item 1)
if("${item}" STREQUAL "${gp_install_id}") if(item STREQUAL gp_install_id)
set(add_item 0) set(add_item 0)
endif() endif()
@ -841,7 +827,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
set(type "") set(type "")
gp_resolved_file_type("${target}" "${item}" "${exepath}" "${dirs}" type "${rpaths}") gp_resolved_file_type("${target}" "${item}" "${exepath}" "${dirs}" type "${rpaths}")
if("${type}" STREQUAL "system") if(type STREQUAL "system")
set(add_item 0) set(add_item 0)
endif() endif()
endif() endif()