From e72e18d9fd08bc5a61efa900d5469cecf5fa9a3e Mon Sep 17 00:00:00 2001 From: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Date: Thu, 23 Sep 2021 21:36:20 +0200 Subject: [PATCH] feat(build): compile "universal" libraries and executables for Mac (#6852) to support both x86_64 and arm64 with a single artifact --- .github/workflows/build.yml | 7 ++++++- CMakeLists.txt | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4e348366..8f2d23e1a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,6 +72,11 @@ jobs: - name: build # NOTE: we need this _build dir to not have xcodebuild's default ./build dir clash with the BUILD file. run: xcodebuild -toolchain clang -configuration Release -target flattests SYMROOT=$(PWD)/_build + - name: check that the binary is "universal" + run: | + info=$(file _build/Release/flatc) + echo $info + echo $info | grep "universal binary with 2 architectures" - name: test run: _build/Release/flattests - name: upload build artifacts @@ -133,7 +138,7 @@ jobs: - name: Build working-directory: kotlin run: ./gradlew clean iosX64Test macosX64Test jsTest jsBrowserTest - + build-kotlin-linux: name: Build Kotlin Linux runs-on: ubuntu-latest diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fe54a275..cccb20931 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,6 +247,7 @@ elseif(CMAKE_COMPILER_IS_GNUCXX) elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") if(APPLE) + set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")