CMakeLists.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. cmake_minimum_required(VERSION 3.22...3.25)
  2. if(CMAKE_HOST_SYSTEM_NAME MATCHES "(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_SIZEOF_VOID_P EQUAL 4)
  6. include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/32bit/projects.cmake")
  7. return()
  8. endif()
  9. include(compilerconfig)
  10. include(defaults)
  11. include(helpers)
  12. option(ENABLE_UI "Enable building with UI (requires Qt)" ON)
  13. option(ENABLE_SCRIPTING "Enable scripting support" ON)
  14. option(ENABLE_HEVC "Enable HEVC encoders" ON)
  15. add_subdirectory(libobs)
  16. if(OS_WINDOWS)
  17. add_subdirectory(libobs-d3d11)
  18. add_subdirectory(libobs-winrt)
  19. endif()
  20. add_subdirectory(libobs-opengl)
  21. add_subdirectory(plugins)
  22. add_subdirectory(test/test-input)
  23. add_subdirectory(UI)
  24. message_configuration()
  25. return()
  26. endif()
  27. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules")
  28. include(VersionConfig)
  29. # Prohibit in-source builds
  30. if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
  31. message(FATAL_ERROR "OBS: You cannot build in a source directory (or any directory with CMakeLists.txt file). "
  32. "Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles.")
  33. endif()
  34. project(obs-studio VERSION ${OBS_VERSION_CANONICAL})
  35. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  36. # Use target folders for MSVC/Xcode/etc.
  37. include(DeprecationHelpers)
  38. include(ObsHelpers)
  39. # Set default compiler flags
  40. include(CompilerConfig)
  41. # Allow selection of common build types via UI
  42. if(NOT CMAKE_BUILD_TYPE)
  43. set(CMAKE_BUILD_TYPE
  44. "RelWithDebInfo"
  45. CACHE STRING "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
  46. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
  47. endif()
  48. # Global project options
  49. option(ENABLE_HEVC "Enable HEVC encoders" ON)
  50. if(ENABLE_HEVC)
  51. add_compile_definitions(ENABLE_HEVC)
  52. endif()
  53. option(BUILD_FOR_DISTRIBUTION "Build for distribution (enables optimizations)" OFF)
  54. option(ENABLE_UI "Enable building with UI (requires Qt)" ON)
  55. option(ENABLE_SCRIPTING "Enable scripting support" ON)
  56. option(USE_LIBCXX "Use libc++ instead of libstdc++" ${APPLE})
  57. option(BUILD_TESTS "Build test directory (includes test sources and possibly a platform test executable)" OFF)
  58. if(OS_WINDOWS)
  59. option(INSTALLER_RUN
  60. "Build a multiarch installer (needs to run independently after both archs have compiled) (Windows)" OFF)
  61. elseif(OS_POSIX)
  62. option(LINUX_PORTABLE "Build portable version (Linux)" OFF)
  63. option(USE_XDG "Utilize XDG Base Directory Specification (Linux)" ON)
  64. option(ENABLE_PULSEAUDIO "Enable PulseAudio support" ON)
  65. if(OS_LINUX)
  66. option(ENABLE_WAYLAND "Enable building with support for Wayland (Linux)" ON)
  67. option(BUILD_FOR_PPA "Build for PPA distribution" OFF)
  68. endif()
  69. endif()
  70. setup_obs_project()
  71. mark_as_advanced(BUILD_TESTS USE_LIBCXX)
  72. if(INSTALLER_RUN)
  73. generate_multiarch_installer()
  74. return()
  75. endif()
  76. # OBS sources and plugins
  77. add_subdirectory(deps)
  78. add_subdirectory(libobs-opengl)
  79. if(OS_WINDOWS)
  80. add_subdirectory(libobs-d3d11)
  81. add_subdirectory(libobs-winrt)
  82. endif()
  83. add_subdirectory(libobs)
  84. add_subdirectory(plugins)
  85. # OBS main app
  86. add_subdirectory(UI)
  87. # Tests
  88. if(ENABLE_UNIT_TESTS)
  89. enable_testing()
  90. endif()
  91. if(BUILD_TESTS OR ENABLE_UNIT_TESTS)
  92. add_subdirectory(test)
  93. endif()