macos.cmake 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #[=======================================================================[.rst:
  2. MacOS
  3. -----
  4. This file contains functions for options and configuration for targeting the
  5. MacOS platform
  6. Universal Builds
  7. ----------------
  8. To build universal binaries, ie targeting both x86_64 and arm64, use
  9. the CMAKE_OSX_ARCHITECTURES variable prior to any project calls.
  10. https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_ARCHITECTURES.html
  11. ]=======================================================================]
  12. # Find Requirements
  13. if(APPLE)
  14. set(CMAKE_OSX_SYSROOT $ENV{SDKROOT})
  15. find_library(
  16. COCOA_LIBRARY
  17. REQUIRED
  18. NAMES Cocoa
  19. PATHS ${CMAKE_OSX_SYSROOT}/System/Library
  20. PATH_SUFFIXES Frameworks
  21. NO_DEFAULT_PATH
  22. )
  23. endif(APPLE)
  24. #[=============================[ MacOS Options ]=============================]
  25. function(macos_options)
  26. #[[ Options from SCons
  27. TODO macos_deployment_target: macOS deployment target
  28. Default: 'default'
  29. TODO macos_sdk_path: macOS SDK path
  30. Default: ''
  31. TODO osxcross_sdk: OSXCross SDK version
  32. Default: if has_osxcross(): "darwin16" else None
  33. ]]
  34. endfunction()
  35. #[===========================[ Target Generation ]===========================]
  36. function(macos_generate)
  37. target_compile_definitions(godot-cpp PUBLIC MACOS_ENABLED UNIX_ENABLED)
  38. target_link_options(godot-cpp PUBLIC -Wl,-undefined,dynamic_lookup)
  39. target_link_libraries(godot-cpp INTERFACE ${COCOA_LIBRARY})
  40. common_compiler_flags()
  41. endfunction()