def __init__(self, conanfile, generator=None, generator_platform=None, build_type=None, toolset=None, parallel=True): self._conanfile = conanfile self.fpic = self._deduce_fpic() self.vs_static_runtime = self._deduce_vs_static_runtime() self.parallel = parallel # To find the generated cmake_find_package finders self.cmake_prefix_path = "${CMAKE_BINARY_DIR}" self.cmake_module_path = "${CMAKE_BINARY_DIR}" self.generator = generator or get_generator(self._conanfile) self.generator_platform = (generator_platform or get_generator_platform( self._conanfile.settings, self.generator)) self.toolset = toolset or get_toolset(self._conanfile.settings, self.generator) self.variables = Variables() self.preprocessor_definitions = Variables() try: self._build_shared_libs = "ON" if self._conanfile.options.shared else "OFF" except ConanException: self._build_shared_libs = None self.set_libcxx, self.glibcxx = self._get_libcxx() self.parallel = None if parallel: if self.generator and "Visual Studio" in self.generator: self.parallel = "/MP%s" % cpu_count( output=self._conanfile.output) self.cppstd, self.cppstd_extensions = self._cppstd() self.skip_rpath = True if self._conanfile.settings.get_safe( "os") == "Macos" else False self.architecture = self._get_architecture() # TODO: I would want to have here the path to the compiler too build_type = build_type or self._conanfile.settings.get_safe( "build_type") self.build_type = build_type if not is_multi_configuration( self.generator) else None try: # This is only defined in the cache, not in the local flow self.install_prefix = self._conanfile.package_folder.replace( "\\", "/") except AttributeError: # FIXME: In the local flow, we don't know the package_folder self.install_prefix = None
def write_toolchain_files(self): # Make it absolute, wrt to current folder, set by the caller conan_project_include_cmake = os.path.abspath( "conan_project_include.cmake") conan_project_include_cmake = conan_project_include_cmake.replace( "\\", "/") t = Template(self._template_project_include) content = t.render(configuration_types_definitions=self.definitions. configuration_types, vs_static_runtime=self._vs_static_runtime) save(conan_project_include_cmake, content) # TODO: I need the profile_host and profile_build here! # TODO: What if the compiler is a build require? # TODO: Add all the stuff related to settings (ALL settings or just _MY_ settings?) # TODO: I would want to have here the path to the compiler too build_type = self._build_type if not is_multi_configuration( self._generator) else None try: # This is only defined in the cache, not in the local flow install_prefix = self._conanfile.package_folder.replace("\\", "/") except AttributeError: # FIXME: In the local flow, we don't know the package_folder install_prefix = None set_libcxx, glibcxx = self._get_libcxx() context = { "configuration_types_definitions": self.definitions.configuration_types, "build_type": build_type, "generator_platform": self._generator_platform, "toolset": self._toolset, "definitions": self.definitions, "cmake_prefix_path": self._cmake_prefix_path, "cmake_module_path": self._cmake_module_path, "fpic": self._fpic, "set_rpath": self._set_rpath, "set_std": self._set_std, "set_libcxx": set_libcxx, "glibcxx": glibcxx, "install_prefix": install_prefix } t = Template(self._template_toolchain) content = t.render( conan_project_include_cmake=conan_project_include_cmake, cmake_macros_and_functions="\n".join([ CMakeCommonMacros.conan_message, CMakeCommonMacros.conan_get_policy, CMakeCommonMacros.conan_set_rpath, CMakeCommonMacros.conan_set_std, ]), **context) save(self.filename, content)
def __init__(self, conanfile, generator=None, generator_platform=None, build_type=None, toolset=None, parallel=True): super(CMakeGenericToolchain, self).__init__(conanfile) self.fpic = self._deduce_fpic() self.vs_static_runtime = self._deduce_vs_static_runtime() self.parallel = parallel self.generator = generator or get_generator(self._conanfile) self.generator_platform = (generator_platform or get_generator_platform( self._conanfile.settings, self.generator)) self.toolset = toolset or get_toolset(self._conanfile.settings, self.generator) if (self.generator is not None and "Ninja" in self.generator and "Visual" in self._conanfile.settings.compiler): self.compiler = "cl" else: self.compiler = None # compiler defined by default try: self._build_shared_libs = "ON" if self._conanfile.options.shared else "OFF" except ConanException: self._build_shared_libs = None self.set_libcxx, self.glibcxx = self._get_libcxx() self.parallel = None if parallel: if self.generator and "Visual Studio" in self.generator: self.parallel = "/MP%s" % cpu_count( output=self._conanfile.output) self.cppstd, self.cppstd_extensions = self._cppstd() self.skip_rpath = True if self._conanfile.settings.get_safe( "os") == "Macos" else False self.architecture = self._get_architecture() # TODO: I would want to have here the path to the compiler too build_type = build_type or self._conanfile.settings.get_safe( "build_type") self.build_type = build_type if not is_multi_configuration( self.generator) else None
def __init__(self, conanfile, generator=None, build_folder=None, parallel=True, msbuild_verbosity="minimal"): _validate_recipe(conanfile) # assert generator is None, "'generator' is handled by the toolchain" self._generator = generator or get_generator(conanfile) self._is_multiconfiguration = is_multi_configuration(self._generator) # Store a reference to useful data self._conanfile = conanfile self._parallel = parallel self._msbuild_verbosity = msbuild_verbosity self._build_folder = build_folder self._cmake_program = "cmake" # Path to CMake should be handled by environment
def is_multi_configuration(self): return is_multi_configuration(self.generator)