macos 如何向 CMake 添加框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2908640/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add a framework to CMake
提问by Quincy
I have written a small helloworld program that needs the Cocoa framework. I'd like to know how to add a framework in CMake. All the information I have found is out-of-date. I have CMake 2.8.1 on Snow Leopard.
我编写了一个需要 Cocoa 框架的小型 helloworld 程序。我想知道如何在 CMake 中添加框架。我找到的所有信息都是过时的。我在雪豹上有 CMake 2.8.1。
回答by choobablue
Can you just use find_library
like this: find_library(COCOA_LIBRARY Cocoa)
?
你可以这样使用find_library
:find_library(COCOA_LIBRARY Cocoa)
?
Then use ${COCOA_LIBRARY}
in your target_link_libraries
. Possibly setting the CMAKE_FIND_FRAMEWORK
variable to ONLY
.
然后${COCOA_LIBRARY}
在您的target_link_libraries
. 可能将CMAKE_FIND_FRAMEWORK
变量设置为ONLY
.
Also, refer to this article: How to use existing OSX frameworks.
另外,请参阅这篇文章:如何使用现有的 OSX 框架。
回答by lbsweek
another solution: https://stackoverflow.com/a/18330634/2482283
另一种解决方案:https: //stackoverflow.com/a/18330634/2482283
target_link_libraries(program "-framework Cocoa")