CMakeLists.txt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_POSIX)
  48. option(LINUX_PORTABLE "Build portable version (Linux)" OFF)
  49. option(USE_XDG "Utilize XDG Base Directory Specification (Linux)" ON)
  50. option(ENABLE_PULSEAUDIO "Enable PulseAudio support" ON)
  51. if(OS_LINUX)
  52. option(ENABLE_WAYLAND "Enable building with support for Wayland (Linux)" ON)
  53. option(BUILD_FOR_PPA "Build for PPA distribution" OFF)
  54. endif()
  55. endif()
  56. setup_obs_project()
  57. mark_as_advanced(BUILD_TESTS USE_LIBCXX)
  58. if(INSTALLER_RUN)
  59. generate_multiarch_installer()
  60. return()
  61. endif()
  62. # OBS sources and plugins
  63. add_subdirectory(deps)
  64. add_subdirectory(libobs-opengl)
  65. if(OS_WINDOWS)
  66. add_subdirectory(libobs-d3d11)
  67. add_subdirectory(libobs-winrt)
  68. endif()
  69. add_subdirectory(libobs)
  70. add_subdirectory(plugins)
  71. # OBS main app
  72. add_subdirectory(UI)
  73. # Tests
  74. if(ENABLE_UNIT_TESTS)
  75. enable_testing()
  76. endif()
  77. if(BUILD_TESTS OR ENABLE_UNIT_TESTS)
  78. add_subdirectory(test)
  79. endif()