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

Fix a compilation issue and a crash issue if using Xcode 15 #16306

Merged
merged 2 commits into from
Sep 21, 2023
Merged
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
14 changes: 14 additions & 0 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ if(USE_SERVER_MODE)
add_definitions(-DCC_SERVER_MODE)
endif()

# Fix the issue: https://github.com/cocos/cocos-engine/issues/16190
# std::unary_function was removed since clang 15
# The macro has already been defined in boost/config/stdlib/dinkumware.hpp(258,1),
# so no need to define it again to avoid 'macro redefinition' error.
if(NOT WINDOWS)
add_definitions(-DBOOST_NO_CXX98_FUNCTION_BASE)
endif()

add_definitions(-DCC_NETMODE_CLIENT=0)
add_definitions(-DCC_NETMODE_LISTEN_SERVER=1)
Expand Down Expand Up @@ -3292,6 +3299,13 @@ if(APPLE)
CC_KEYBOARD_SUPPORT
)
elseif(IOS)

if("${XCODE_VERSION}" VERSION_GREATER_EQUAL "15.0")
# For Xcode 15 and newer, add extra link flags to fix crash in __cxx_global_var_init.
message(STATUS "Using Xcode 15 or newer, adding extra link flags: -Wl,-ld_classic.")
target_link_options(${ENGINE_NAME} PUBLIC -Wl,-ld_classic)
endif()

target_link_libraries(${ENGINE_NAME} PUBLIC
"-framework QuartzCore"
"-framework MetalPerformanceShaders"
Expand Down