[libpng] Fix cross-compilation on macOS#15002
Conversation
|
I think we need @strega-nil to review this PR. Because she is more familiar with MacOS. |
ports/libpng/portfile.cmake
Outdated
| if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL Darwin) | ||
| set(MACOS_EXTRA_PATCH macos-arch-fix.patch) | ||
| endif() |
There was a problem hiding this comment.
This doesn't need to be an optional patch, you can just do use it regardless.
There was a problem hiding this comment.
Would that not affect building on other platforms? The changes I made would only check an OSX-specific variable.
There was a problem hiding this comment.
ah, I see what you're saying.
strega-nil
left a comment
There was a problem hiding this comment.
Noting that, unfortunately, this means that this doesn't support universal binaries. We need to figure out how we want to solve that problem.
Yes, creating a universal triplet was my first thought, but I kept facing issues with libraries that compiled different files for different architectures. For my app, I basically need to perform two builds then |
|
@strega-nil Anything else? |
7c7939e to
6d5eb68
Compare
|
@JackBoosY I've approved it. |
|
Thanks! |
libpng does not build correctly for arm64 on macOS, as the CMakeLists.txt supplied with libpng checks CMAKE_SYSTEM_PROCESSOR. vcpkg currently uses an x86_64 version of cmake, and cmake always sets CMAKE_SYSTEM_PROCESSOR to x86_64 in this situation, when run under Rosetta. Updated versions of cmake (see #15001) do report arm64 correctly, but in this case if we're cross-compiling we are not wanting to know the system processor, but the target architecture.
Ideally a fix may be submitted upstream, but for the time being I propose this patch, which should only be applied for macOS triplets, and will detect the target architecture and will then compile libpng with appropriate hardware-specific optimisations.