CMakeLists.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. cmake_minimum_required(VERSION 3.22...3.25)
  2. if(CMAKE_HOST_SYSTEM_NAME MATCHES "(Windows|Darwin)" OR OBS_CMAKE_VERSION VERSION_GREATER_EQUAL 3.0.0)
  3. include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/common/bootstrap.cmake" NO_POLICY_SCOPE)
  4. project(obs-studio VERSION ${OBS_VERSION_CANONICAL})
  5. if(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
  6. include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/windows/architecture.cmake")
  7. if(NOT OBS_PARENT_ARCHITECTURE STREQUAL CMAKE_GENERATOR_PLATFORM)
  8. return()
  9. endif()
  10. endif()
  11. include(compilerconfig)
  12. include(defaults)
  13. include(helpers)
  14. option(ENABLE_UI "Enable building with UI (requires Qt)" ON)
  15. option(ENABLE_SCRIPTING "Enable scripting support" ON)
  16. option(ENABLE_HEVC "Enable HEVC encoders" ON)
  17. add_subdirectory(libobs)
  18. if(OS_WINDOWS)
  19. add_subdirectory(libobs-d3d11)
  20. add_subdirectory(libobs-winrt)
  21. endif()
  22. add_subdirectory(libobs-opengl)
  23. add_subdirectory(plugins)
  24. add_subdirectory(test/test-input)
  25. add_subdirectory(UI)
  26. message_configuration()
  27. return()
  28. endif()
  29. message(
  30. DEPRECATION
  31. "\n"
  32. "============ LEGACY BUILD SYSTEM IS DEPRECATED ============"
  33. "\n"
  34. "You are using the legacy build system to build OBS Studio. "
  35. "The legacy build system is unsupported and will be removed in the near future."
  36. "\n"
  37. "To migrate to the new build system, familiarize yourself with CMake presets "
  38. "(https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) and create "
  39. "a user preset with your customized build settings, inheriting from one of the default presets."
  40. "\n"
  41. "============ LEGACY BUILD SYSTEM IS DEPRECATED ============"
  42. )
  43. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules")
  44. include(VersionConfig)
  45. # Prohibit in-source builds
  46. if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
  47. message(
  48. FATAL_ERROR
  49. "OBS: You cannot build in a source directory (or any directory with CMakeLists.txt file). "
  50. "Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles."
  51. )
  52. endif()
  53. project(obs-studio VERSION ${OBS_VERSION_CANONICAL})
  54. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  55. # Use target folders for MSVC/Xcode/etc.
  56. include(DeprecationHelpers)
  57. include(ObsHelpers)
  58. # Set default compiler flags
  59. include(CompilerConfig)
  60. # Allow selection of common build types via UI
  61. if(NOT CMAKE_BUILD_TYPE)
  62. set(
  63. CMAKE_BUILD_TYPE
  64. "RelWithDebInfo"
  65. CACHE STRING
  66. "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]"
  67. FORCE
  68. )
  69. set_property(
  70. CACHE CMAKE_BUILD_TYPE
  71. PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel
  72. )
  73. endif()
  74. # Global project options
  75. option(ENABLE_HEVC "Enable HEVC encoders" ON)
  76. if(ENABLE_HEVC)
  77. add_compile_definitions(ENABLE_HEVC)
  78. endif()
  79. option(BUILD_FOR_DISTRIBUTION "Build for distribution (enables optimizations)" OFF)
  80. option(ENABLE_UI "Enable building with UI (requires Qt)" ON)
  81. option(ENABLE_SCRIPTING "Enable scripting support" ON)
  82. option(USE_LIBCXX "Use libc++ instead of libstdc++" ${APPLE})
  83. option(BUILD_TESTS "Build test directory (includes test sources and possibly a platform test executable)" OFF)
  84. if(OS_WINDOWS)
  85. option(
  86. INSTALLER_RUN
  87. "Build a multiarch installer (needs to run independently after both archs have compiled) (Windows)"
  88. OFF
  89. )
  90. elseif(OS_POSIX)
  91. option(LINUX_PORTABLE "Build portable version (Linux)" OFF)
  92. option(USE_XDG "Utilize XDG Base Directory Specification (Linux)" ON)
  93. option(ENABLE_PULSEAUDIO "Enable PulseAudio support" ON)
  94. if(OS_LINUX)
  95. option(ENABLE_WAYLAND "Enable building with support for Wayland (Linux)" ON)
  96. option(BUILD_FOR_PPA "Build for PPA distribution" OFF)
  97. endif()
  98. endif()
  99. setup_obs_project()
  100. mark_as_advanced(BUILD_TESTS USE_LIBCXX)
  101. if(INSTALLER_RUN)
  102. generate_multiarch_installer()
  103. return()
  104. endif()
  105. # OBS sources and plugins
  106. add_subdirectory(deps)
  107. add_subdirectory(libobs-opengl)
  108. if(OS_WINDOWS)
  109. add_subdirectory(libobs-d3d11)
  110. add_subdirectory(libobs-winrt)
  111. endif()
  112. add_subdirectory(libobs)
  113. add_subdirectory(plugins)
  114. # OBS main app
  115. add_subdirectory(UI)
  116. # Tests
  117. if(ENABLE_UNIT_TESTS)
  118. enable_testing()
  119. endif()
  120. if(BUILD_TESTS OR ENABLE_UNIT_TESTS)
  121. add_subdirectory(test)
  122. endif()