Conan is a package manager for C/C++. We provide prebuilt binary dependencies for some platforms that are used by our CI, but they can also be consumed by users to build VCMI. However, it's not required to use only the prebuilt binaries: you can build them from source as well.
The following platforms are supported and known to work, others might require changes to our conanfile.py or upstream recipes.
conan profile new default --detectIf your platform is not on the list of supported ones or you don't want to use our prebuilt binaries, you can still build dependencies from source or try consuming prebuilt binaries from the central Conan repository - ConanCenter. In this case skip to the next section directly.
Check if your build environment can use the prebuilt binaries: basically, that your compiler version (or Xcode major version) matches the information below. If you're unsure, simply advance to the next step.
Download the binaries archive and unpack it to ~/.conan directory:
Only if you have Apple Silicon Mac and trying to build for macOS or iOS: follow instructions how to build Qt host tools for Apple Silicon, on step 3 copy them to ~/.conan/data/qt/5.15.x/_/_/package/SOME_HASH/bin (5.15.x and SOME_HASH are placeholders).
Conan needs to generate CMake toolchain file to make dependencies available to CMake. See CMakeDeps and CMakeToolchain in the official documentation for details.
In terminal cd to the VCMI source directory and run the following command. If you want to download prebuilt binaries from ConanCenter, also read the next section.
conan install . \ --install-folder=conan-generated \ --no-imports \ --build=never \ --profile:build=default \ --profile:host=CI/conan/PROFILE
The highlighted parts can be adjusted:
missing to build recipes, that are not present in your local cache, from source.default (your default profile).If you use --build=never and this command fails, then it means that you can't use prebuilt binaries out of the box. For example, try using --build=missing instead.
VCMI "recipe" also has some options that you can specify. For example, if you don't care about game videos, you can disable FFmpeg dependency by passing -o with_ffmpeg=False. If you only want to make release build, you can use GENERATE_ONLY_BUILT_CONFIG=1 environment variable to skip generating files for other configurations (our CI does this).
Note: you can find full reference of this command in the official documentation or by executing conan help install.
First, check if binaries for your platform are produced.
You must adjust the above conan install command:
default.-o default_options_of_requirements=True: this disables all custom options of our conanfile.py to match ConanCenter builds.You must pass the generated toolchain file to CMake invocation.
build-with-conan preset. If you store Conan generated files in a non-default directory, define the path to the generated toolchain in toolchainFile field (or CMAKE_TOOLCHAIN_FILE cache variable) or include CMake presets file generated by Conan.--toolchain option (available in CMake 3.21+) or CMAKE_TOOLCHAIN_FILE variable.In these examples only the minimum required amount of options is passed to cmake invocation, you can pass additional ones as needed.
conan install . \
--install-folder=conan-generated \
--no-imports \
--build=never \
--profile:build=default \
--profile:host=CI/conan/macos-intel
cmake -S . -B build -G Xcode \
--toolchain conan-generated/conan_toolchain.cmake
If you also want to build the missing binaries from source, use --build=missing instead of --build=never.
conan install . \
--install-folder=~/my-dir \
--no-imports \
--build=never \
--profile:build=default \
--profile:host=default \
-o default_options_of_requirements=True
cmake -S . -B build \
-D CMAKE_TOOLCHAIN_FILE=~/my-dir/conan_toolchain.cmake
conan install . \
--install-folder=~/my-dir \
--no-imports \
--build=never \
--profile:build=default \
--profile:host=CI/conan/ios-arm64
cmake --preset ios-conan
CMakeUserPresets.json file:
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "ios-conan",
"displayName": "iOS",
"inherits": ["build-with-conan", "ios-device"],
"toolchainFile": "~/my-dir/conan_toolchain.cmake",
"cacheVariables": {
"BUNDLE_IDENTIFIER_PREFIX": "com.YOUR-NAME",
"CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM": "YOUR_TEAM_ID"
}
}
]
}