summaryrefslogtreecommitdiff
path: root/Modules/BundleUtilities.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/BundleUtilities.cmake')
-rw-r--r--Modules/BundleUtilities.cmake15
1 files changed, 10 insertions, 5 deletions
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake
index 2f3b9e1d30..f521d22200 100644
--- a/Modules/BundleUtilities.cmake
+++ b/Modules/BundleUtilities.cmake
@@ -894,11 +894,16 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs)
# to install_name_tool:
#
if(changes)
- set(cmd ${CMAKE_INSTALL_NAME_TOOL} ${changes} "${resolved_embedded_item}")
- execute_process(COMMAND ${cmd} RESULT_VARIABLE install_name_tool_result)
- if(NOT install_name_tool_result EQUAL 0)
- string(REPLACE ";" "' '" msg "'${cmd}'")
- message(FATAL_ERROR "Command failed:\n ${msg}")
+ # Check for a script by extension (.bat,.sh,...) or if the file starts with "#!" (shebang)
+ file(READ ${resolved_embedded_item} file_contents LIMIT 5)
+ if(NOT "${resolved_embedded_item}" MATCHES "\\.(bat|c?sh|bash|ksh|cmd)$" AND
+ NOT file_contents MATCHES "^#!")
+ set(cmd ${CMAKE_INSTALL_NAME_TOOL} ${changes} "${resolved_embedded_item}")
+ execute_process(COMMAND ${cmd} RESULT_VARIABLE install_name_tool_result)
+ if(NOT install_name_tool_result EQUAL 0)
+ string(REPLACE ";" "' '" msg "'${cmd}'")
+ message(FATAL_ERROR "Command failed:\n ${msg}")
+ endif()
endif()
endif()
endfunction()