示例#1
0
    def test_vs_generator(self):
        settings = MockSettings({"os": "Windows", "arch": "x86_64", "compiler": "Visual Studio"})
        conanfile = ConanFileMock()
        conanfile.settings = settings

        settings.values['compiler.version'] = '15'
        assert get_generator(conanfile) == 'Visual Studio 15 2017'

        settings.values['compiler.version'] = '15.9'
        assert get_generator(conanfile) == 'Visual Studio 15 2017'
示例#2
0
    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
示例#3
0
    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
示例#4
0
    def context(self):
        # build_type (Release, Debug, etc) is only defined for single-config generators
        generator = self._toolchain.generator or get_generator(self._conanfile)
        generator_platform = get_generator_platform(self._conanfile.settings,
                                                    generator)
        toolset = self._get_toolset(generator)
        # TODO: Check if really necessary now that conanvcvars is used
        if (generator is not None and "Ninja" in generator
                and "Visual" in self._conanfile.settings.compiler):
            compiler = "cl"
        else:
            compiler = None  # compiler defined by default

        build_type = self._conanfile.settings.get_safe("build_type")
        build_type = build_type if not is_multi_configuration(
            generator) else None
        return {
            "compiler": compiler,
            "toolset": toolset,
            "generator_platform": generator_platform,
            "build_type": build_type
        }