bootstrap.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # OBS CMake bootstrap module
  2. include_guard(GLOBAL)
  3. # Enable automatic PUSH and POP of policies to parent scope
  4. if(POLICY CMP0011)
  5. cmake_policy(SET CMP0011 NEW)
  6. endif()
  7. # Enable distinction between Clang and AppleClang
  8. if(POLICY CMP0025)
  9. cmake_policy(SET CMP0025 NEW)
  10. endif()
  11. # Enable strict checking of "break()" usage
  12. if(POLICY CMP0055)
  13. cmake_policy(SET CMP0055 NEW)
  14. endif()
  15. # Honor visibility presets for all target types (executable, shared, module, static)
  16. if(POLICY CMP0063)
  17. cmake_policy(SET CMP0063 NEW)
  18. endif()
  19. # Disable export function calls to populate package registry by default
  20. if(POLICY CMP0090)
  21. cmake_policy(SET CMP0090 NEW)
  22. endif()
  23. # Prohibit in-source builds
  24. if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
  25. message(FATAL_ERROR "In-source builds of OBS are not supported. "
  26. "Specify a build directory via 'cmake -S <SOURCE DIRECTORY> -B <BUILD_DIRECTORY>' instead.")
  27. file(REMOVE_RECURSE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeCache.txt" "${CMAKE_CURRENT_SOURCE_DIR}/CMakeFiles")
  28. endif()
  29. # Use folders for source file organization with IDE generators (Visual Studio/Xcode)
  30. set_property(GLOBAL PROPERTY USE_FOLDERS TRUE)
  31. # Set default global project variables
  32. set(OBS_COMPANY_NAME "OBS Project")
  33. set(OBS_PRODUCT_NAME "OBS Studio")
  34. set(OBS_WEBSITE "https://www.obsproject.com")
  35. set(OBS_COMMENTS "Free and open source software for video recording and live streaming")
  36. set(OBS_LEGAL_COPYRIGHT "(C) Lain Bailey")
  37. set(OBS_CMAKE_VERSION 3.0.0)
  38. # Configure default version strings
  39. set(_obs_default_version "0" "0" "1")
  40. set(_obs_release_candidate "0" "0" "0" "0")
  41. set(_obs_beta "0" "0" "0" "0")
  42. # Add common module directories to default search path
  43. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/common" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/finders")
  44. include(versionconfig)
  45. include(buildnumber)
  46. include(osconfig)
  47. # Allow selection of common build types via UI
  48. if(NOT CMAKE_GENERATOR MATCHES "(Xcode|Visual Studio .+)")
  49. set(CMAKE_BUILD_TYPE
  50. "RelWithDebInfo"
  51. CACHE STRING "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
  52. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
  53. endif()
  54. # Disable exports automatically going into the CMake package registry
  55. set(CMAKE_EXPORT_PACKAGE_REGISTRY FALSE)
  56. # Enable default inclusion of targets' source and binary directory
  57. set(CMAKE_INCLUDE_CURRENT_DIR TRUE)