Skip to content

Commit

Permalink
Fixed: Non-xcode build workaround for macos with xcode 15 or later in…
Browse files Browse the repository at this point in the history
…stalled
  • Loading branch information
richardbiely committed Dec 13, 2023
1 parent 12757c7 commit 83a1a33
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,15 @@ cmake -G Xcode ...
cmake -G Ninja
```

>**NOTE**<br/>
When using MacOS you might run into a few issues caused by the specifics of the platform unrelated to Gaia-ECS. Quick way to fix them is listed bellow.
>
> CMake issue:<br/>
> After you update to a new version of Xcode you might start getting "Ignoring CMAKE_OSX_SYSROOT value: ..." warnings when building the project. Residual cmake cache is to blame here. A solution is to delete files generated by cmake.
>
> Linker issue:<br/>
> When not bulding the project from Xcode and using ***ld*** as your linker, if XCode 15 or later is installed on your system you will most likely run into various issues: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking. In the CMake project a workaround is implemented which adds "-Wl,-ld_classic" to linker settings but if you use a different build system or settings you might want to do same.
### Project settings
Following is a list of parameters you can use to customize your build

Expand Down
22 changes: 22 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ if(MSVC)

enable_cxx_compiler_flag_if_supported("/permissive-")
else()
# MacOS
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
# Workaround for the new linker starting with XCode 15
# https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking
# We need to use -Wl,-ld_classic for the linker for the backwards compatibility when buiding
# outside of XCode because they messed things up.
if(NOT CMAKE_GENERATOR MATCHES "Xcode")
# Make sure xcodebuild is installed. Otherwise we won't be able to tell is the workaround
# needs to be applied
find_program(XCODEBUILD_EXECUTABLE NAMES xcodebuild)

if(XCODEBUILD_EXECUTABLE)
execute_process(COMMAND xcodebuild -version OUTPUT_VARIABLE XCODE_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "([0-9]+)\\.[0-9]+" XCODE_MAJOR_VERSION ${XCODE_VERSION_STRING})

if(XCODE_MAJOR_VERSION GREATER_EQUAL "15")
add_link_options("-Wl,-ld_classic")
endif()
endif()
endif()
endif()

enable_cxx_compiler_flag_if_supported("-fno-exceptions")

# strictness rules
Expand Down

0 comments on commit 83a1a33

Please sign in to comment.