Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion .github/workflows/cmake_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
cc: clang
cxx: clang++
cmake-opts: '-DUHDR_BUILD_TESTS=1 -DUHDR_ENABLE_LOGS=1 -DUHDR_ENABLE_INSTALL=1 -DUHDR_ENABLE_WERROR=1'
run_tests: true
expected_arch: arm64

# <macOS-latest ARM64 Platform, Release Build, Clang toolchain, Ninja generator, Build Deps>
- name: "macOS latest ARM64 clang rel ninja with deps"
Expand All @@ -26,6 +28,8 @@ jobs:
cc: clang
cxx: clang++
cmake-opts: '-DUHDR_BUILD_TESTS=1 -DUHDR_ENABLE_LOGS=1 -DUHDR_BUILD_DEPS=1 -DUHDR_ENABLE_WERROR=1'
run_tests: true
expected_arch: arm64

# <macOS-latest ARM64 Platform, Release Build, Clang toolchain, Ninja generator, Static linking>
- name: "macOS latest ARM64 clang rel ninja static"
Expand All @@ -34,6 +38,29 @@ jobs:
cc: clang
cxx: clang++
cmake-opts: '-DUHDR_BUILD_TESTS=1 -DUHDR_ENABLE_LOGS=1 -DUHDR_ENABLE_INSTALL=1 -DBUILD_SHARED_LIBS=0 -DUHDR_ENABLE_WERROR=1'
run_tests: true
expected_arch: arm64

# <macOS-15 Intel Platform, Release Build, Clang toolchain, Ninja generator>
- name: "macOS-15 Intel clang rel ninja"
os: macos-15-intel
build_type: Release
cc: clang
cxx: clang++
cmake-opts: '-DUHDR_BUILD_TESTS=1 -DUHDR_ENABLE_LOGS=1 -DUHDR_ENABLE_INSTALL=1 -DUHDR_ENABLE_WERROR=1'
run_tests: true
run_cli_smoke: true
expected_arch: x86_64

# <macOS-latest ARM64 Platform, cross-compiled x86_64, Release Build, Clang toolchain, Ninja generator, Build Deps>
- name: "macOS latest ARM64 cross x86_64 clang rel ninja with deps"
os: macos-latest
build_type: Release
cc: clang
cxx: clang++
cmake-opts: '-DUHDR_BUILD_TESTS=1 -DUHDR_ENABLE_LOGS=1 -DUHDR_BUILD_DEPS=1 -DUHDR_ENABLE_WERROR=1 -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0'
run_tests: false
expected_arch: x86_64

steps:
- name: Checkout the repository
Expand Down Expand Up @@ -65,6 +92,34 @@ jobs:
- name: Build
run: cmake --build build --config ${{ matrix.config.build_type }}

- name: Verify artifact architecture
env:
EXPECTED_ARCH: ${{ matrix.config.expected_arch }}
shell: bash
run: |
artifacts=(
build/libuhdr.a
build/ultrahdr_app
build/ultrahdr_unit_test
)
if [[ -e build/libuhdr.dylib ]]; then
artifacts+=(build/libuhdr.dylib)
fi
if [[ -e build/turbojpeg/src/turbojpeg-build/libjpeg.a ]]; then
artifacts+=(build/turbojpeg/src/turbojpeg-build/libjpeg.a)
fi
for artifact in "${artifacts[@]}"; do
test "$(lipo -archs "$artifact")" = "$EXPECTED_ARCH"
done

- name: Test
if: matrix.config.run_tests
working-directory: build
run: ctest --build-config ${{ matrix.config.build_type }}
run: ctest --build-config ${{ matrix.config.build_type }}

- name: Test CLI
if: matrix.config.run_cli_smoke
run: |
build/ultrahdr_app -m 0 -p tests/data/raw_p010_image.p010 -w 1280 -h 720 -a 0 -z build/cli-smoke.jpeg
build/ultrahdr_app -m 1 -j build/cli-smoke.jpeg -P
build/ultrahdr_app -m 1 -j build/cli-smoke.jpeg -o 1 -O 5 -z build/cli-smoke.raw
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,17 @@ endif()
if(DEFINED UHDR_ANDROID_NDK_PATH)
list(APPEND UHDR_CMAKE_ARGS -DUHDR_ANDROID_NDK_PATH=${UHDR_ANDROID_NDK_PATH})
endif()
if(APPLE)
if(DEFINED CMAKE_OSX_ARCHITECTURES AND NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
list(APPEND UHDR_CMAKE_ARGS "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}")
endif()
if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET AND NOT "${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "")
list(APPEND UHDR_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
if(DEFINED CMAKE_OSX_SYSROOT AND NOT "${CMAKE_OSX_SYSROOT}" STREQUAL "")
list(APPEND UHDR_CMAKE_ARGS "-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}")
endif()
endif()

# opengl es libraries
if(UHDR_ENABLE_GLES)
Expand Down
20 changes: 20 additions & 0 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,26 @@ ninja
ctest
```

#### Cross-compiling for Intel on Apple Silicon

From the libultrahdr source directory, build a thin x86_64 binary on an Apple
Silicon Mac:

```sh
cmake -G Ninja -S . -B build-x86_64 \
-DCMAKE_OSX_ARCHITECTURES=x86_64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-DUHDR_BUILD_DEPS=1 \
-DUHDR_BUILD_TESTS=1
cmake --build build-x86_64
```

`UHDR_BUILD_DEPS=1` builds libjpeg-turbo and test dependencies for the
requested architecture. When using installed dependencies instead, they must
contain an x86_64 slice. Only one value in `CMAKE_OSX_ARCHITECTURES` is
supported per build; universal arm64+x86_64 builds are not supported. Running
the x86_64 tests on Apple Silicon requires Rosetta 2.

This will generate the following files under `build_directory`:

**libuhdr.{version}.dylib** - Shared library for the libuhdr API <br>
Expand Down
Loading