diff --git a/preview/CMakeLists.txt b/preview/CMakeLists.txt index 20d8f11c..8fac07fa 100644 --- a/preview/CMakeLists.txt +++ b/preview/CMakeLists.txt @@ -34,7 +34,17 @@ ExternalProject_Add(libjpeg-turbo-project -DREQUIRE_SIMD:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH= - -DCMAKE_INSTALL_LIBDIR:PATH=/lib) + -DCMAKE_INSTALL_LIBDIR:PATH=/lib + # An ExternalProject is a separate cmake invocation and inherits nothing, so without these + # it configures for the BUILD host: a cross build would link an x86_64 libjpeg.a into an + # aarch64 binary and only fail at the final link. Forward the toolchain file (empty when not + # cross-compiling, which cmake ignores) and the compilers, so it follows the parent build. + # libjpeg-turbo picks its own SIMD from the target arch, so NEON comes for free on aarch64 + # and nasm is simply not consulted there. + -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_SYSTEM_NAME:STRING=${CMAKE_SYSTEM_NAME} + -DCMAKE_SYSTEM_PROCESSOR:STRING=${CMAKE_SYSTEM_PROCESSOR}) # Create the include dir up front so setting INTERFACE_INCLUDE_DIRECTORIES below does not fail. FILE(MAKE_DIRECTORY ${LIBJPEG_TURBO_INCLUDE_DIRS})