Fix error during Xcode archive

This commit is contained in:
Benau 2021-09-28 13:00:25 +08:00
parent 781273b472
commit 31ce998cda
2 changed files with 26 additions and 0 deletions

View File

@ -58,6 +58,10 @@ if((UNIX AND NOT APPLE) OR NINTENDO_SWITCH)
include(FindPkgConfig)
endif()
if(IOS)
include(cmake/XcodeHelper.cmake)
endif()
if(APPLE AND NOT IOS)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
set(ARCHFLAGS "arm64")
@ -568,6 +572,14 @@ else()
XCODE_ATTRIBUTE_INSTALL_PATH /Applications
XCODE_ATTRIBUTE_SKIP_INSTALL No
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
if(CMAKE_GENERATOR MATCHES "Xcode")
get_all_targets(supertuxkart_targets ${CMAKE_CURRENT_LIST_DIR})
foreach(target IN LISTS supertuxkart_targets)
if (NOT target MATCHES "supertuxkart")
set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib$(EFFECTIVE_PLATFORM_NAME)/${target})
endif()
endforeach()
endif()
else()
add_executable(supertuxkart ${STK_SOURCES} ${STK_RESOURCES} ${STK_HEADERS})
endif()

14
cmake/XcodeHelper.cmake Normal file
View File

@ -0,0 +1,14 @@
# Collect all currently added targets in all subdirectories
#
# Parameters:
# - _result the list containing all found targets
# - _dir root directory to start looking from
function(get_all_targets _result _dir)
get_property(_subdirs DIRECTORY "${_dir}" PROPERTY SUBDIRECTORIES)
foreach(_subdir IN LISTS _subdirs)
get_all_targets(${_result} "${_subdir}")
endforeach()
get_directory_property(_sub_targets DIRECTORY "${_dir}" BUILDSYSTEM_TARGETS)
set(${_result} ${${_result}} ${_sub_targets} PARENT_SCOPE)
endfunction()