I am using Conan version 1.27.1 and trying to generate a toolchain from the existing setting in options in my profile file. The following example, which is provided in the Conan document (https://docs.conan.io/en/latest/creating_packages/toolchains/cmake.html), fails with an error. It seems the method write_toolchain_file() does not exist. I tried write_toolchain(), which works, but it does not generate a toolchain cmake file.
I will greatly appreciate any help on this; so that I can generate a toolchain cmake file from my existing conan profile.
Code:
from conans import ConanFile, CMake, CMakeToolchain
class App(ConanFile):
settings = "os", "arch", "compiler", "build_type"
requires = "hello/0.1"
generators = "cmake_find_package_multi"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
def toolchain(self):
tc = CMakeToolchain(self)
tc.write_toolchain_files()
Error on running above code:
ERROR: conanfile.py: Error in toolchain() method, line 18
tc.write_toolchain_file()
AttributeError: 'CMakeToolchain' object has no attribute 'write_toolchain_files'