conanfile.py 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. from conan import ConanFile
  2. from conan.tools.apple import is_apple_os
  3. from conan.tools.cmake import CMakeDeps, CMakeToolchain
  4. from conans import tools
  5. import os
  6. required_conan_version = ">=1.51.3"
  7. class VCMI(ConanFile):
  8. settings = "os", "compiler", "build_type", "arch"
  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. "minizip/*:shared": True,
  55. "onetbb/*:shared": True,
  56. # we need only the following Boost parts:
  57. # date_time filesystem locale program_options system thread
  58. # some other parts are also enabled because they're dependents
  59. # see e.g. conan-center-index/recipes/boost/all/dependencies
  60. "boost/*:without_context": True,
  61. "boost/*:without_contract": True,
  62. "boost/*:without_coroutine": True,
  63. "boost/*:without_fiber": True,
  64. "boost/*:without_graph": True,
  65. "boost/*:without_graph_parallel": True,
  66. "boost/*:without_iostreams": True,
  67. "boost/*:without_json": True,
  68. "boost/*:without_log": True,
  69. "boost/*:without_math": True,
  70. "boost/*:without_mpi": True,
  71. "boost/*:without_nowide": True,
  72. "boost/*:without_python": True,
  73. "boost/*:without_random": True,
  74. "boost/*:without_regex": True,
  75. "boost/*:without_serialization": True,
  76. "boost/*:without_stacktrace": True,
  77. "boost/*:without_test": True,
  78. "boost/*:without_timer": True,
  79. "boost/*:without_type_erasure": True,
  80. "boost/*:without_wave": True,
  81. "ffmpeg/*:avdevice": False,
  82. "ffmpeg/*:avfilter": False,
  83. "ffmpeg/*:postproc": False,
  84. "ffmpeg/*:swresample": False,
  85. "ffmpeg/*:with_freetype": False,
  86. "ffmpeg/*:with_libfdk_aac": False,
  87. "ffmpeg/*:with_libmp3lame": False,
  88. "ffmpeg/*:with_libvpx": False,
  89. "ffmpeg/*:with_libwebp": False,
  90. "ffmpeg/*:with_libx264": False,
  91. "ffmpeg/*:with_libx265": False,
  92. "ffmpeg/*:with_openh264": False,
  93. "ffmpeg/*:with_openjpeg": False,
  94. "ffmpeg/*:with_opus": False,
  95. "ffmpeg/*:with_programs": False,
  96. "ffmpeg/*:with_ssl": False,
  97. "ffmpeg/*:with_vorbis": False,
  98. "sdl/*:vulkan": False,
  99. "sdl_image/*:lbm": False,
  100. "sdl_image/*:pnm": False,
  101. "sdl_image/*:svg": False,
  102. "sdl_image/*:tga": False,
  103. "sdl_image/*:with_libjpeg": False,
  104. "sdl_image/*:with_libtiff": False,
  105. "sdl_image/*:with_libwebp": False,
  106. "sdl_image/*:xcf": False,
  107. "sdl_image/*:xpm": False,
  108. "sdl_image/*:xv": False,
  109. "sdl_mixer/*:flac": False,
  110. "sdl_mixer/*:mad": False,
  111. "sdl_mixer/*:mikmod": False,
  112. "sdl_mixer/*:modplug": False,
  113. "sdl_mixer/*:nativemidi": False,
  114. "sdl_mixer/*:opus": False,
  115. "sdl_mixer/*:wav": False,
  116. "qt/*:config": " ".join(_qtOptions),
  117. "qt/*:qttools": True,
  118. "qt/*:with_freetype": False,
  119. "qt/*:with_libjpeg": False,
  120. "qt/*:with_md4c": False,
  121. "qt/*:with_mysql": False,
  122. "qt/*:with_odbc": False,
  123. "qt/*:with_openal": False,
  124. "qt/*:with_pq": False,
  125. # transitive deps
  126. "pcre2/*:build_pcre2grep": False, # doesn't link to overridden bzip2 & zlib, the tool isn't needed anyway
  127. }
  128. def configure(self):
  129. # SDL_image and Qt depend on it, in iOS both are static
  130. self.options["libpng"].shared = self.settings.os != "iOS"
  131. self.options["qt"].openssl = not is_apple_os(self)
  132. self.options["qt"].shared = self.settings.os != "iOS"
  133. if self.settings.os == "iOS":
  134. self.options["qt"].opengl = "es2"
  135. self.options["sdl"].sdl2main = self.settings.os != "iOS"
  136. if is_apple_os(self):
  137. self.options["sdl_image"].imageio = True
  138. def requirements(self):
  139. # TODO: will no longer be needed after merging https://github.com/conan-io/conan-center-index/pull/13399
  140. self.requires("libpng/1.6.38", override=True) # freetype / Qt
  141. # use Apple system libraries instead of external ones
  142. if is_apple_os(self):
  143. systemLibsOverrides = [
  144. "bzip2/1.0.8",
  145. "libiconv/1.17",
  146. "sqlite3/3.39.2",
  147. "zlib/1.2.12",
  148. ]
  149. for lib in systemLibsOverrides:
  150. self.requires(f"{lib}@vcmi/apple", override=True)
  151. # TODO: the latest official release of LuaJIT (which is quite old) can't be built for arm
  152. if not str(self.settings.arch).startswith("arm"):
  153. self.requires("luajit/2.0.5")
  154. def generate(self):
  155. tc = CMakeToolchain(self)
  156. tc.variables["USING_CONAN"] = True
  157. tc.generate()
  158. deps = CMakeDeps(self)
  159. if os.getenv("USE_CONAN_WITH_ALL_CONFIGS", "0") == "0":
  160. deps.generate()
  161. return
  162. # allow using prebuilt deps with all configs
  163. # credits to https://github.com/conan-io/conan/issues/11607#issuecomment-1188500937 for the workaround
  164. configs = [
  165. "Debug",
  166. "MinSizeRel",
  167. "Release",
  168. "RelWithDebInfo",
  169. ]
  170. for config in configs:
  171. print(f"generating CMakeDeps for {config}")
  172. deps.configuration = config
  173. deps.generate()
  174. def imports(self):
  175. self.copy("*.dylib", "Frameworks", "lib")