Skip to content
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

Merged
merged 3 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions cmake/Modules/CocosBuildHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Copy link
Contributor

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

Copy link
Contributor

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 ..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

property CC_DEPEND_DLLS set for each target in external libs

yes, it's proper than this one.

we should call function with list of targets

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


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()
Expand Down Expand Up @@ -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})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any dll for ios/xcode?
I thought that all libraries are static (like for Android)

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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()
Expand Down
4 changes: 4 additions & 0 deletions cmake/Modules/CocosBuildSet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ set(CMAKE_DEBUG_TARGET_PROPERTIES
# some useful variables for every one cocos project
set(ENGINE_BINARY_PATH ${PROJECT_BINARY_DIR}/engine)

if(CMAKE_TOOLCHAIN_FILE)
message(STATUS "using toolchain file:" ${CMAKE_TOOLCHAIN_FILE})
endif()

message(STATUS "PROJECT_NAME:" ${PROJECT_NAME})
message(STATUS "PROJECT_SOURCE_DIR:" ${PROJECT_SOURCE_DIR})
message(STATUS "COCOS2DX_ROOT_PATH:" ${COCOS2DX_ROOT_PATH})
Expand Down