21

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.

eyelash
  • 2,640
  • 23
  • 31
Quincy
  • 1,835
  • 5
  • 26
  • 37

2 Answers2

29

Can you just use find_library like this: find_library(COCOA_LIBRARY Cocoa)?

Then use ${COCOA_LIBRARY} in your target_link_libraries. Possibly setting the CMAKE_FIND_FRAMEWORK variable to ONLY.

Also, refer to this article: How to use existing OSX frameworks.

shybovycha
  • 10,674
  • 6
  • 49
  • 81
choobablue
  • 674
  • 6
  • 5
  • How does this guarantee that the Cocoa framework version of the library is included as opposed to a regular unix style library? – Iron Attorney Jun 18 '20 at 19:06
10

another solution: https://stackoverflow.com/a/18330634/2482283

target_link_libraries(program "-framework Cocoa")
lbsweek
  • 4,586
  • 41
  • 40