Skip to content

Commit

Permalink
fix linux cross compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Oct 26, 2024
1 parent af36a23 commit 5c100e5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
24 changes: 21 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,35 @@ jobs:
- name: Linux-x86_64 # ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}
os: ubuntu-22.04
arch: x86_64
generator: "Unix Makefiles"
shell: bash
- name: Linux-aarch64
os: ubuntu-22.04
arch: aarch64
generator: "Unix Makefiles"
shell: bash
target: aarch64-linux-gnu
- name: Linux-ppc64le
os: ubuntu-22.04
arch: powerpc64le
generator: "Unix Makefiles"
shell: bash
target: powerpc64le-linux-gnu
- name: Darwin-x86_64
os: macos-13
arch: x86_64
generator: "Unix Makefiles"
shell: bash
- name: Darwin-arm64
os: macos-14
arch: aarch64
generator: "Unix Makefiles"
shell: bash
target: arm64-apple-macosx
- name: Windows-AMD64
os: windows-2022
arch: x86_64
generator: "MSYS Makefiles"
shell: msys2 {0}
runs-on: ${{ matrix.os }}
defaults:
Expand Down Expand Up @@ -225,6 +231,11 @@ jobs:
mingw-w64-ucrt-x86_64-nasm
mingw-w64-ucrt-x86_64-ninja
- name: Debug msys2.CMD
if: ${{ runner.os == 'Windows' }}
run: |
cat /d/a/_temp/setup-msys2/msys2.CMD
- name: Initialize Submodules
# libx265 has issues when using the recursive method of the first checkout action
# this is after `msys2/setup-msys2@v2` because `msys2` (default) shell is not available until then.
Expand Down Expand Up @@ -259,17 +270,24 @@ jobs:
cmake \
-B build \
-S . \
-G "Ninja" \
-G "${{ matrix.generator }}" \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
-DCMAKE_INSTALL_PREFIX="${ROOT_PATH}/build/dist"
- name: Build
run: |
ninja -C build
make -C build
- name: Install
run: |
ninja -C build install
make -C build install
- name: Debug logs
if: always()
run: |
echo "::group::x264 config.log"
cat ./third-party/FFmpeg/x264/config.log || true
echo "::endgroup::"
- name: Debug build
if: always()
Expand Down
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ option(BUILD_FFMPEG_X264_PATCHES "Apply FFmpeg x264 patches" ON)
option(BUILD_FFMPEG_X265 "Build FFmpeg x265" ON)
option(BUILD_FFMPEG_X265_PATCHES "Apply FFmpeg x265 patches" ON)

# common includes
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/apply_git_patch.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/unix_path.cmake)

if(UNIX AND NOT APPLE)
include(GNUInstallDirs)
endif()
Expand Down Expand Up @@ -57,6 +61,11 @@ find_program(MAKE_EXECUTABLE
REQUIRED)
message(STATUS "Found make: ${MAKE_EXECUTABLE}")

if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles")
# Ninja can handle the conversion automatically, but MSYS Makefiles cannot
UNIX_PATH(MAKE_EXECUTABLE ${MAKE_EXECUTABLE})
endif()

# Custom target to use to ensure all dependencies are built
add_custom_target(${CMAKE_PROJECT_NAME}
COMMENT "Completed build-deps"
Expand All @@ -68,10 +77,6 @@ string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} arch)
# set generated source path
set(CMAKE_GENERATED_SRC_PATH ${CMAKE_CURRENT_BINARY_DIR}/generated-src)

# common includes
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/apply_git_patch.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/unix_path.cmake)

if(BUILD_ALL OR BUILD_ALL_SUNSHINE OR BUILD_FFMPEG)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ffmpeg/_main.cmake)
endif()
5 changes: 5 additions & 0 deletions cmake/ffmpeg/ffmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ if(CMAKE_CROSSCOMPILING)
--arch=${arch}
--enable-cross-compile
)
if(UNIX AND NOT APPLE)
set(FFMPEG_EXTRA_CONFIGURE
--cross-prefix=/usr/bin/${CMAKE_C_COMPILER_TARGET}-
)
endif()
endif()

set(WORKING_DIR ${FFMPEG_GENERATED_SRC_PATH})
Expand Down
3 changes: 1 addition & 2 deletions cmake/toolchains/aarch64-linux-gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(CMAKE_C_COMPILER_TARGET aarch64-linux-gnu)
set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_C_COMPILER_TARGET})
set(CCPREFIX ${CMAKE_C_COMPILER_TARGET}-)
set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc)
set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER_TARGET}-g++)

SET(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_C_COMPILER_TARGET})
set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_C_COMPILER_TARGET})
3 changes: 1 addition & 2 deletions cmake/toolchains/powerpc64le-linux-gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ set(CMAKE_SYSTEM_PROCESSOR ppc64le)

set(CMAKE_C_COMPILER_TARGET powerpc64le-linux-gnu)
set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_C_COMPILER_TARGET})
set(CCPREFIX ${CMAKE_C_COMPILER_TARGET}-)
set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_TARGET}-gcc)
set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER_TARGET}-g++)

SET(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_C_COMPILER_TARGET})
set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_C_COMPILER_TARGET})

0 comments on commit 5c100e5

Please sign in to comment.