Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] Some ports reference hardcoded library paths #16259

Open
davidebeatrici opened this issue Feb 17, 2021 · 6 comments
Open

[macOS] Some ports reference hardcoded library paths #16259

davidebeatrici opened this issue Feb 17, 2021 · 6 comments
Assignees
Labels
category:tool-update The issue is with build tool or build script, which requires update or should be executed correctly

Comments

@davidebeatrici
Copy link
Contributor

davidebeatrici commented Feb 17, 2021

After relocating a vcpkg build environment to another machine, I encountered the following error when building my application:

ninja: error: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreFoundation.framework', needed by 'murmurd', missing and no known rule to make it

Searching for /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk in the environment's directory yields the following results:

In installed/x64-osx/share/absl/abslTargets.cmake:

set_target_properties(absl::time_zone PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "\$<\$<PLATFORM_ID:Darwin>:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreFoundation.framework>"
)

In installed/x64-osx/share/unofficial-angle/unofficial-angle-config.cmake:

set_target_properties(unofficial::angle::angle_gpu_info_util PROPERTIES
  INTERFACE_LINK_LIBRARIES "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/IOKit.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreFoundation.framework;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreGraphics.framework;\$<LINK_ONLY:unofficial::angle::angle_common>"
)

The correct content is as follows:

set_target_properties(absl::time_zone PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "\$<\$<PLATFORM_ID:Darwin>:-framework CoreFoundation>"
)
set_target_properties(unofficial::angle::angle_gpu_info_util PROPERTIES
  INTERFACE_LINK_LIBRARIES "-framework IOKit;-framework CoreFoundation;-framework CoreGraphics;\$<LINK_ONLY:unofficial::angle::angle_common>"
)
@JackBoosY
Copy link
Contributor

@strega-nil What do you think about? I think we should correct vcpkg_fixup_cmake_targets.

@strega-nil
Copy link
Contributor

@JackBoosY is this something that angle/abseil screws up, or is it something that cmake screws up? In the former case, then we should do the fix in the ports; if it's something that cmake screws up, then we should fix it with vcpkg_fixup_cmake_targets. At least, that's my opinion.

@JackBoosY JackBoosY added category:port-bug The issue is with a library, which is something the port should already support and removed requires:discussion labels Feb 19, 2021
@JackBoosY JackBoosY added category:tool-update The issue is with build tool or build script, which requires update or should be executed correctly and removed category:port-bug The issue is with a library, which is something the port should already support labels Mar 4, 2021
@JackBoosY
Copy link
Contributor

I think that's a common issue. Will be fixed in vcpkg-cmake-config and vcpkg_fixup_cmake_targets.

@daschuer
Copy link
Contributor

This seems to be a common upstream issue.
I have tried to fix it in case of abseil with:

-    $<$<PLATFORM_ID:Darwin>:${CoreFoundation}>
+    $<$<PLATFORM_ID:Darwin>:"-framework CoreFoundation">

https://github.com/daschuer/vcpkg/blob/750ff67b6d676123c75065105b10bb7e3fac661c/ports/abseil/core-foundation-deps.patch

Unfortunately I get now a link error because of

-l"-framework CoreFoundation"

@daschuer
Copy link
Contributor

This is a duplicate: aws/aws-sdk-cpp#1245
It becomes a real error if you update Xcode and the original absolute path doe no longer exist.

@dg0yt
Copy link
Contributor

dg0yt commented Jul 25, 2023

AFAICT there are three common mistakes in CMake projects:

  • looking up standard frameworks with find_library and actually using the result.
  • blindly prefixing link libraries with -l when exporting config such as pc files.
  • building super-smart custom CMake functions.

Maybe you can pass -framework CoreFoundation via LINKOPTS instead of DEPS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:tool-update The issue is with build tool or build script, which requires update or should be executed correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants