conanfile.py 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. from conan import ConanFile
  2. from conan.tools.apple import is_apple_os
  3. from conan.tools.cmake import CMakeDeps
  4. from conans import tools
  5. import os
  6. class VCMI(ConanFile):
  7. settings = "os", "compiler", "build_type", "arch"
  8. generators = "CMakeToolchain"
  9. requires = [
  10. "boost/1.80.0",
  11. "ffmpeg/4.4.3",
  12. "minizip/1.2.12",
  13. "onetbb/2021.3.0", # Nullkiller AI
  14. "qt/5.15.6", # launcher
  15. "sdl/2.24.1",
  16. "sdl_image/2.0.5",
  17. "sdl_mixer/2.0.4",
  18. "sdl_ttf/2.0.18",
  19. ]
  20. def _disableQtOptions(disableFlag, options):
  21. return " ".join([f"-{disableFlag}-{tool}" for tool in options])
  22. _qtOptions = [
  23. _disableQtOptions("no", [
  24. "gif",
  25. "ico",
  26. ]),
  27. _disableQtOptions("no-feature", [
  28. # xpm format is required for Drag'n'Drop support
  29. "imageformat_bmp",
  30. "imageformat_jpeg",
  31. "imageformat_ppm",
  32. "imageformat_xbm",
  33. # we need only macdeployqt
  34. # TODO: disabling these doesn't disable generation of CMake targets
  35. # TODO: in Qt 6.3 it's a part of qtbase
  36. # "assistant",
  37. # "designer",
  38. # "distancefieldgenerator",
  39. # "kmap2qmap",
  40. # "linguist",
  41. # "makeqpf",
  42. # "pixeltool",
  43. # "qdbus",
  44. # "qev",
  45. # "qtattributionsscanner",
  46. # "qtdiag",
  47. # "qtpaths",
  48. # "qtplugininfo",
  49. ]),
  50. ]
  51. default_options = {
  52. # shared libs
  53. "boost/*:shared": True,
  54. "libpng/*:shared": True, # SDL_image and Qt depend on it
  55. "minizip/*:shared": True,
  56. "onetbb/*:shared": True,
  57. "qt/*:shared": True,
  58. # we need only the following Boost parts:
  59. # date_time filesystem locale program_options system thread
  60. # some other parts are also enabled because they're dependents
  61. # see e.g. conan-center-index/recipes/boost/all/dependencies
  62. "boost/*:without_context": True,
  63. "boost/*:without_contract": True,
  64. "boost/*:without_coroutine": True,
  65. "boost/*:without_fiber": True,
  66. "boost/*:without_graph": True,
  67. "boost/*:without_graph_parallel": True,
  68. "boost/*:without_iostreams": True,
  69. "boost/*:without_json": True,
  70. "boost/*:without_log": True,
  71. "boost/*:without_math": True,
  72. "boost/*:without_mpi": True,
  73. "boost/*:without_nowide": True,
  74. "boost/*:without_python": True,
  75. "boost/*:without_random": True,
  76. "boost/*:without_regex": True,
  77. "boost/*:without_serialization": True,
  78. "boost/*:without_stacktrace": True,
  79. "boost/*:without_test": True,
  80. "boost/*:without_timer": True,
  81. "boost/*:without_type_erasure": True,
  82. "boost/*:without_wave": True,
  83. "ffmpeg/*:avdevice": False,
  84. "ffmpeg/*:avfilter": False,
  85. "ffmpeg/*:postproc": False,
  86. "ffmpeg/*:swresample": False,
  87. "ffmpeg/*:with_freetype": False,
  88. "ffmpeg/*:with_libfdk_aac": False,
  89. "ffmpeg/*:with_libmp3lame": False,
  90. "ffmpeg/*:with_libvpx": False,
  91. "ffmpeg/*:with_libwebp": False,
  92. "ffmpeg/*:with_libx264": False,
  93. "ffmpeg/*:with_libx265": False,
  94. "ffmpeg/*:with_openh264": False,
  95. "ffmpeg/*:with_openjpeg": False,
  96. "ffmpeg/*:with_opus": False,
  97. "ffmpeg/*:with_programs": False,
  98. "ffmpeg/*:with_ssl": False,
  99. "ffmpeg/*:with_vorbis": False,
  100. "sdl/*:vulkan": False,
  101. "sdl_image/*:imageio": True,
  102. "sdl_image/*:lbm": False,
  103. "sdl_image/*:pnm": False,
  104. "sdl_image/*:svg": False,
  105. "sdl_image/*:tga": False,
  106. "sdl_image/*:with_libjpeg": False,
  107. "sdl_image/*:with_libtiff": False,
  108. "sdl_image/*:with_libwebp": False,
  109. "sdl_image/*:xcf": False,
  110. "sdl_image/*:xpm": False,
  111. "sdl_image/*:xv": False,
  112. "sdl_mixer/*:flac": False,
  113. "sdl_mixer/*:mad": False,
  114. "sdl_mixer/*:mikmod": False,
  115. "sdl_mixer/*:modplug": False,
  116. "sdl_mixer/*:nativemidi": False,
  117. "sdl_mixer/*:opus": False,
  118. "sdl_mixer/*:wav": False,
  119. "qt/*:config": " ".join(_qtOptions),
  120. "qt/*:openssl": False,
  121. "qt/*:qttools": True,
  122. "qt/*:with_freetype": False,
  123. "qt/*:with_libjpeg": False,
  124. "qt/*:with_md4c": False,
  125. "qt/*:with_mysql": False,
  126. "qt/*:with_odbc": False,
  127. "qt/*:with_openal": False,
  128. "qt/*:with_pq": False,
  129. # transitive deps
  130. "pcre2/*:build_pcre2grep": False, # doesn't link to overridden bzip2 & zlib, the tool isn't needed anyway
  131. }
  132. def configure(self):
  133. # workaround: macOS deployment target isn't passed to linker when building Boost
  134. # TODO: remove when https://github.com/conan-io/conan-center-index/pull/12468 is merged
  135. if is_apple_os(self):
  136. osVersion = self.settings.get_safe("os.version")
  137. if osVersion:
  138. deploymentTargetFlag = tools.apple_deployment_target_flag(
  139. self.settings.os,
  140. osVersion,
  141. self.settings.get_safe("os.sdk"),
  142. self.settings.get_safe("os.subsystem"),
  143. self.settings.get_safe("arch")
  144. )
  145. self.options["boost"].extra_b2_flags = f"linkflags={deploymentTargetFlag}"
  146. def requirements(self):
  147. self.requires("libpng/1.6.38", override=True) # freetype / Qt
  148. # use Apple system libraries instead of external ones
  149. if is_apple_os(self):
  150. systemLibsOverrides = [
  151. "bzip2/1.0.8",
  152. "libiconv/1.17",
  153. "sqlite3/3.39.2",
  154. "zlib/1.2.12",
  155. ]
  156. for lib in systemLibsOverrides:
  157. self.requires(f"{lib}@kambala/apple", override=True)
  158. # TODO: the latest official release of LuaJIT (which is quite old) can't be built for arm Mac
  159. if self.settings.os != "Macos" or self.settings.arch != "armv8":
  160. self.requires("luajit/2.0.5")
  161. def generate(self):
  162. deps = CMakeDeps(self)
  163. if os.getenv("USE_CONAN_WITH_ALL_CONFIGS", "0") == "0":
  164. deps.generate()
  165. return
  166. # allow using prebuilt deps with all configs
  167. # credits to https://github.com/conan-io/conan/issues/11607#issuecomment-1188500937 for the workaround
  168. configs = [
  169. "Debug",
  170. "MinSizeRel",
  171. "Release",
  172. "RelWithDebInfo",
  173. ]
  174. for config in configs:
  175. print(f"generating CMakeDeps for {config}")
  176. deps.configuration = config
  177. deps.generate()
  178. def imports(self):
  179. self.copy("*.dylib", "Frameworks", "lib")