macos.cmake 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #[=======================================================================[.rst:
  2. MacOS
  3. -----
  4. This file contains functions for options and configuration for targeting the
  5. MacOS platform
  6. # To build universal binaries, ie targeting both x86_64 and arm64, use
  7. # the CMAKE_OSX_ARCHITECTURES variable prior to any project calls.
  8. # https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_ARCHITECTURES.html
  9. ]=======================================================================]
  10. # Find Requirements
  11. IF(APPLE)
  12. set( CMAKE_OSX_SYSROOT $ENV{SDKROOT} )
  13. find_library( COCOA_LIBRARY REQUIRED
  14. NAMES Cocoa
  15. PATHS ${CMAKE_OSX_SYSROOT}/System/Library
  16. PATH_SUFFIXES Frameworks
  17. NO_DEFAULT_PATH)
  18. ENDIF (APPLE)
  19. function( macos_options )
  20. endfunction()
  21. function( macos_generate )
  22. target_compile_definitions(${TARGET_NAME}
  23. PUBLIC
  24. MACOS_ENABLED
  25. UNIX_ENABLED
  26. )
  27. target_link_options( ${TARGET_NAME}
  28. PUBLIC
  29. -Wl,-undefined,dynamic_lookup
  30. )
  31. target_link_libraries( ${TARGET_NAME}
  32. INTERFACE
  33. ${COCOA_LIBRARY}
  34. )
  35. common_compiler_flags()
  36. endfunction()