From d5333c0923b80f211bd7be1ec3a2a935d70481e8 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 14 Jun 2019 08:17:33 +0200 Subject: BundleUtilities: simplify inclusion of GetPrerequisites --- Modules/BundleUtilities.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index f94fc5c..ca92f85 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -246,8 +246,7 @@ endif() # 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) -- cgit v0.12 From 6695383dd5a7855321dc011158e30ec24a7cf902 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 14 Jun 2019 08:30:34 +0200 Subject: BundleUtilities: remove needless variable expansions in if() arguments --- Modules/BundleUtilities.cmake | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index ca92f85..182720b 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -279,7 +279,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() @@ -601,9 +601,9 @@ function(get_bundle_keys app libs dirs keys_var) set(prereqs "") set(ignoreFile FALSE) get_filename_component(prereq_filename ${lib} NAME) - if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" ) + if(NOT CFG_IGNORE_ITEM STREQUAL "") foreach(item ${CFG_IGNORE_ITEM}) - if("${item}" STREQUAL "${prereq_filename}") + if(item STREQUAL prereq_filename) set(ignoreFile TRUE) endif() endforeach() @@ -626,7 +626,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}") @@ -644,9 +644,9 @@ function(get_bundle_keys app libs dirs keys_var) set(prereqs "") set(ignoreFile FALSE) get_filename_component(prereq_filename ${exe} NAME) - if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" ) + if(NOT CFG_IGNORE_ITEM STREQUAL "" ) foreach(item ${CFG_IGNORE_ITEM}) - if("${item}" STREQUAL "${prereq_filename}") + if(item STREQUAL prereq_filename) set(ignoreFile TRUE) endif() endforeach() @@ -664,7 +664,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}") @@ -681,7 +681,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() @@ -715,7 +715,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) @@ -737,7 +737,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}") @@ -760,7 +760,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) @@ -840,12 +840,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() @@ -1034,9 +1034,9 @@ function(verify_bundle_prerequisites bundle result_var info_var) set(ignoreFile FALSE) get_filename_component(prereq_filename ${f} NAME) - if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" ) + if(NOT CFG_IGNORE_ITEM STREQUAL "" ) foreach(item ${CFG_IGNORE_ITEM}) - if("${item}" STREQUAL "${prereq_filename}") + if(item STREQUAL prereq_filename) set(ignoreFile TRUE) endif() endforeach() @@ -1062,11 +1062,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() -- cgit v0.12 From e33f4cb0cb18a03aa12b308ba654ec5f305365f8 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 14 Jun 2019 08:33:27 +0200 Subject: BundleUtilities: use if(... IN_LIST ...) --- Modules/BundleUtilities.cmake | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 182720b..2f3b9e1 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -243,6 +243,9 @@ 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: # @@ -599,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}") @@ -642,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}") @@ -1031,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}") @@ -1141,3 +1119,5 @@ function(verify_app app) message(FATAL_ERROR "error: verify_app failed") endif() endfunction() + +cmake_policy(POP) -- cgit v0.12 From 8d59ebb7049f30f2c56f6d89b8e6c8db907c0324 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 14 Jun 2019 08:38:24 +0200 Subject: GetPrerequisites: use CMAKE_OBJDUMP if it is set --- Modules/GetPrerequisites.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 41d9dc1..2beea00 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -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() -- cgit v0.12