FindFreetype: Does not support macOS Frameworks
https://github.com/ChrisThrasher/cmake_framework_test
Above is a sample project that tries to find Freetype.framework on macOS but fails at link time. The CI pipeline shows the steps required to reproduce this failure. Here is the pipeline run to see the error for yourself.
https://github.com/ChrisThrasher/cmake_framework_test/actions/runs/5968375737/job/16192070077
ld: can't map file, errno=22 file '/Users/runner/work/cmake_framework_test/cmake_framework_test/freetype.framework' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
After discussing this with @ben.boeckel we cannot find any bugs in the sample project. I suspect the issue is in FindFreetype.cmake but I'm not certain about that.
This may be related to #19073
This comment from Brad King seems relevant as well. He talks about how target_link_libraries
knows to prepend -framework
when linking to frameworks but when dealing with IMPORTED
targets, you need to write some special case code to detect the presence of frameworks as is the case with FindGlut.cmake. FindFreetype.cmake does not have such special case code for frameworks.