bootstrap.cmake 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Plugin bootstrap module
  2. include_guard(GLOBAL)
  3. # Map fallback configurations for optimized build configurations
  4. # gersemi: off
  5. set(
  6. CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO
  7. RelWithDebInfo
  8. Release
  9. MinSizeRel
  10. None
  11. ""
  12. )
  13. set(
  14. CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL
  15. MinSizeRel
  16. Release
  17. RelWithDebInfo
  18. None
  19. ""
  20. )
  21. set(
  22. CMAKE_MAP_IMPORTED_CONFIG_RELEASE
  23. Release
  24. RelWithDebInfo
  25. MinSizeRel
  26. None
  27. ""
  28. )
  29. # gersemi: on
  30. # Prohibit in-source builds
  31. if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
  32. message(
  33. FATAL_ERROR
  34. "In-source builds are not supported. "
  35. "Specify a build directory via 'cmake -S <SOURCE DIRECTORY> -B <BUILD_DIRECTORY>' instead."
  36. )
  37. file(REMOVE_RECURSE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeCache.txt" "${CMAKE_CURRENT_SOURCE_DIR}/CMakeFiles")
  38. endif()
  39. # Add common module directories to default search path
  40. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/common")
  41. file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
  42. string(JSON _name GET ${buildspec} name)
  43. string(JSON _website GET ${buildspec} website)
  44. string(JSON _author GET ${buildspec} author)
  45. string(JSON _email GET ${buildspec} email)
  46. string(JSON _version GET ${buildspec} version)
  47. string(JSON _bundleId GET ${buildspec} platformConfig macos bundleId)
  48. set(PLUGIN_AUTHOR ${_author})
  49. set(PLUGIN_WEBSITE ${_website})
  50. set(PLUGIN_EMAIL ${_email})
  51. set(PLUGIN_VERSION ${_version})
  52. set(MACOS_BUNDLEID ${_bundleId})
  53. string(REPLACE "." ";" _version_canonical "${_version}")
  54. list(GET _version_canonical 0 PLUGIN_VERSION_MAJOR)
  55. list(GET _version_canonical 1 PLUGIN_VERSION_MINOR)
  56. list(GET _version_canonical 2 PLUGIN_VERSION_PATCH)
  57. unset(_version_canonical)
  58. include(buildnumber)
  59. include(osconfig)
  60. # Allow selection of common build types via UI
  61. if(NOT CMAKE_GENERATOR MATCHES "(Xcode|Visual Studio .+)")
  62. if(NOT CMAKE_BUILD_TYPE)
  63. set(
  64. CMAKE_BUILD_TYPE
  65. "RelWithDebInfo"
  66. CACHE STRING
  67. "OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]"
  68. FORCE
  69. )
  70. set_property(
  71. CACHE CMAKE_BUILD_TYPE
  72. PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel
  73. )
  74. endif()
  75. endif()
  76. # Disable exports automatically going into the CMake package registry
  77. set(CMAKE_EXPORT_PACKAGE_REGISTRY FALSE)
  78. # Enable default inclusion of targets' source and binary directory
  79. set(CMAKE_INCLUDE_CURRENT_DIR TRUE)