Skip to content

Commit a31675f

Browse files
authored
Merge pull request #308 from Dnawrkshp/master
Add Mac OS build support
2 parents 6a9ce47 + 57de652 commit a31675f

File tree

4 files changed

+72
-11
lines changed

4 files changed

+72
-11
lines changed

.github/workflows/release.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,34 @@ jobs:
1616
sys:
1717
- { os: windows-latest, shell: pwsh }
1818
- { os: ubuntu-latest, shell: bash }
19+
- { os: macos-latest, shell: bash }
1920

2021
steps:
2122
- name: Checkout
2223
uses: actions/checkout@v3
2324
with:
2425
submodules: 'recursive'
2526

26-
- name: Install Dependencies
27+
- name: Install Ubuntu Dependencies
2728
if: ${{ matrix.sys.os == 'ubuntu-latest' }}
2829
run: sudo apt update && sudo apt install extra-cmake-modules libwayland-dev libxkbcommon-dev wayland-protocols xorg-dev zenity
2930

30-
- name: Configure CMake
31+
- name: Install MacOS Dependencies
32+
if: ${{ matrix.sys.os == 'macos-latest' }}
33+
run: brew update && brew install cmake libpng zlib pkg-config
34+
35+
- name: Configure Ubuntu CMake
36+
if: ${{ matrix.sys.os == 'ubuntu-latest' }}
3137
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DZIP_RELEASE=1
3238

39+
- name: Configure Windows CMake
40+
if: ${{ matrix.sys.os == 'windows-latest' }}
41+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DZIP_RELEASE=1
42+
43+
- name: Configure MacOS CMake
44+
if: ${{ matrix.sys.os == 'macos-latest' }}
45+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DPNG_ARM_NEON=off -DZIP_RELEASE=1
46+
3347
- name: Build
3448
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
3549

.github/workflows/test.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,34 @@ jobs:
1717
sys:
1818
- { os: windows-latest, shell: pwsh }
1919
- { os: ubuntu-latest, shell: bash }
20+
- { os: macos-latest, shell: bash }
2021

2122
steps:
2223
- name: Checkout
2324
uses: actions/checkout@v3
2425
with:
2526
submodules: 'recursive'
2627

27-
- name: Install Dependencies
28+
- name: Install Ubuntu Dependencies
2829
if: ${{ matrix.sys.os == 'ubuntu-latest' }}
2930
run: sudo apt update && sudo apt install extra-cmake-modules libwayland-dev libxkbcommon-dev wayland-protocols xorg-dev zenity
3031

31-
- name: Configure CMake
32+
- name: Install MacOS Dependencies
33+
if: ${{ matrix.sys.os == 'macos-latest' }}
34+
run: brew update && brew install cmake libpng zlib pkg-config
35+
36+
- name: Configure Ubuntu CMake
37+
if: ${{ matrix.sys.os == 'ubuntu-latest' }}
3238
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
3339

40+
- name: Configure Windows CMake
41+
if: ${{ matrix.sys.os == 'windows-latest' }}
42+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
43+
44+
- name: Configure MacOS CMake
45+
if: ${{ matrix.sys.os == 'macos-latest' }}
46+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DPNG_ARM_NEON=off
47+
3448
- name: Build
3549
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel 2
3650

.github/workflows/unstable.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,34 @@ jobs:
1515
sys:
1616
- { os: windows-latest, shell: pwsh }
1717
- { os: ubuntu-latest, shell: bash }
18+
- { os: macos-latest, shell: bash }
1819

1920
steps:
2021
- name: Checkout
2122
uses: actions/checkout@v3
2223
with:
2324
submodules: 'recursive'
2425

25-
- name: Install Dependencies
26+
- name: Install Ubuntu Dependencies
2627
if: ${{ matrix.sys.os == 'ubuntu-latest' }}
2728
run: sudo apt update && sudo apt install extra-cmake-modules libwayland-dev libxkbcommon-dev wayland-protocols xorg-dev zenity
2829

29-
- name: Configure CMake
30+
- name: Install MacOS Dependencies
31+
if: ${{ matrix.sys.os == 'macos-latest' }}
32+
run: brew update && brew install cmake libpng zlib pkg-config
33+
34+
- name: Configure Ubuntu CMake
35+
if: ${{ matrix.sys.os == 'ubuntu-latest' }}
3036
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DZIP_RELEASE=1
3137

38+
- name: Configure Windows CMake
39+
if: ${{ matrix.sys.os == 'windows-latest' }}
40+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DZIP_RELEASE=1
41+
42+
- name: Configure MacOS CMake
43+
if: ${{ matrix.sys.os == 'macos-latest' }}
44+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DPNG_ARM_NEON=off -DZIP_RELEASE=1
45+
3246
- name: Build
3347
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel 2
3448

cmake/wrench_compiler_flags.cmake

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
1+
if(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
22
if (CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
33
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /MP")
44
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /O2")
@@ -10,8 +10,17 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
1010
endif()
1111

1212
if(NOT PORTABLE_BUILD)
13-
# Both frontends support -march=native
14-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
13+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
14+
# Apple Silicon / Intel mac
15+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
16+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=apple-m1")
17+
else()
18+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
19+
endif()
20+
else()
21+
# Windows & Linux support -march=native
22+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
23+
endif()
1524
endif()
1625
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
1726
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-sign-compare")
@@ -32,7 +41,7 @@ else()
3241
message(SEND_ERROR "No flags available for C Compiler ${CMAKE_C_COMPILER_ID}.")
3342
endif()
3443

35-
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
44+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
3645
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
3746
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /EHsc /MP")
3847
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2")
@@ -53,7 +62,17 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
5362
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -g")
5463

5564
if(NOT PORTABLE_BUILD)
56-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
65+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
66+
# Apple Silicon / Intel mac
67+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
68+
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -mcpu=apple-m1")
69+
else()
70+
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -march=native")
71+
endif()
72+
else()
73+
# Windows & Linux support -march=native
74+
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -march=native")
75+
endif()
5776
endif()
5877
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
5978
# /W4 - enable all non-default-disabled warnings (-Wall equivalent)

0 commit comments

Comments
 (0)