Skip to content

Commit 5833385

Browse files
tsukasa-artclaude
andcommitted
build(linux): switch to vcpkg static linking for libpict.so
Linux/arm64 CI now uses vcpkg with x64-linux-static / arm64-linux-static triplets instead of apt + pkg-config. This statically links libavif, libwebp, libjpeg-turbo, and libpng into libpict.so, eliminating runtime dependencies on system shared libraries. - Add cmake/triplets/x64-linux-static.cmake - Add cmake/triplets/arm64-linux-static.cmake - CMakeLists.txt: extend WIN32 guard to VCPKG_TARGET_TRIPLET so Linux uses find_package (vcpkg) path when triplet is set - build.yml: replace apt deps + plain cmake with vcpkg install + Ninja Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fdd893a commit 5833385

4 files changed

Lines changed: 53 additions & 11 deletions

File tree

.github/workflows/build.yml

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,32 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- name: Install dependencies
16+
- name: Install build tools
1717
run: |
1818
sudo apt-get update -qq
19-
sudo apt-get install -y cmake pkg-config \
20-
libavif-dev libwebp-dev libjpeg-dev libpng-dev
19+
sudo apt-get install -y cmake ninja-build pkg-config curl zip unzip tar
20+
- name: Cache vcpkg
21+
uses: actions/cache@v4
22+
with:
23+
path: ${{ github.workspace }}/vcpkg_installed
24+
key: vcpkg-x64-linux-static-${{ hashFiles('vcpkg.json') }}-v1
25+
- name: Install vcpkg dependencies
26+
run: |
27+
vcpkg install --triplet x64-linux-static \
28+
--overlay-triplets=cmake/triplets \
29+
--x-install-root=${{ github.workspace }}/vcpkg_installed
2130
- uses: oven-sh/setup-bun@v2
2231
with:
2332
bun-version: latest
2433
- name: Build
25-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build --parallel
34+
run: |
35+
cmake -S . -B build -G Ninja \
36+
-DCMAKE_BUILD_TYPE=Release \
37+
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" \
38+
-DVCPKG_TARGET_TRIPLET=x64-linux-static \
39+
-DVCPKG_OVERLAY_TRIPLETS=cmake/triplets \
40+
-DVCPKG_INSTALLED_DIR=${{ github.workspace }}/vcpkg_installed
41+
cmake --build build --parallel
2642
- name: Test — Lanczos-3 precision
2743
run: bun run test/lanczos_precision.ts
2844
- name: Test — ops precision
@@ -37,16 +53,32 @@ jobs:
3753
runs-on: ubuntu-24.04-arm
3854
steps:
3955
- uses: actions/checkout@v4
40-
- name: Install dependencies
56+
- name: Install build tools
4157
run: |
4258
sudo apt-get update -qq
43-
sudo apt-get install -y cmake pkg-config \
44-
libavif-dev libwebp-dev libjpeg-dev libpng-dev
59+
sudo apt-get install -y cmake ninja-build pkg-config curl zip unzip tar
60+
- name: Cache vcpkg
61+
uses: actions/cache@v4
62+
with:
63+
path: ${{ github.workspace }}/vcpkg_installed
64+
key: vcpkg-arm64-linux-static-${{ hashFiles('vcpkg.json') }}-v1
65+
- name: Install vcpkg dependencies
66+
run: |
67+
vcpkg install --triplet arm64-linux-static \
68+
--overlay-triplets=cmake/triplets \
69+
--x-install-root=${{ github.workspace }}/vcpkg_installed
4570
- uses: oven-sh/setup-bun@v2
4671
with:
4772
bun-version: latest
4873
- name: Build
49-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build --parallel
74+
run: |
75+
cmake -S . -B build -G Ninja \
76+
-DCMAKE_BUILD_TYPE=Release \
77+
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" \
78+
-DVCPKG_TARGET_TRIPLET=arm64-linux-static \
79+
-DVCPKG_OVERLAY_TRIPLETS=cmake/triplets \
80+
-DVCPKG_INSTALLED_DIR=${{ github.workspace }}/vcpkg_installed
81+
cmake --build build --parallel
5082
- name: Test — Lanczos-3 precision
5183
run: bun run test/lanczos_precision.ts
5284
- name: Test — ops precision

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ set_target_properties(pict PROPERTIES
6060
target_include_directories(pict PRIVATE ${CMAKE_SOURCE_DIR}/include)
6161

6262
# ── Platform-specific dependencies ────────────────────────────────────────
63-
if(WIN32)
64-
# vcpkg provides these via CMAKE_TOOLCHAIN_FILE
63+
# vcpkg path: Windows always, Linux/macOS when VCPKG_TARGET_TRIPLET is set
64+
if(WIN32 OR DEFINED VCPKG_TARGET_TRIPLET)
6565
find_package(libavif CONFIG REQUIRED)
6666
find_package(WebP CONFIG REQUIRED)
6767
find_package(JPEG REQUIRED)
6868
find_package(PNG REQUIRED)
6969

70-
target_compile_definitions(pict PRIVATE PICT_DISABLE_HEIC)
70+
if(WIN32)
71+
target_compile_definitions(pict PRIVATE PICT_DISABLE_HEIC)
72+
endif()
7173
target_link_libraries(pict PRIVATE
7274
avif
7375
WebP::webp WebP::webpdemux WebP::libwebpmux
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set(VCPKG_TARGET_ARCHITECTURE arm64)
2+
set(VCPKG_CRT_LINKAGE dynamic)
3+
set(VCPKG_LIBRARY_LINKAGE static)
4+
set(VCPKG_CMAKE_SYSTEM_NAME Linux)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set(VCPKG_TARGET_ARCHITECTURE x64)
2+
set(VCPKG_CRT_LINKAGE dynamic)
3+
set(VCPKG_LIBRARY_LINKAGE static)
4+
set(VCPKG_CMAKE_SYSTEM_NAME Linux)

0 commit comments

Comments
 (0)