-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cmake] fix iOS xcode property setting failed #19208
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,25 +45,18 @@ function(cocos_mark_multi_resources res_out) | |
set(${res_out} ${tmp_file_list} PARENT_SCOPE) | ||
endfunction() | ||
|
||
# get `cocos_target` depend all dlls, save the result in `all_depend_dlls_out` | ||
function(get_target_depends_ext_dlls cocos_target all_depend_dlls_out) | ||
set(all_depend_ext_dlls) | ||
# get all linked libraries including transitive ones, recursive | ||
function(search_depend_libs_recursive cocos_target all_depends_out) | ||
set(all_depends_inner) | ||
set(targets_prepare_search ${cocos_target}) | ||
# targets_prepare_search, target need find ext libs | ||
set(have_searched_targets) | ||
set(need_search_targets) | ||
while(true) | ||
foreach(tmp_target ${targets_prepare_search}) | ||
get_target_property(tmp_depend_libs ${tmp_target} LINK_LIBRARIES) | ||
list(REMOVE_ITEM targets_prepare_search ${tmp_target}) | ||
# target itself use_cocos_pkg | ||
list(APPEND tmp_depend_libs ${tmp_target}) | ||
foreach(depend_lib ${tmp_depend_libs}) | ||
if(TARGET ${depend_lib}) | ||
get_target_property(tmp_dlls ${depend_lib} CC_DEPEND_DLLS) | ||
if(tmp_dlls) | ||
list(APPEND all_depend_ext_dlls ${tmp_dlls}) | ||
endif() | ||
list(APPEND all_depends_inner ${depend_lib}) | ||
if(NOT (depend_lib STREQUAL tmp_target)) | ||
list(APPEND targets_prepare_search ${depend_lib}) | ||
endif() | ||
|
@@ -75,6 +68,23 @@ function(get_target_depends_ext_dlls cocos_target all_depend_dlls_out) | |
break() | ||
endif() | ||
endwhile(true) | ||
set(${all_depends_out} ${all_depends_inner} PARENT_SCOPE) | ||
endfunction() | ||
|
||
# get `cocos_target` depend all dlls, save the result in `all_depend_dlls_out` | ||
function(get_target_depends_ext_dlls cocos_target all_depend_dlls_out) | ||
|
||
set(depend_libs) | ||
set(all_depend_ext_dlls) | ||
search_depend_libs_recursive(${cocos_target} depend_libs) | ||
foreach(depend_lib ${depend_libs}) | ||
if(TARGET ${depend_lib}) | ||
get_target_property(tmp_dlls ${depend_lib} CC_DEPEND_DLLS) | ||
if(tmp_dlls) | ||
list(APPEND all_depend_ext_dlls ${tmp_dlls}) | ||
endif() | ||
endif() | ||
endforeach() | ||
|
||
set(${all_depend_dlls_out} ${all_depend_ext_dlls} PARENT_SCOPE) | ||
endfunction() | ||
|
@@ -231,26 +241,18 @@ macro(cocos_pak_xcode cocos_target) | |
set(MACOSX_BUNDLE_LONG_VERSION_STRING ${COCOS_APP_LONG_VERSION_STRING}) | ||
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${COCOS_APP_SHORT_VERSION_STRING}) | ||
|
||
message("cocos package: ${cocos_target}, plist file: ${COCOS_APP_INFO_PLIST}") | ||
message(STATUS "cocos package: ${cocos_target}, plist file: ${COCOS_APP_INFO_PLIST}") | ||
|
||
cocos_config_app_xcode_property(${cocos_target}) | ||
endmacro() | ||
|
||
# set Xcode property for application, include all depend target | ||
macro(cocos_config_app_xcode_property cocos_app) | ||
cocos_config_target_xcode_property(${cocos_app}) | ||
# for example, cocos_target: cpp-tests link engine_lib: cocos2d | ||
get_target_property(engine_libs ${cocos_app} LINK_LIBRARIES) | ||
foreach(engine_lib ${engine_libs}) | ||
if(TARGET ${engine_lib}) | ||
cocos_config_target_xcode_property(${engine_lib}) | ||
# for example, engine_lib: cocos2d link external_lib: flatbuffers | ||
get_target_property(external_libs ${engine_lib} LINK_LIBRARIES) | ||
foreach(external_lib ${external_libs}) | ||
if(TARGET ${external_lib}) | ||
cocos_config_target_xcode_property(${external_lib}) | ||
endif() | ||
endforeach() | ||
set(depend_libs) | ||
search_depend_libs_recursive(${cocos_app} depend_libs) | ||
foreach(depend_lib ${depend_libs}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have any dll for ios/xcode? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a function to set Xcode property, not dlls. what we need is a function to find all depend target, and then set property one by one. |
||
if(TARGET ${depend_lib}) | ||
cocos_config_target_xcode_property(${depend_lib}) | ||
endif() | ||
endforeach() | ||
endmacro() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that instead of all those functions and property CC_DEPEND_DLLS set for each target in external libs we should just have list of targets (curl zlib ... ) and used this list where needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check
cocos2d/cocos2d-x-3rd-party-libs-bin#330 (comment)
I think that we should call function with list of targets
copy_imported_targets(app curl zlib ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's proper than this one.
I don't think so, since the target lists have existed in the relationship of dependence, we can get them by
LINK_LIBRARIES
property recursively.The defect is CMake didn't supply a functions to get all linked libraries, so we need
search_depend_libs_recursive
, it's a little complex. About the feature CMake should supply, existed thread at https://gitlab.kitware.com/cmake/cmake/issues/12435