Merge pull request #1501 from colobot/dev-fix-macos-compilation

Fix compilation under MacOS
fix-squashed-planets
Tomasz Kapuściński 2023-04-08 19:11:43 +02:00 committed by GitHub
commit 2e95aeac9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 2 deletions

View File

@ -76,6 +76,42 @@ jobs:
name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }})
path: build/gtestresults.xml
if: matrix.target_os == 'linux'
build-macos:
runs-on: ${{ matrix.host_os }}
container: ${{ matrix.container }}
strategy:
matrix:
target_os: [macos]
host_os: [macos-11, macos-12]
container: ['']
fail-fast: false
steps:
- name: Install Colobot dependencies
run: brew install cmake sdl2 sdl2_image sdl2_ttf boost glew physfs flac libsndfile libvorbis vorbis-tools gettext libicns librsvg wget xmlstarlet
if: matrix.container == ''
- uses: actions/checkout@v2
- name: Checkout the Google Test submodule
run: git submodule update --init -- lib/googletest
- name: Create build directory
run: cmake -E make_directory build
- name: Run CMake (for Mac)
working-directory: build
run: cmake -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTESTS=1 -DDESKTOP=1 -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd ..
if: matrix.target_os == 'macos'
- name: Build
working-directory: build
run: make -j `nproc`
- name: Run tests
# TODO: Maybe run Windows tests using wine as well?
working-directory: build
run: ./colobot_ut --gtest_output=xml:gtestresults.xml
if: matrix.target_os == 'macos'
- name: Upload test results
uses: actions/upload-artifact@v2
with:
name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }})
path: build/gtestresults.xml
if: matrix.target_os == 'macos'
build-windows:
runs-on: windows-2019
strategy:

View File

@ -106,6 +106,8 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
# Platform-dependent implementation of system.h
set(SYSTEM_CPP_MODULE "system_macosx.cpp")
set(SYSTEM_H_MODULE "system_macosx.h")
# Fix compilation errors in MacOS SDK files
set(CMAKE_CXX_FLAGS "${NORMAL_CXX_FLAGS} -Wno-nullability-extension -Wno-nullability-completeness -Wno-expansion-to-defined -Wno-four-char-constants -Wno-gnu-zero-variadic-macro-arguments -Wno-variadic-macros -Wno-zero-length-array")
# To avoid CMake warning
set(CMAKE_MACOSX_RPATH 1)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")

View File

@ -4,7 +4,7 @@ To compile Colobot on MacOS X, you need to first get Developer Command Line Tool
After installing Developer Command Line Tools, you should have basic tools like clang and git installed. After that, you can grab other required packages with Homebrew. So as in instructions on [the project page](http://brew.sh/):
```bash
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
And then:
```bash
@ -20,7 +20,7 @@ If you've installed everything correctly, the simple way of compiling Colobot wi
git clone --recursive https://github.com/colobot/colobot.git
mkdir colobot/build
cd colobot/build
cmake ../
cmake -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd ../
make
```