CMakeLists.txt 2.7 KB

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