You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wanting to build a binary for both x64 and Apple Silicon at the same time that is merged together for me rather than me having to run vcpkg 2x and do the extra binary merge work myself. This should be possible with CMake, however, vcpkg does not allow for this right now due to some problems.
Note the different VCPKG_TARGET_ARCHITECTURE. Running a command such as ./vcpkg install libzip --triplet x64_arm64-osx --clean-after-build --debug results in this error:
CMake Error: The source directory "/Users/myname/Desktop/vcpkg-testing/vcpkg/buildtrees/detect_compiler/x64_arm64-osx-rel/arm64" does not exist.
The actual error is (edited to add newlines for easier reading here on GitHub)
Note this part: -DVCPKG_TARGET_ARCHITECTURE=x86_64 arm64 -- this is likely why we are getting an error about an arm64 dir. This param is not being escaped properly.
Historical Context
I have this feature working in a fork. #12657 was a PR to fix these issues that was split into 4 subsequent PRs that also has more historical information. Three of those subsequent PRs were merged, and one was not (#12718 was not merged) due to me never finishing it because [reasons].
My working fork with this feature is available here: https://github.com/Deadpikle/vcpkg/tree/fix/osx-archs-attempt. Note that this requires Xcode 12.2+ to build for Apple Silicon and x64. However, my fork is quite old, and when trying to apply the same fixes to the latest master, things still don't work out, and I'm not sure why.
Proposed solution
I am guessing that fixing this problem is probably two-fold:
Need to fix escaping issues so that -DVCPKG_TARGET_ARCHITECTURE is output properly
In theory, you could probably use the x64-osx.cmake triplet and the arm64-osx.cmake triplet to build the raw libraries, then use some combination of lipo or something else to merge the libraries. This would look something like what this blog post describes or this SO post describes. However, having this capability built in to vcpkg is much easier and more convenient for end users. Plus, the escaping issue is an issue.
In addition, I could just do set(VCPKG_OSX_ARCHITECTURES x86_64 arm64) in the triplet and not worry about number 2 in the above solution, but it results in another something that looks like an escaping issue. set(VCPKG_TARGET_ARCHITECTURE x86_64;arm64) or set(VCPKG_OSX_ARCHITECTURES x86_64;arm64) does not rectify the issue -- it just results in more escaping problems down the road.
Summary
I'm wanting to build a binary for both x64 and Apple Silicon at the same time that is merged together for me rather than me having to run vcpkg 2x and do the extra binary merge work myself. This should be possible with CMake, however, vcpkg does not allow for this right now due to some problems.
Environment
master(commitecba240490afcc65e6ec07e49bf7f763a1a2b28b)Description
I have the following triplet in a custom triplet file:
Note the different
VCPKG_TARGET_ARCHITECTURE. Running a command such as./vcpkg install libzip --triplet x64_arm64-osx --clean-after-build --debugresults in this error:CMake Error: The source directory "/Users/myname/Desktop/vcpkg-testing/vcpkg/buildtrees/detect_compiler/x64_arm64-osx-rel/arm64" does not exist.The actual error is (edited to add newlines for easier reading here on GitHub)
Note this part:
-DVCPKG_TARGET_ARCHITECTURE=x86_64 arm64-- this is likely why we are getting an error about an arm64 dir. This param is not being escaped properly.Historical Context
I have this feature working in a fork. #12657 was a PR to fix these issues that was split into 4 subsequent PRs that also has more historical information. Three of those subsequent PRs were merged, and one was not (#12718 was not merged) due to me never finishing it because [reasons].
My working fork with this feature is available here: https://github.com/Deadpikle/vcpkg/tree/fix/osx-archs-attempt. Note that this requires Xcode 12.2+ to build for Apple Silicon and x64. However, my fork is quite old, and when trying to apply the same fixes to the latest
master, things still don't work out, and I'm not sure why.Proposed solution
I am guessing that fixing this problem is probably two-fold:
-DVCPKG_TARGET_ARCHITECTUREis output properly-DCMAKE_OSX_ARCHITECTURESto the contents of-DVCPKG_TARGET_ARCHITECTURE-- but this is just a guess on my part. (See note below on alternatives how this could just be done in the triplet)Describe alternatives you've considered
In theory, you could probably use the
x64-osx.cmaketriplet and thearm64-osx.cmaketriplet to build the raw libraries, then use some combination oflipoor something else to merge the libraries. This would look something like what this blog post describes or this SO post describes. However, having this capability built in to vcpkg is much easier and more convenient for end users. Plus, the escaping issue is an issue.In addition, I could just do
set(VCPKG_OSX_ARCHITECTURES x86_64 arm64)in the triplet and not worry about number 2 in the above solution, but it results in another something that looks like an escaping issue.set(VCPKG_TARGET_ARCHITECTURE x86_64;arm64)orset(VCPKG_OSX_ARCHITECTURES x86_64;arm64)does not rectify the issue -- it just results in more escaping problems down the road.Thank you! 😄