CMake macOS Framework link

macOS Frameworks are linked with the -framework flag. CMake has special handling for these flags, so target_link_libraries should be used for them. The quoting in the example below is necessary to get CMake handling the flags correctly.

add_executable(main main.c)

if(APPLE)
  target_link_libraries(main PRIVATE
  "-framework Foundation"
  "-framework IOKit"
  )
endif()

Alternatively, use find_library() with the framework name.