bootstrap.cmake 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. cmake_minimum_required(VERSION 3.16...3.26)
  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 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 ON)
  31. # Add common module directories to default search path
  32. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/common")
  33. file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
  34. # cmake-format: off
  35. string(JSON _name GET ${buildspec} name)
  36. string(JSON _website GET ${buildspec} website)
  37. string(JSON _author GET ${buildspec} author)
  38. string(JSON _email GET ${buildspec} email)
  39. string(JSON _version GET ${buildspec} version)
  40. string(JSON _bundleId GET ${buildspec} platformConfig macos bundleId)
  41. string(JSON _macosPackageUUID GET ${buildspec} uuids macosPackage)
  42. string(JSON _macosInstallerUUID GET ${buildspec} uuids macosInstaller)
  43. string(JSON _windowsAppUUID GET ${buildspec} uuids windowsApp)
  44. # cmake-format: on
  45. set(PLUGIN_AUTHOR ${_author})
  46. set(PLUGIN_WEBSITE ${_website})
  47. set(PLUGIN_EMAIL ${_email})
  48. set(PLUGIN_VERSION ${_version})
  49. set(MACOS_BUNDLEID ${_bundleId})
  50. include(buildnumber)
  51. include(osconfig)
  52. # Allow selection of common build types via UI
  53. if(NOT CMAKE_BUILD_TYPE)
  54. set(CMAKE_BUILD_TYPE
  55. "RelWithDebInfo"
  56. CACHE STRING "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
  57. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
  58. endif()
  59. # Disable exports automatically going into the CMake package registry
  60. set(CMAKE_EXPORT_PACKAGE_REGISTRY FALSE)
  61. # Enable default inclusion of targets' source and binary directory
  62. set(CMAKE_INCLUDE_CURRENT_DIR TRUE)