@ -19,56 +19,96 @@ endfunction()
include ( BundleUtilities )
include ( BundleUtilities )
cmake_policy ( SET CMP0012 NEW ) # n e w p o l i c y f o r t h e i f t h a t e v a l u a t e s a b o o l e a n o u t o f t h e L Y _ B U I L D _ F I X U P _ B U N D L E e x p a n s i o n
cmake_policy ( SET CMP0012 NEW ) # n e w p o l i c y f o r t h e i f t h a t e v a l u a t e s a b o o l e a n o u t o f t h e L Y _ B U I L D _ F I X U P _ B U N D L E e x p a n s i o n
cmake_policy ( SET CMP0009 NEW ) # d o n o t t r a v e r s e s y m l i n k s o n G L O B _ R E C U R S E
set ( anything_new FALSE )
set ( anything_new FALSE )
set ( plugin_libs )
set ( plugin_libs )
set ( plugin_dirs )
set ( plugin_dirs )
set ( depends_on_python FALSE )
find_program ( LY_INSTALL_NAME_TOOL install_name_tool )
if ( NOT LY_INSTALL_NAME_TOOL )
message ( FATAL_ERROR "Unable to locate 'install_name_tool'" )
endif ( )
function ( ly_copy source_file target_directory )
function ( ly_copy source_file target_directory )
get_filename_component ( target_filename "${source_file}" NAME )
get_filename_component ( target_filename "${source_file}" NAME )
# I f s o u r c e _ f i l e i s a F r a m e w o r k a n d t a r g e t _ d i r e c t o r y i s a b u n d l e
# I f ta r g e t _ d i r e c t o r y i s a b u n d l e
if ( "${ source_file}" MATCHES "\\.[Ff]ramework[^\\.]" AND "${ target_directory}" MATCHES "\\.app/Contents/MacOS" )
if ( "${ target_directory}" MATCHES "\\.app/Contents/MacOS" )
if ( NOT @LY_BUILD_FIXUP_BUNDLE@ )
set ( target_is_bundle TRUE )
return ( )
if ( "${source_file}" MATCHES "\\.[Ff]ramework[^\\.]" )
endif ( )
# f i x u p o r i g i n t o c o p y t h e w h o l e F r a m e w o r k f o l d e r a n d c h a n g e d e s t i n a t i o n t o C o n t e n t s / F r a m e w o r k s
if ( NOT @LY_BUILD_FIXUP_BUNDLE@ )
string ( REGEX REPLACE "(.*\\.[Ff]ramework).*" "\\1" source_file "${source_file}" )
return ( )
get_filename_component ( source_file_folder "${source_file}" DIRECTORY )
endif ( )
set ( local_plugin_dirs ${ plugin_dirs } )
# f i x u p o r i g i n t o c o p y t h e w h o l e F r a m e w o r k f o l d e r a n d c h a n g e d e s t i n a t i o n t o C o n t e n t s / F r a m e w o r k s
list ( APPEND local_plugin_dirs "${source_file_folder}" )
string ( REGEX REPLACE "(.*\\.[Ff]ramework).*" "\\1" source_file "${source_file}" )
set ( plugin_dirs ${ local_plugin_dirs } PARENT_SCOPE )
get_filename_component ( source_file_folder "${source_file}" DIRECTORY )
return ( )
# P y t h o n . f r a m e w o r k p r o d u c e s a b u g i n B u n d l e U t i l i t i e s s o i t n e e d s m a n u a l h a n d l i n g
# h t t p s : / / g i t l a b . k i t w a r e . c o m / c m a k e / c m a k e / - / i s s u e s / 2 0 1 6 5
if ( "${source_file}" MATCHES "Python.framework" )
# f i x u p t h e d e s t i n a t i o n s o i t e n d s u p i n C o n t e n t s / F r a m e w o r k s
string ( REGEX REPLACE "(.*\\.app/Contents)/MacOS" "\\1/Frameworks" target_directory "${target_directory}" )
set ( local_plugin_dirs ${ plugin_dirs } )
list ( APPEND local_plugin_dirs "${target_directory}/Python.framework" )
set ( target_filename Python.framework )
set ( plugin_dirs ${ local_plugin_dirs } PARENT_SCOPE )
set ( depends_on_python TRUE PARENT_SCOPE )
else ( )
set ( local_plugin_dirs ${ plugin_dirs } )
list ( APPEND local_plugin_dirs "${source_file_folder}" )
set ( plugin_dirs ${ local_plugin_dirs } PARENT_SCOPE )
return ( )
endif ( )
elseif ( "${source_file}" MATCHES "qt/plugins" AND "${target_directory}" MATCHES "\\.app/Contents/MacOS" )
elseif ( "${source_file}" MATCHES "qt/plugins ")
if ( NOT @LY_BUILD_FIXUP_BUNDLE@ )
if ( NOT @LY_BUILD_FIXUP_BUNDLE@ )
return ( )
return ( )
endif ( )
endif ( )
# f i x u p t h e d e s t i n a t i o n s o i t e n d s u p i n C o n t e n t s / P l u g i n s
# f i x u p t h e d e s t i n a t i o n s o i t e n d s u p i n C o n t e n t s / P l u g i n s
string ( REGEX REPLACE "(.*\\.app/Contents)/MacOS" "\\1/plugins" target_directory "${target_directory}" )
string ( REGEX REPLACE "(.*\\.app/Contents)/MacOS" "\\1/plugins" target_directory "${target_directory}" )
set ( local_plugin_dirs ${ plugin_dirs } )
set ( local_plugin_dirs ${ plugin_dirs } )
list ( APPEND local_plugin_dirs "${target_directory}" )
list ( APPEND local_plugin_dirs "${target_directory}" )
set ( plugin_dirs ${ local_plugin_dirs } PARENT_SCOPE )
set ( plugin_dirs ${ local_plugin_dirs } PARENT_SCOPE )
set ( local_plugin_libs ${ plugin_libs } )
set ( local_plugin_libs ${ plugin_libs } )
list ( APPEND local_plugin_libs "${target_directory}/${target_filename}" )
list ( APPEND local_plugin_libs "${target_directory}/${target_filename}" )
set ( plugin_libs ${ local_plugin_libs } PARENT_SCOPE )
set ( plugin_libs ${ local_plugin_libs } PARENT_SCOPE )
elseif ( "${source_file}" MATCHES "qt/translations " AND "${target_directory}" MATCHES "\\.app/Contents/MacOS ")
elseif ( "${source_file}" MATCHES "qt/translations ")
return ( ) # s k i p , i s t h i s u s e d ?
return ( ) # s k i p , i s t h i s u s e d ?
elseif ( "${source_file}" MATCHES ".dylib" )
elseif ( "${source_file}" MATCHES ".dylib" )
set ( local_plugin_dirs ${ plugin_dirs } )
set ( local_plugin_dirs ${ plugin_dirs } )
list ( APPEND local_plugin_dirs "${target_directory}" )
list ( APPEND local_plugin_dirs "${target_directory}" )
set ( plugin_dirs ${ local_plugin_dirs } PARENT_SCOPE )
set ( plugin_dirs ${ local_plugin_dirs } PARENT_SCOPE )
endif ( )
else ( )
# t a r g e t i s n o t a b u n d l e
set ( target_is_bundle FALSE )
if ( "${source_file}" MATCHES "\\.[Ff]ramework[^\\.]" )
# f i x u p o r i g i n t o c o p y t h e w h o l e F r a m e w o r k f o l d e r
string ( REGEX REPLACE "(.*\\.[Ff]ramework).*" "\\1" source_file "${source_file}" )
get_filename_component ( target_filename "${source_file}" NAME )
if ( "${source_file}" MATCHES "Python.framework" )
set ( depends_on_python TRUE PARENT_SCOPE )
endif ( )
endif ( )
endif ( )
endif ( )
@ -79,6 +119,11 @@ function(ly_copy source_file target_directory)
endif ( )
endif ( )
if ( NOT EXISTS "${target_directory}/${target_filename}" OR "${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}" )
if ( NOT EXISTS "${target_directory}/${target_filename}" OR "${source_file}" IS_NEWER_THAN "${target_directory}/${target_filename}" )
message ( STATUS "Copying \" ${ source_file } \" to \"${target_directory}\"...")
message ( STATUS "Copying \" ${ source_file } \" to \"${target_directory}\"...")
if ( NOT target_is_bundle )
# i f i t i s a b u n d l e , t h e r e i s n o c o n t e n t i o n a b o u t t h e f i l e s i n t h e d e s t i n a t i o n , e a c h b u n d l e t a r g e t w i l l c o p y e v e r y t h i n g
# w e d o n t w a n t t h e s e f i l e s t o i n v a l i d a t e t h e b u n d l e a n d c a u s e a n e w s i g n a t u r e
file ( LOCK ${ target_directory } / ${ target_filename } .lock GUARD FUNCTION TIMEOUT 300 )
endif ( )
file ( COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN )
file ( COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN )
file ( TOUCH ${ target_directory } / ${ target_filename } )
file ( TOUCH ${ target_directory } / ${ target_filename } )
set ( anything_new TRUE PARENT_SCOPE )
set ( anything_new TRUE PARENT_SCOPE )
@ -93,6 +138,7 @@ if(NOT @LY_BUILD_FIXUP_BUNDLE@)
endif ( )
endif ( )
if ( @target_file_dir@ MATCHES ".app/Contents/MacOS" )
if ( @target_file_dir@ MATCHES ".app/Contents/MacOS" )
string ( REGEX REPLACE "(.*\\.app)/Contents/MacOS.*" "\\1" bundle_path "@target_file_dir@" )
string ( REGEX REPLACE "(.*\\.app)/Contents/MacOS.*" "\\1" bundle_path "@target_file_dir@" )
set ( fixup_timestamp_file "${bundle_path}.fixup.stamp" )
set ( fixup_timestamp_file "${bundle_path}.fixup.stamp" )
if ( NOT anything_new )
if ( NOT anything_new )
@ -106,31 +152,44 @@ if(@target_file_dir@ MATCHES ".app/Contents/MacOS")
if ( EXISTS ${ bundle_path } /Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7 )
if ( EXISTS ${ bundle_path } /Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7 )
list ( APPEND fixup_bundle_ignore dxc-3.7 )
list ( APPEND fixup_bundle_ignore dxc-3.7 )
endif ( )
endif ( )
# P y t h o n . f r a m e w o r k b e i n g c o p i e d b y f i x u p _ b u n d l e
# L Y N - 4 5 0 2 : P a t c h p y t h o n b u n d l e , i t c o n t a i n s s o m e w i n d o w s e x e c u t a b l e s , s o m e f i l e s t h a t f i x u p _ b u n d l e d o e s n t l i k e a n d h a s
# if ( EXISTS ${ bundle_path } /Contents/Frameworks/Python.framework )
# o t h e r i s s u e s t h a t p r o d u c e s i g n a t u r e p r o b l e m s
# # L Y N - 4 5 0 2 : P a t c h p y t h o n b u n d l e , i t c o n t a i n s s o m e w i n d o w s e x e c u t a b l e s , s o m e f i l e s t h a t f i x u p _ b u n d l e d o e s n t l i k e a n d h a s
if ( depends_on_python )
# # d u p l i c a t e d b i n a r i e s b e t w e e n V e r s i o n s / 3 . 7 a n d V e r s i o n s / C u r r e n t .
message ( STATUS "Fixing ${bundle_path}/Contents/Frameworks/Python.framework..." )
# file ( GLOB exe_files
list ( APPEND fixup_bundle_ignore Python python3.7m python3.7 )
# $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7 / l i b / p y t h o n 3 . 7 / d i s t u t i l s / c o m m a n d / * . e x e
file ( REMOVE_RECURSE
# $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7 / l i b / p y t h o n 3 . 7 / s i t e - p a c k a g e s / p i p / _ v e n d o r / d i s t l i b / * . e x e
$ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / C u r r e n t
# $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7 / l i b / p y t h o n 3 . 7 / s i t e - p a c k a g e s / s e t u p t o o l s / * . e x e
$ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7 / H e a d e r s
# )
$ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7 / l i b / P y t h o n
# foreach ( exe_file ${ exe_files } )
$ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7 / l i b / p y t h o n 3 . 7 / t e s t
# file ( REMOVE ${ exe_file } )
$ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7 / l i b / p y t h o n 3 . 7 / s i t e - p a c k a g e s / s c i p y / i o / t e s t s
# endforeach ( )
$ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / P y t h o n
# file ( REMOVE_RECURSE
$ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / R e s o u r c e s
# $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7 / l i b / p y t h o n 3 . 7 / t e s t
$ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / H e a d e r s
# $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7 / l i b / p y t h o n 3 . 7 / s i t e - p a c k a g e s / s c i p y / i o / t e s t s
)
# $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7 / R e s o u r c e s
file ( GLOB_RECURSE exe_file_list "${bundle_path}/Contents/Frameworks/Python.framework/**/*.exe" )
# $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / P y t h o n
if ( exe_file_list )
# $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / R e s o u r c e s / P y t h o n . a p p
file ( REMOVE_RECURSE ${ exe_file_list } )
# $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7 / P y t h o n
endif ( )
# )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E create_symlink include/python3.7m Headers
# file ( REMOVE_RECURSE ${ bundle_path } /Contents/Frameworks/Python.framework/Versions/Current )
W O R K I N G _ D I R E C T O R Y $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s / 3 . 7
# execute_process ( COMMAND ${ CMAKE_COMMAND } -E create_symlink 3.7 Current
)
# W O R K I N G _ D I R E C T O R Y $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s /
execute_process ( COMMAND ${ CMAKE_COMMAND } -E create_symlink 3.7 Current
# )
W O R K I N G _ D I R E C T O R Y $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k / V e r s i o n s /
# endif ( )
)
execute_process ( COMMAND ${ CMAKE_COMMAND } -E create_symlink Versions/Current/Python Python
W O R K I N G _ D I R E C T O R Y $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k
)
execute_process ( COMMAND ${ CMAKE_COMMAND } -E create_symlink Versions/Current/Headers Headers
W O R K I N G _ D I R E C T O R Y $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k
)
execute_process ( COMMAND ${ CMAKE_COMMAND } -E create_symlink Versions/Current/Resources Resources
W O R K I N G _ D I R E C T O R Y $ { b u n d l e _ p a t h } / C o n t e n t s / F r a m e w o r k s / P y t h o n . f r a m e w o r k
)
file ( CHMOD ${ bundle_path } /Contents/Frameworks/Python.framework/Versions/Current/Python
P E R M I S S I O N S O W N E R _ R E A D O W N E R _ W R I T E O W N E R _ E X E C U T E G R O U P _ R E A D G R O U P _ W R I T E G R O U P _ E X E C U T E W O R L D _ R E A D W O R L D _ E X E C U T E
)
endif ( )
list ( REMOVE_DUPLICATES plugin_libs )
list ( REMOVE_DUPLICATES plugin_libs )
list ( REMOVE_DUPLICATES plugin_dirs )
list ( REMOVE_DUPLICATES plugin_dirs )
fixup_bundle ( "${bundle_path}" "${plugin_libs}" "${plugin_dirs}" IGNORE_ITEM ${ fixup_bundle_ignore } )
fixup_bundle ( "${bundle_path}" "${plugin_libs}" "${plugin_dirs}" IGNORE_ITEM ${ fixup_bundle_ignore } )
@ -139,11 +198,27 @@ if(@target_file_dir@ MATCHES ".app/Contents/MacOS")
# f i x u p b u n d l e e n d s u p r e m o v i n g t h e r p a t h o f dxc ( despite we exclude it )
# f i x u p b u n d l e e n d s u p r e m o v i n g t h e r p a t h o f dxc ( despite we exclude it )
if ( EXISTS ${ bundle_path } /Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7 )
if ( EXISTS ${ bundle_path } /Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7 )
find_program ( LY_INSTALL_NAME_TOOL install_name_tool )
if ( NOT LY_INSTALL_NAME_TOOL )
message ( FATAL_ERROR "Unable to locate 'install_name_tool'" )
endif ( )
execute_process ( COMMAND ${ LY_INSTALL_NAME_TOOL } -add_rpath @executable_path/../lib ${ bundle_path } /Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7 )
execute_process ( COMMAND ${ LY_INSTALL_NAME_TOOL } -add_rpath @executable_path/../lib ${ bundle_path } /Contents/MacOS/Builders/DirectXShaderCompiler/bin/dxc-3.7 )
endif ( )
endif ( )
# m i s p l a c e d . D S _ S t o r e f i l e s c a n c a u s e s i g n i n g t o f a i l
# I n t e r r u p t e d s i g n a t u r e s c a n l e a v e c s t e m p f i l e s b e h i n d t h a t f a i l n e x t s i g n a t u r e
file ( GLOB_RECURSE remove_file_list
" $ { b u n d l e _ p a t h } / * * / . D S _ S t o r e "
" $ { b u n d l e _ p a t h / } * * / * . c s t e m p "
)
if ( remove_file_list )
file ( REMOVE_RECURSE ${ remove_file_list } )
endif ( )
endif ( )
endif ( )
else ( ) # N o n - b u n d l e c a s e
if ( depends_on_python )
# R P A T H f i x p y t h o n
execute_process ( COMMAND ${ LY_INSTALL_NAME_TOOL } -change @rpath/Python @rpath/Python.framework/Versions/Current/Python @target_file@ )
endif ( )
endif ( )
endif ( )