autc04 / Retro68

a gcc-based cross-compiler for classic 68K and PPC Macintoshes
GNU General Public License v3.0
555 stars 54 forks source link

Can't link to libraries generated as a result of ExternalProject_Add #261

Closed IoIxD closed 4 months ago

IoIxD commented 4 months ago

I decided for goofs to try and get ffmpeg working (and astonishingly, got quite far; after disabling assembly (because of an issue that will become apparent)).

FFmpeg uses autotools, so I need to use ExternalProject_Add.

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/FFmpeg)

include(ExternalProject)
ExternalProject_Add(
    libff
    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/FFmpeg
    CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/FFmpeg/configure --prefix=${CMAKE_CURRENT_SOURCE_DIR}/lib --arch=ppc32 --enable-cross-compile --disable-asm --disable-inline-asm --disable-pthreads
    PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/FFmpeg
    BUILD_COMMAND make
    BUILD_IN_SOURCE 1

    BUILD_BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/FFmpeg/libavcodec/libavcodec.a

    CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
)

add_dependencies(os9player libff)
target_link_directories(os9player PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/lib/lib/)
target_link_libraries(os9player avcodec)
CC=powerpc-apple-macos-gcc cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_QJS_LIBC=OFF -DPLATFORM=retroppc -DRETRO68_ROOT=$RETRO68_TOOLCHAIN_PATH -DCMAKE_TOOLCHAIN_FILE=$RETRO68_INSTALL_PATH/cmake/retroppc.toolchain.cmake.in

It compiles, but I can't actually link to the result, implying that it's not actually using the compiler.

/home/gavin/Projects/os9ffmpegplayer/lib/lib/libavcodec.a: file not recognized: file format not recognized.

I also tried appending CC=powerpc-apple-macos-gcc LD=powerpc-apple-macos-ld CXX=powerpc-apple-macos-g++ to CONFIGURE_COMMAND and MAKE_COMMAND, to no avail

Anything I can do to fix this? I tried compiling by just adding all the source files manually, but the problem there is that it ignores config.h and seems to get confused thereon with imports.

IoIxD commented 4 months ago

Had to add --cross-prefix=powerpc-apple-macos- to get it to actually use the correct compiler.