defaults.cmake 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # OBS CMake macOS defaults module
  2. # Enable selection between arm64 and x86_64 targets
  3. if(NOT CMAKE_OSX_ARCHITECTURES)
  4. set(CMAKE_OSX_ARCHITECTURES
  5. arm64
  6. CACHE STRING "Build architectures for macOS" FORCE)
  7. endif()
  8. set_property(CACHE CMAKE_OSX_ARCHITECTURES PROPERTY STRINGS arm64 x86_64)
  9. # Set empty codesigning team if not specified as cache variable
  10. if(NOT OBS_CODESIGN_TEAM)
  11. set(OBS_CODESIGN_TEAM
  12. ""
  13. CACHE STRING "OBS code signing team for macOS" FORCE)
  14. # Set ad-hoc codesigning identity if not specified as cache variable
  15. if(NOT OBS_CODESIGN_IDENTITY)
  16. set(OBS_CODESIGN_IDENTITY
  17. "-"
  18. CACHE STRING "OBS code signing identity for macOS" FORCE)
  19. endif()
  20. endif()
  21. if(XCODE)
  22. include(xcode)
  23. endif()
  24. include(buildspec)
  25. # Set default deployment target to 11.0 if not set and enable selection in GUI up to 13.0
  26. if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
  27. set(CMAKE_OSX_DEPLOYMENT_TARGET
  28. 11.0
  29. CACHE STRING "Minimum macOS version to target for deployment (at runtime). Newer APIs will be weak-linked." FORCE)
  30. endif()
  31. set_property(CACHE CMAKE_OSX_DEPLOYMENT_TARGET PROPERTY STRINGS 13.0 12.0 11.0)
  32. # Use Applications directory as default install destination
  33. if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  34. set(CMAKE_INSTALL_PREFIX
  35. "/Applications"
  36. CACHE STRING "Directory to install OBS after building" FORCE)
  37. endif()
  38. # Show warning about missing CMAKE_PREFIX_PATH, usually required for successful builds
  39. if(NOT DEFINED CMAKE_PREFIX_PATH)
  40. message(
  41. WARNING "No CMAKE_PREFIX_PATH set: OBS supplies pre-built dependencies for building on macOS.\n"
  42. "While OBS can be built using packages installed via Homebrew, pre-built dependencies "
  43. "contain beneficial patches and fixes for use within OBS and is the suggested source "
  44. "of these dependencies.\n"
  45. "You can download the appropriate obs-deps package for your "
  46. "architecture and set CMAKE_PREFIX_PATH to this directory:\n"
  47. "CMAKE_PREFIX_PATH=\"<PATH_TO_OBS_DEPS>\"\n"
  48. "Download pre-built OBS dependencies at https://github.com/obsproject/obs-deps/releases\n")
  49. endif()
  50. # SWIG hard codes the directory to its library directory at compile time. As obs-deps need to be relocatable, we need to
  51. # force SWIG to look for its files in a directory relative to the PREFIX_PATH. The best way to ensure this is to set the
  52. # SWIG_LIB environment variable.
  53. foreach(path IN LISTS CMAKE_PREFIX_PATH)
  54. if(NOT DEFINED ENV{SWIG_LIB} AND EXISTS "${path}/bin/swig")
  55. set(ENV{SWIG_LIB} "${path}/share/swig/CURRENT")
  56. break()
  57. endif()
  58. endforeach()
  59. # Set default values for CMake's bundle generator and created Info.plist files
  60. set(MACOSX_BUNDLE_EXECUTABLE_NAME OBS)
  61. set(MACOSX_BUNDLE_BUNDLE_NAME "${OBS_PRODUCT_NAME}")
  62. set(MACOSX_BUNDLE_BUNDLE_VERSION ${OBS_BUILD_NUMBER})
  63. set(MACOSX_BUNDLE_COPYRIGHT "${OBS_LEGAL_COPYRIGHT}")
  64. set(MACOSX_BUNDLE_GUI_IDENTIFIER com.obsproject.obs-studio)
  65. set(MACOSX_BUNDLE_ICON_FILE AppIcon)
  66. set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${OBS_VERSION_CANONICAL})
  67. string(TIMESTAMP CURRENT_YEAR "%Y")
  68. # Enable find_package targets to become globally available targets
  69. set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)
  70. # Enable RPATH support for generated binaries
  71. set(CMAKE_MACOSX_RPATH TRUE)
  72. # Use RPATHs from build tree _in_ the build tree
  73. set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  74. # Do not add default linker search paths to RPATH
  75. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
  76. # Use common bundle-relative RPATH for installed targets
  77. set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks")
  78. # Used for library exports only (obs-frontend-api)
  79. set(OBS_LIBRARY_DESTINATION "lib")
  80. set(OBS_INCLUDE_DESTINATION "include/obs")
  81. set(OBS_CMAKE_DESTINATION "lib/cmake")
  82. set(_dmg_package_name "OBS")
  83. set(_dmg_background_filename "background.tiff")
  84. set(_dmg_window_x 100)
  85. set(_dmg_window_y 100)
  86. set(_dmg_window_width 540)
  87. set(_dmg_window_height 380)
  88. set(_dmg_icon_size 96)
  89. set(_dmg_text_size 16)
  90. set(_dmg_obs_x 124)
  91. set(_dmg_obs_y 180)
  92. set(_dmg_app_link_x 416)
  93. set(_dmg_app_link_y 180)
  94. configure_file("${CMAKE_SOURCE_DIR}/cmake/macos/resources/package.applescript.in"
  95. "${CMAKE_BINARY_DIR}/package.applescript" @ONLY)