Skip to content

Commit

Permalink
[cmake] fix iOS xcode property setting failed (cocos2d#19208)
Browse files Browse the repository at this point in the history
* fix iOS xcode property setting failed

* use search_depend_libs_recursive at dlls collect

* fix typo
  • Loading branch information
drelaptop committed Jan 16, 2019
1 parent 9e6471b commit 0a4adb1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
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)

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})
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 @@ -32,6 +32,10 @@ endif()
set(COCOS_EXTERNAL_DIR ${COCOS2DX_ROOT_PATH}/external)
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

0 comments on commit 0a4adb1

Please sign in to comment.