1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

[Conan] add option to use default options of dependencies

this allows consuming prebuilt binaries from CCI
name: default_options_of_requirements
This commit is contained in:
Andrey Filipenkov 2022-10-14 16:49:48 +03:00
parent 77d0fa8659
commit 3a0d11b38a

View File

@ -1,4 +1,5 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import is_apple_os
from conan.tools.cmake import CMakeDeps, CMakeToolchain
from conans import tools
@ -20,155 +21,161 @@ class VCMI(ConanFile):
"sdl_ttf/2.0.18",
]
options = {
"default_options_of_requirements": [True, False],
"with_ffmpeg": [True, False],
"with_luajit": [True, False],
}
def _disableQtOptions(disableFlag, options):
return " ".join([f"-{disableFlag}-{tool}" for tool in options])
_qtOptions = [
_disableQtOptions("no", [
"gif",
"ico",
]),
_disableQtOptions("no-feature", [
# xpm format is required for Drag'n'Drop support
"imageformat_bmp",
"imageformat_jpeg",
"imageformat_ppm",
"imageformat_xbm",
# we need only macdeployqt
# TODO: disabling these doesn't disable generation of CMake targets
# TODO: in Qt 6.3 it's a part of qtbase
# "assistant",
# "designer",
# "distancefieldgenerator",
# "kmap2qmap",
# "linguist",
# "makeqpf",
# "pixeltool",
# "qdbus",
# "qev",
# "qtattributionsscanner",
# "qtdiag",
# "qtpaths",
# "qtplugininfo",
]),
]
default_options = {
"default_options_of_requirements": False,
"with_ffmpeg": True,
"with_luajit": False,
# shared libs
"boost/*:shared": True,
"minizip/*:shared": True,
"onetbb/*:shared": True,
# we need only the following Boost parts:
# date_time filesystem locale program_options system thread
# some other parts are also enabled because they're dependents
# see e.g. conan-center-index/recipes/boost/all/dependencies
"boost/*:without_context": True,
"boost/*:without_contract": True,
"boost/*:without_coroutine": True,
"boost/*:without_fiber": True,
"boost/*:without_graph": True,
"boost/*:without_graph_parallel": True,
"boost/*:without_iostreams": True,
"boost/*:without_json": True,
"boost/*:without_log": True,
"boost/*:without_math": True,
"boost/*:without_mpi": True,
"boost/*:without_nowide": True,
"boost/*:without_python": True,
"boost/*:without_random": True,
"boost/*:without_regex": True,
"boost/*:without_serialization": True,
"boost/*:without_stacktrace": True,
"boost/*:without_test": True,
"boost/*:without_timer": True,
"boost/*:without_type_erasure": True,
"boost/*:without_wave": True,
"ffmpeg/*:avdevice": False,
"ffmpeg/*:avfilter": False,
"ffmpeg/*:postproc": False,
"ffmpeg/*:swresample": False,
"ffmpeg/*:with_freetype": False,
"ffmpeg/*:with_libfdk_aac": False,
"ffmpeg/*:with_libmp3lame": False,
"ffmpeg/*:with_libvpx": False,
"ffmpeg/*:with_libwebp": False,
"ffmpeg/*:with_libx264": False,
"ffmpeg/*:with_libx265": False,
"ffmpeg/*:with_openh264": False,
"ffmpeg/*:with_openjpeg": False,
"ffmpeg/*:with_opus": False,
"ffmpeg/*:with_programs": False,
"ffmpeg/*:with_ssl": False,
"ffmpeg/*:with_vorbis": False,
"sdl/*:vulkan": False,
"sdl_image/*:lbm": False,
"sdl_image/*:pnm": False,
"sdl_image/*:svg": False,
"sdl_image/*:tga": False,
"sdl_image/*:with_libjpeg": False,
"sdl_image/*:with_libtiff": False,
"sdl_image/*:with_libwebp": False,
"sdl_image/*:xcf": False,
"sdl_image/*:xpm": False,
"sdl_image/*:xv": False,
"sdl_mixer/*:flac": False,
"sdl_mixer/*:mad": False,
"sdl_mixer/*:mikmod": False,
"sdl_mixer/*:modplug": False,
"sdl_mixer/*:nativemidi": False,
"sdl_mixer/*:opus": False,
"sdl_mixer/*:wav": False,
"qt/*:config": " ".join(_qtOptions),
"qt/*:qttools": True,
"qt/*:with_freetype": False,
"qt/*:with_libjpeg": False,
"qt/*:with_md4c": False,
"qt/*:with_mysql": False,
"qt/*:with_odbc": False,
"qt/*:with_openal": False,
"qt/*:with_pq": False,
# transitive deps
"pcre2/*:build_pcre2grep": False, # doesn't link to overridden bzip2 & zlib, the tool isn't needed anyway
}
def configure(self):
# SDL_image and Qt depend on it, in iOS both are static
self.options["libpng"].shared = self.settings.os != "iOS"
self.options["qt"].openssl = not is_apple_os(self)
# static Qt for iOS is the only viable option at the moment
self.options["qt"].shared = self.settings.os != "iOS"
if self.options.default_options_of_requirements:
return
# we need only the following Boost parts:
# date_time filesystem locale program_options system thread
# some other parts are also enabled because they're dependents
# see e.g. conan-center-index/recipes/boost/all/dependencies
self.options["boost"].without_context = True
self.options["boost"].without_contract = True
self.options["boost"].without_coroutine = True
self.options["boost"].without_fiber = True
self.options["boost"].without_graph = True
self.options["boost"].without_graph_parallel = True
self.options["boost"].without_iostreams = True
self.options["boost"].without_json = True
self.options["boost"].without_log = True
self.options["boost"].without_math = True
self.options["boost"].without_mpi = True
self.options["boost"].without_nowide = True
self.options["boost"].without_python = True
self.options["boost"].without_random = True
self.options["boost"].without_regex = True
self.options["boost"].without_serialization = True
self.options["boost"].without_stacktrace = True
self.options["boost"].without_test = True
self.options["boost"].without_timer = True
self.options["boost"].without_type_erasure = True
self.options["boost"].without_wave = True
self.options["ffmpeg"].avdevice = False
self.options["ffmpeg"].avfilter = False
self.options["ffmpeg"].postproc = False
self.options["ffmpeg"].swresample = False
self.options["ffmpeg"].with_freetype = False
self.options["ffmpeg"].with_libfdk_aac = False
self.options["ffmpeg"].with_libmp3lame = False
self.options["ffmpeg"].with_libvpx = False
self.options["ffmpeg"].with_libwebp = False
self.options["ffmpeg"].with_libx264 = False
self.options["ffmpeg"].with_libx265 = False
self.options["ffmpeg"].with_openh264 = False
self.options["ffmpeg"].with_openjpeg = False
self.options["ffmpeg"].with_opus = False
self.options["ffmpeg"].with_programs = False
self.options["ffmpeg"].with_ssl = False
self.options["ffmpeg"].with_vorbis = False
self.options["sdl"].sdl2main = self.settings.os != "iOS"
self.options["sdl"].vulkan = False
self.options["sdl_image"].lbm = False
self.options["sdl_image"].pnm = False
self.options["sdl_image"].svg = False
self.options["sdl_image"].tga = False
self.options["sdl_image"].with_libjpeg = False
self.options["sdl_image"].with_libtiff = False
self.options["sdl_image"].with_libwebp = False
self.options["sdl_image"].xcf = False
self.options["sdl_image"].xpm = False
self.options["sdl_image"].xv = False
if is_apple_os(self):
self.options["sdl_image"].imageio = True
self.options["sdl_mixer"].flac = False
self.options["sdl_mixer"].mad = False
self.options["sdl_mixer"].mikmod = False
self.options["sdl_mixer"].modplug = False
self.options["sdl_mixer"].nativemidi = False
self.options["sdl_mixer"].opus = False
self.options["sdl_mixer"].wav = False
def _disableQtOptions(disableFlag, options):
return " ".join([f"-{disableFlag}-{tool}" for tool in options])
_qtOptions = [
_disableQtOptions("no", [
"gif",
"ico",
]),
_disableQtOptions("no-feature", [
# xpm format is required for Drag'n'Drop support
"imageformat_bmp",
"imageformat_jpeg",
"imageformat_ppm",
"imageformat_xbm",
# we need only macdeployqt
# TODO: disabling these doesn't disable generation of CMake targets
# TODO: in Qt 6.3 it's a part of qtbase
# "assistant",
# "designer",
# "distancefieldgenerator",
# "kmap2qmap",
# "linguist",
# "makeqpf",
# "pixeltool",
# "qdbus",
# "qev",
# "qtattributionsscanner",
# "qtdiag",
# "qtpaths",
# "qtplugininfo",
]),
]
self.options["qt"].config = " ".join(_qtOptions)
self.options["qt"].qttools = True
self.options["qt"].with_freetype = False
self.options["qt"].with_libjpeg = False
self.options["qt"].with_md4c = False
self.options["qt"].with_mysql = False
self.options["qt"].with_odbc = False
self.options["qt"].with_openal = False
self.options["qt"].with_pq = False
self.options["qt"].openssl = not is_apple_os(self)
if self.settings.os == "iOS":
self.options["qt"].opengl = "es2"
self.options["sdl"].sdl2main = self.settings.os != "iOS"
if is_apple_os(self):
self.options["sdl_image"].imageio = True
# transitive deps
# doesn't link to overridden bzip2 & zlib, the tool isn't needed anyway
self.options["pcre2"].build_pcre2grep = False
def requirements(self):
# TODO: will no longer be needed after merging https://github.com/conan-io/conan-center-index/pull/13399
self.requires("libpng/1.6.38", override=True) # freetype / Qt
if self.options.default_options_of_requirements:
self.requires("libjpeg/9e", override=True) # libtiff / Qt
self.requires("freetype/2.12.1", override=True) # sdl_ttf / Qt
if self.options.with_ffmpeg:
self.requires("libwebp/1.2.4", override=True) # sdl_image / ffmpeg
if self.options.with_ffmpeg:
self.requires("ffmpeg/4.4.3")
# use Apple system libraries instead of external ones
if is_apple_os(self):
if not self.options.default_options_of_requirements and is_apple_os(self):
systemLibsOverrides = [
"bzip2/1.0.8",
"libiconv/1.17",