Skip to content

Commit

Permalink
Fix a compilation issue and a crash issue if using Xcode 15 (#16306)
Browse files Browse the repository at this point in the history
* Fix crash in __cxx_global_var_init if using Xcode 15 and targeting <= iOS 14

* fixed #16190: Compilation errors if using Clang 15 with c++17 since std::unary_function has been removed (#16191)

* fixed #16190: Compilation errors if using Clang 15 with c++17 since std::unary_function has been removed

* Windows doesn't need to define BOOST_NO_CXX98_FUNCTION_BASE since it has already been defined.
  • Loading branch information
dumganhar authored Sep 21, 2023
1 parent 2039c33 commit 8c3e160
Showing 1 changed file with 14 additions and 0 deletions.
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

0 comments on commit 8c3e160

Please sign in to comment.