macos.cmake 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #[=======================================================================[.rst:
  2. MacOS
  3. -----
  4. This file contains functions for options and configuration for targeting the
  5. MacOS platform
  6. ]=======================================================================]
  7. # Find Requirements
  8. IF(APPLE)
  9. set( CMAKE_OSX_SYSROOT $ENV{SDKROOT} )
  10. find_library( COCOA_LIBRARY REQUIRED
  11. NAMES Cocoa
  12. PATHS ${CMAKE_OSX_SYSROOT}/System/Library
  13. PATH_SUFFIXES Frameworks
  14. NO_DEFAULT_PATH)
  15. ENDIF (APPLE)
  16. function( macos_options )
  17. # macos options here
  18. endfunction()
  19. function( macos_generate )
  20. # OSX_ARCHITECTURES does not support generator expressions.
  21. if( NOT GODOT_ARCH OR GODOT_ARCH STREQUAL universal )
  22. set( OSX_ARCH "x86_64;arm64" )
  23. set( SYSTEM_ARCH universal )
  24. else()
  25. set( OSX_ARCH ${GODOT_ARCH} )
  26. endif()
  27. set_target_properties( ${TARGET_NAME}
  28. PROPERTIES
  29. OSX_ARCHITECTURES "${OSX_ARCH}"
  30. )
  31. target_compile_definitions(${TARGET_NAME}
  32. PUBLIC
  33. MACOS_ENABLED
  34. UNIX_ENABLED
  35. )
  36. target_link_options( ${TARGET_NAME}
  37. PUBLIC
  38. -Wl,-undefined,dynamic_lookup
  39. )
  40. target_link_libraries( ${TARGET_NAME}
  41. INTERFACE
  42. ${COCOA_LIBRARY}
  43. )
  44. common_compiler_flags()
  45. endfunction()