bootstrap.cmake 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 _windowsAppUUID GET ${buildspec} uuids windowsApp)
  42. # cmake-format: on
  43. set(PLUGIN_AUTHOR ${_author})
  44. set(PLUGIN_WEBSITE ${_website})
  45. set(PLUGIN_EMAIL ${_email})
  46. set(PLUGIN_VERSION ${_version})
  47. set(MACOS_BUNDLEID ${_bundleId})
  48. include(buildnumber)
  49. include(osconfig)
  50. # Allow selection of common build types via UI
  51. if(NOT CMAKE_BUILD_TYPE)
  52. set(CMAKE_BUILD_TYPE
  53. "RelWithDebInfo"
  54. CACHE STRING "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
  55. set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
  56. endif()
  57. # Disable exports automatically going into the CMake package registry
  58. set(CMAKE_EXPORT_PACKAGE_REGISTRY FALSE)
  59. # Enable default inclusion of targets' source and binary directory
  60. set(CMAKE_INCLUDE_CURRENT_DIR TRUE)