Commit cecf7e61 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'BundleUtilities-cleanup'

8d59ebb7 GetPrerequisites: use CMAKE_OBJDUMP if it is set
e33f4cb0 BundleUtilities: use if(... IN_LIST ...)
6695383d BundleUtilities: remove needless variable expansions in if() arguments
d5333c09 BundleUtilities: simplify inclusion of GetPrerequisites
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !3447
parents fe11593d 8d59ebb7
Pipeline #139605 passed with stage
in 0 seconds
......@@ -243,11 +243,13 @@ if(DEFINED CMAKE_GENERATOR)
endif()
endif()
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
# The functions defined in this file depend on the get_prerequisites function
# (and possibly others) found in:
#
get_filename_component(BundleUtilities_cmake_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
include("${BundleUtilities_cmake_dir}/GetPrerequisites.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/GetPrerequisites.cmake")
function(get_bundle_main_executable bundle result_var)
......@@ -280,7 +282,7 @@ function(get_bundle_main_executable bundle result_var)
endif()
endforeach()
if(NOT "${bundle_executable}" STREQUAL "")
if(NOT bundle_executable STREQUAL "")
if(EXISTS "${bundle}/Contents/MacOS/${bundle_executable}")
set(result "${bundle}/Contents/MacOS/${bundle_executable}")
else()
......@@ -600,17 +602,9 @@ function(get_bundle_keys app libs dirs keys_var)
set_bundle_key_values(${keys_var} "${lib}" "${lib}" "${exepath}" "${dirs}" 0 "${main_rpaths}")
set(prereqs "")
set(ignoreFile FALSE)
get_filename_component(prereq_filename ${lib} NAME)
if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
foreach(item ${CFG_IGNORE_ITEM})
if("${item}" STREQUAL "${prereq_filename}")
set(ignoreFile TRUE)
endif()
endforeach()
endif()
if(NOT ignoreFile)
if(NOT prereq_filename IN_LIST CFG_IGNORE_ITEM)
get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}" "${main_rpaths}")
foreach(pr ${prereqs})
set_bundle_key_values(${keys_var} "${lib}" "${pr}" "${exepath}" "${dirs}" 1 "${main_rpaths}")
......@@ -627,7 +621,7 @@ function(get_bundle_keys app libs dirs keys_var)
foreach(exe ${exes})
# Main executable is scanned first above:
#
if(NOT "${exe}" STREQUAL "${executable}")
if(NOT exe STREQUAL executable)
# Add the exe itself to the keys:
#
set_bundle_key_values(${keys_var} "${exe}" "${exe}" "${exepath}" "${dirs}" 0 "${main_rpaths}")
......@@ -643,17 +637,9 @@ function(get_bundle_keys app libs dirs keys_var)
# Add each prerequisite to the keys:
#
set(prereqs "")
set(ignoreFile FALSE)
get_filename_component(prereq_filename ${exe} NAME)
if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
foreach(item ${CFG_IGNORE_ITEM})
if("${item}" STREQUAL "${prereq_filename}")
set(ignoreFile TRUE)
endif()
endforeach()
endif()
if(NOT ignoreFile)
if(NOT prereq_filename IN_LIST CFG_IGNORE_ITEM)
get_prerequisites("${exe}" prereqs 1 1 "${exepath}" "${dirs}" "${exe_rpaths}")
foreach(pr ${prereqs})
set_bundle_key_values(${keys_var} "${exe}" "${pr}" "${exepath}" "${dirs}" 1 "${exe_rpaths}")
......@@ -665,7 +651,7 @@ function(get_bundle_keys app libs dirs keys_var)
# preserve library symlink structure
foreach(key ${${keys_var}})
if("${${key}_COPYFLAG}" STREQUAL 1)
if("${${key}_COPYFLAG}" STREQUAL "1")
if(IS_SYMLINK "${${key}_RESOLVED_ITEM}")
get_filename_component(target "${${key}_RESOLVED_ITEM}" REALPATH)
set_bundle_key_values(${keys_var} "${exe}" "${target}" "${exepath}" "${dirs}" 1 "${exe_rpaths}")
......@@ -682,7 +668,7 @@ function(get_bundle_keys app libs dirs keys_var)
get_filename_component(resolved_item_compare "${resolved_item_compare}" NAME)
get_filename_component(resolved_embedded_item_compare "${resolved_embedded_item_compare}" NAME)
if(NOT "${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
if(NOT resolved_item_compare STREQUAL resolved_embedded_item_compare)
set(${key}_COPYFLAG "2")
set(${key}_RESOLVED_ITEM "${${targetkey}_RESOLVED_EMBEDDED_ITEM}")
endif()
......@@ -716,7 +702,7 @@ function(link_resolved_item_into_bundle resolved_item resolved_embedded_item)
set(resolved_embedded_item_compare "${resolved_embedded_item}")
endif()
if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
if(resolved_item_compare STREQUAL resolved_embedded_item_compare)
message(STATUS "warning: resolved_item == resolved_embedded_item - not linking...")
else()
get_filename_component(target_dir "${resolved_embedded_item}" DIRECTORY)
......@@ -738,7 +724,7 @@ function(copy_resolved_item_into_bundle resolved_item resolved_embedded_item)
set(resolved_embedded_item_compare "${resolved_embedded_item}")
endif()
if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
if(resolved_item_compare STREQUAL resolved_embedded_item_compare)
message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...")
else()
#message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy ${resolved_item} ${resolved_embedded_item}")
......@@ -761,7 +747,7 @@ function(copy_resolved_framework_into_bundle resolved_item resolved_embedded_ite
set(resolved_embedded_item_compare "${resolved_embedded_item}")
endif()
if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
if(resolved_item_compare STREQUAL resolved_embedded_item_compare)
message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...")
else()
if(BU_COPY_FULL_FRAMEWORK_CONTENTS)
......@@ -841,12 +827,12 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs)
string(LENGTH "${resolved_embedded_item}" resolved_embedded_item_length)
set(path_too_short 0)
set(is_embedded 0)
if(${resolved_embedded_item_length} LESS ${exe_dotapp_dir_length})
if(resolved_embedded_item_length LESS exe_dotapp_dir_length)
set(path_too_short 1)
endif()
if(NOT path_too_short)
string(SUBSTRING "${resolved_embedded_item}" 0 ${exe_dotapp_dir_length} item_substring)
if("${exe_dotapp_dir}/" STREQUAL "${item_substring}")
if("${exe_dotapp_dir}/" STREQUAL item_substring)
set(is_embedded 1)
endif()
endif()
......@@ -1032,18 +1018,9 @@ function(verify_bundle_prerequisites bundle result_var info_var)
message(STATUS "executable file ${count}: ${f}")
set(prereqs "")
set(ignoreFile FALSE)
get_filename_component(prereq_filename ${f} NAME)
if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
foreach(item ${CFG_IGNORE_ITEM})
if("${item}" STREQUAL "${prereq_filename}")
set(ignoreFile TRUE)
endif()
endforeach()
endif()
if(NOT ignoreFile)
if(NOT prereq_filename IN_LIST CFG_IGNORE_ITEM)
get_item_rpaths(${f} _main_exe_rpaths)
get_prerequisites("${f}" prereqs 1 1 "${exepath}" "${_main_exe_rpaths}")
......@@ -1063,11 +1040,11 @@ function(verify_bundle_prerequisites bundle result_var info_var)
gp_file_type("${f}" "${p}" p_type)
if(APPLE)
if(NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system")
if(NOT p_type STREQUAL "embedded" AND NOT p_type STREQUAL "system")
set(external_prereqs ${external_prereqs} "${p}")
endif()
else()
if(NOT "${p_type}" STREQUAL "local" AND NOT "${p_type}" STREQUAL "system")
if(NOT p_type STREQUAL "local" AND NOT p_type STREQUAL "system")
set(external_prereqs ${external_prereqs} "${p}")
endif()
endif()
......@@ -1142,3 +1119,5 @@ function(verify_app app)
message(FATAL_ERROR "error: verify_app failed")
endif()
endfunction()
cmake_policy(POP)
......@@ -710,7 +710,9 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
find_program(gp_dumpbin "dumpbin" PATHS ${gp_cmd_paths})
if(gp_dumpbin)
set(gp_tool "dumpbin")
else() # Try harder. Maybe we're on MinGW
elseif(CMAKE_OBJDUMP) # Try harder. Maybe we're on MinGW
set(gp_tool "${CMAKE_OBJDUMP}")
else()
set(gp_tool "objdump")
endif()
endif()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment