Пример #1
0
 def build(self):
     cmake = CMake(self)
     cmake.configure()
     cmake.build()
     if self.options.run_tests:
         with tools.run_environment(self):
             cmake.test(output_on_failure=True)
Пример #2
0
 def build(self):
     cmake = CMake(self)
     if self.should_configure:
         cmake.configure()
     if self.should_build:
         cmake.build()
     if self.should_install and self.develop:
         cmake.install()
Пример #3
0
 def _configure_cmake(self):
     cmake = CMake(self)
     if self._run_tests:
         # developer's mode (unit tests, examples, documentation, restrictive compilation warnings, ...)
         cmake.configure()
     else:
         # consumer's mode (library sources only)
         cmake.configure(source_folder="src")
     return cmake
Пример #4
0
 def build(self):
     cmake = CMake(self)
     with tools.run_environment(self):
         cmake.configure()
         cmake.build()
         if self.options.run_tests:
             with tools.environment_append({"CTEST_OUTPUT_ON_FAILURE":
                                            "1"}):
                 cmake.test()
Пример #5
0
 def build(self):
     cmake = CMake(self)
     cmake.configure()
     cmake.build()
     if not cross_building(self):
         pkg_config = PkgConfig(self, "wayland-scanner",
                                self.generators_folder)
         self.run('%s --version' % pkg_config.variables["wayland_scanner"],
                  env="conanrun")
def test_cmake_make_program(conanfile):
    save_toolchain_args({"cmake_generator": "MinGW Makefiles"},
                        generators_folder=conanfile.folders.generators_folder)

    def run(command):
        assert '-DCMAKE_MAKE_PROGRAM="C:/mymake.exe"' in command

    conanfile.run = run
    conanfile.conf.define("tools.gnu:make_program", "C:\\mymake.exe")
    with mock.patch("platform.system", mock.MagicMock(return_value='Windows')):
        cmake = CMake(conanfile)
        cmake.configure()
Пример #7
0
    def build(self):
        # TODO: Add some test for the cross-building scenario

        if not cross_building(self):
            calc_wsdl = os.path.join(os.path.dirname(__file__), 'calc.wsdl')
            self.output.info("Generating code from WSDL '{}'".format(calc_wsdl))
            self.run("wsdl2h -o calc.h {}".format(calc_wsdl), run_environment=True)
            self.run("soapcpp2 -j -CL -I{} calc.h".format(os.path.join(self.deps_cpp_info["gsoap"].rootpath, 'bin', 'import')), run_environment=True)

            cmake = CMake(self)
            cmake.configure()
            cmake.build()
Пример #8
0
def test_cmake_make_program(conanfile):
    def run(command):
        assert '-DCMAKE_MAKE_PROGRAM="C:/mymake.exe"' in command

    conanfile.run = run
    conanfile.conf.define("tools.gnu:make_program", "C:\\mymake.exe")

    with mock.patch("platform.system", mock.MagicMock(return_value='Windows')):
        write_cmake_presets(conanfile, "the_toolchain.cmake",
                            "MinGW Makefiles")

    cmake = CMake(conanfile)
    cmake.configure()
Пример #9
0
 def build(self):
     cmake = CMake(self)
     # Current dir is "test_package/build/<build_id>" and CMakeLists.txt is
     # in "test_package"
     cmake.configure()
     cmake.build()
Пример #10
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(build_script_folder=None if self._run_tests else "src")
     cmake.build()
     if self._run_tests:
         cmake.test()
Пример #11
0
 def _configure_cmake(self):
     cmake = CMake(self)
     cmake.configure()
     return cmake
Пример #12
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(source_folder="src")
     cmake.build()
Пример #13
0
 def build(self):
     apply_conandata_patches(self)
     cmake = CMake(self)
     cmake.configure()
     cmake.build()
Пример #14
0
 def build(self):
     cmake = CMake(self)
     cmake.configure()
Пример #15
0
class FluidSynthConan(ConanFile):
    name = "fluidsynth"
    description = "Software synthesizer based on the SoundFont 2 specifications"
    topics = ("fluidsynth", "soundfont", "midi", "synthesizer")
    url = "https://github.com/bincrafters/community"
    homepage = "http://www.fluidsynth.org"
    license = "LGPL-2.1-only"
    exports_sources = ["CMakeLists.txt"]
    generators = "pkg_config"
    settings = "os", "arch", "compiler", "build_type"

    options = {
        "shared": [True, False],
        "fPIC": [True, False],
        "floats": [True, False],
        "fpe-check": [True, False],
        "trap-on-check": [True, False],
        "portaudio": [True, False],
        "aufile": [True, False],
        "dbus": [True, False],
        "ipv6": [True, False],
        "jack": [True, False],
        "ladspa": [True, False],
        "libsndfile": [True, False],
        "midishare": [True, False],
        "opensles": [True, False],
        "oboe": [True, False],
        "network": [True, False],
        "oss": [True, False],
        "dsound": [True, False],
        "waveout": [True, False],
        "winmidi": [True, False],
        "sdl2": [True, False],
        "pkgconfig": [True, False],
        "pulseaudio": [True, False],
        "readline": [True, False],
        "threads": [True, False],
        "lash": [True, False],
        "alsa": [True, False],
        "systemd": [True, False],
        "coreaudio": [True, False],
        "coremidi": [True, False],
        "framework": [True, False],
    }
    default_options = {
        "shared": False,
        "fPIC": True,
        "floats": False,
        "fpe-check": False,
        "trap-on-check": False,
        "portaudio": False,
        "aufile": False,
        "dbus": False,
        "ipv6": True,
        "jack": False,
        "ladspa": False,
        "libsndfile": False,
        "midishare": False,
        "opensles": False,
        "oboe": False,
        "network": True,
        "oss": False,
        "dsound": True,
        "waveout": True,
        "winmidi": True,
        "sdl2": False,
        "pkgconfig": True,
        "pulseaudio": False,
        "readline": False,
        "threads": False,
        "lash": False,
        "alsa": False,
        "systemd": False,
        "coreaudio": True,
        "coremidi": True,
        "framework": False,
    }

    _source_subfolder = "source_subfolder"
    _build_subfolder = "build_subfolder"
    requires = "glib/2.70.1"
    _cmake = None

    def configure(self):
        if self.options.shared:
            del self.options.fPIC

        del self.settings.compiler.libcxx
        del self.settings.compiler.cppstd

    def build_requirements(self):
        if self.options.pkgconfig:
            self.build_requires("pkgconf/1.7.4")

    def config_options(self):
        if self.settings.os == "Windows":
            del self.options.fPIC

        if self.settings.os != "Windows":
            del self.options.dsound
            del self.options.waveout
            del self.options.winmidi

        if not self.settings.os in ["Linux", "FreeBSD"]:
            del self.options.lash
            del self.options.alsa

        if self.settings.os != "Linux":
            del self.options.systemd

        if self.settings.os != "Macos":
            del self.options.coreaudio
            del self.options.coremidi
            del self.options.framework

    def requirements(self):
        if self.options.get_safe("portaudio"):
            self.requires("portaudio/19.7.0@bincrafters/stable")
        if self.options.get_safe("sdl2"):
            self.requires("sdl2/2.0.16@bincrafters/stable")
        if self.options.get_safe("readline"):
            self.requires("readline/8.0")

    def source(self):
        tools.get(**self.conan_data["sources"][self.version],
                  strip_root=True,
                  destination=self._source_subfolder)

    def generate(self):
        tc = CMakeToolchain(self)
        tc.variables["enable-debug"] = self.settings.build_type
        tc.variables["enable-tests"] = False
        tc.variables[
            "LIB_INSTALL_DIR"] = "lib"  # https://github.com/FluidSynth/fluidsynth/issues/476
        tc.variables["BUILD_SHARED_LIBS"] = self.options.shared

        for o in [
                "floats", "fpe-check", "trap-on-check", "portaudio", "aufile",
                "dbus", "ipv6", "jack", "ladspa", "libsndfile", "midishare",
                "opensles", "oboe", "network", "oss", "dsound", "waveout",
                "winmidi", "sdl2", "pkgconfig", "pulseaudio", "readline",
                "threads", "lash", "alsa", "systemd", "coreaudio", "coremidi",
                "framework"
        ]:
            tc.variables["enable-{}".format(o)] = self.options.get_safe(o)
        tc.generate()

        cmake = CMakeDeps(self)
        cmake.generate()

    def _configure_cmake(self):
        if self._cmake:
            return self._cmake
        self._cmake = CMake(self)

        self._cmake.configure(build_script_folder=self._source_subfolder)
        return self._cmake

    def build(self):
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "CMakeLists.txt"),
            "find_package ( OpenMP QUIET )",
            "#find_package ( OpenMP QUIET )",
        )
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "src", "CMakeLists.txt"),
            "${GLIB_LIBRARIES}",
            "${GLIB_LINK_LIBRARIES}",
        )
        with tools.environment_append({"PKG_CONFIG_PATH":
                                       self.install_folder}):
            cmake = self._configure_cmake()
            cmake.build()

    def package(self):
        self.copy(pattern="LICENSE",
                  dst="licenses",
                  src=self._source_subfolder)
        with tools.environment_append({"PKG_CONFIG_PATH":
                                       self.install_folder}):
            cmake = self._configure_cmake()
            cmake.install()
        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
        tools.rmdir(os.path.join(self.package_folder, "bin", "pkgconfig"))
        tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"),
                                   "msvcp*.dll")
        tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"),
                                   "vcruntime*.dll")
        tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"),
                                   "concrt*.dll")

    def package_info(self):
        bindir = os.path.join(self.package_folder, "bin")
        self.output.info(
            "Appending PATH environment variable: {}".format(bindir))
        self.env_info.PATH.append(bindir)

        if self.settings.compiler == "Visual Studio":
            self.cpp_info.libs = [
                "fluidsynth" if self.options.shared else "libfluidsynth"
            ]
        else:
            self.cpp_info.libs = ["fluidsynth"]
        if self.settings.os == "Macos":
            self.cpp_info.frameworks.append("Foundation")
            if self.options.coreaudio:
                self.cpp_info.frameworks.extend(
                    ["CoreAudio", "AudioToolbox", "CoreServices"])
            if self.options.coremidi:
                self.cpp_info.frameworks.append("CoreMidi")
            if self.options.framework:
                self.cpp_info.frameworks.append("FluidSynth")
        if self.settings.os == "Windows":
            if self.options.network:
                self.cpp_info.system_libs.append("ws2_32")
            if self.options.dsound:
                self.cpp_info.system_libs.append("dsound")
            if self.options.winmidi:
                self.cpp_info.system_libs.append("winmm")
            self.cpp_info.system_libs.append("ksuser")
        if self.settings.os in ["Linux", "FreeBSD"]:
            self.cpp_info.system_libs.append("m")
Пример #16
0
 def package(self):
     self.copy("LICENSE.txt", dst="licenses")
     self.copy("NOTICE.txt", dst="licenses")
     cmake = CMake(self)
     cmake.configure()
     cmake.install()
Пример #17
0
 def package(self):
     self.copy(pattern="LICENSE.md", dst="licenses")
     cmake = CMake(self)
     cmake.configure(source_folder=None if self._run_tests else "src")
     cmake.install()
Пример #18
0
 def build(self):
     cmake = CMake(self)
     cmake.verbose = True
     cmake.configure()
     cmake.build()
Пример #19
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(build_script_folder=self._source_subfolder)
     cmake.build()
Пример #20
0
 def build(self):
     cmake = CMake(self)
     cmake.configure()
     cmake.build()
     self.run(f"ctest -C {self.settings.build_type} --output-on-failure")
Пример #21
0
class UnitsConan(ConanFile):
    name = "mp-units"
    homepage = "https://github.com/mpusz/units"
    description = "Physical Units library for C++"
    topics = ("units", "dimensions", "quantities", "dimensional-analysis",
              "physical-quantities", "physical-units", "system-of-units",
              "cpp23", "cpp20", "library", "quantity-manipulation")
    license = "MIT"
    url = "https://github.com/mpusz/units"
    settings = "os", "compiler", "build_type", "arch"
    requires = ("fmt/7.1.3", "gsl-lite/0.37.0")
    options = {
        "downcast_mode": ["off", "on", "auto"],
        "build_docs": [True, False]
    }
    default_options = {"downcast_mode": "on", "build_docs": True}
    exports = ["LICENSE.md"]
    exports_sources = [
        "docs/*", "src/*", "test/*", "cmake/*", "example/*", "CMakeLists.txt"
    ]
    # scm = {
    #     "type": "git",
    #     "url": "auto",
    #     "revision": "auto",
    #     "submodule": "recursive"
    # }
    generators = "cmake_paths"

    _cmake = None

    @property
    def _run_tests(self):
        return tools.get_env("CONAN_RUN_TESTS", False)

    def _configure_cmake(self):
        if not self._cmake:
            self._cmake = CMake(self)
            if self._run_tests:
                # developer's mode (unit tests, examples, documentation, restrictive compilation warnings, ...)
                self._cmake.configure()
            else:
                # consumer's mode (library sources only)
                self._cmake.configure(source_folder="src")
        return self._cmake

    def set_version(self):
        content = tools.load(
            os.path.join(self.recipe_folder, "src/CMakeLists.txt"))
        version = re.search(r"project\([^\)]+VERSION (\d+\.\d+\.\d+)[^\)]*\)",
                            content).group(1)
        self.version = version.strip()

    def validate(self):
        compiler = self.settings.compiler
        version = Version(self.settings.compiler.version)
        if compiler == "gcc":
            if version < "10.0":
                raise ConanInvalidConfiguration(
                    "mp-units requires at least g++-10")
        elif compiler == "clang":
            if version < "12":
                raise ConanInvalidConfiguration(
                    "mp-units requires at least clang++-12")
        elif compiler == "Visual Studio":
            if version < "16":
                raise ConanInvalidConfiguration(
                    "mp-units requires at least Visual Studio 16.9")
        else:
            raise ConanInvalidConfiguration("Unsupported compiler")
        check_min_cppstd(self, "20")

    # TODO Uncomment this when environment is supported in the Conan toolchain
    # def config_options(self):
    #     if not self._run_tests:
    #         # build_docs has sense only in a development or CI build
    #         del self.options.build_docs

    def requirements(self):
        compiler = self.settings.compiler
        if compiler == "clang" and compiler.libcxx == "libc++":
            self.requires("range-v3/0.11.0")

    def build_requirements(self):
        if self._run_tests:
            self.build_requires("catch2/2.13.4")
            self.build_requires("linear_algebra/0.7.0@public-conan/stable")
            if self.options.build_docs:
                self.build_requires("doxygen/1.8.20")

    def generate(self):
        tc = CMakeToolchain(self)
        tc.variables["UNITS_DOWNCAST_MODE"] = str(
            self.options.downcast_mode).upper()
        # if self._run_tests:  # TODO Enable this when environment is supported in the Conan toolchain
        tc.variables["UNITS_BUILD_DOCS"] = self.options.build_docs
        tc.generate()
        deps = CMakeDeps(self)
        deps.generate()

    def build(self):
        cmake = self._configure_cmake()
        cmake.build()
        if self._run_tests:
            cmake.test(output_on_failure=True)

    def package(self):
        self.copy(pattern="LICENSE.md", dst="licenses")
        cmake = self._configure_cmake()
        cmake.install()

    def package_id(self):
        self.info.header_only()

    def package_info(self):
        compiler = self.settings.compiler

        # core
        self.cpp_info.components["core"].requires = ["gsl-lite::gsl-lite"]
        if compiler == "Visual Studio":
            self.cpp_info.components["core"].cxxflags = ["/utf-8"]
        elif compiler == "clang" and compiler.libcxx == "libc++":
            self.cpp_info.components["core"].requires.append(
                "range-v3::range-v3")

        # rest
        self.cpp_info.components["core-io"].requires = ["core"]
        self.cpp_info.components["core-fmt"].requires = ["core", "fmt::fmt"]
        self.cpp_info.components["isq"].requires = ["core"]
        self.cpp_info.components["isq-natural"].requires = ["isq"]
        self.cpp_info.components["si"].requires = ["isq"]
        self.cpp_info.components["si-cgs"].requires = ["si"]
        self.cpp_info.components["si-fps"].requires = ["si"]
        self.cpp_info.components["si-iau"].requires = ["si"]
        self.cpp_info.components["si-imperial"].requires = ["si"]
        self.cpp_info.components["si-international"].requires = ["si"]
        self.cpp_info.components["si-typographic"].requires = ["si"]
        self.cpp_info.components["si-us"].requires = ["si"]
        self.cpp_info.components["isq-iec80000"].requires = ["si"]
        self.cpp_info.components["systems"].requires = [
            "isq", "isq-natural", "si", "si-cgs", "si-fps", "si-iau",
            "si-imperial", "si-international", "si-typographic", "si-us",
            "isq-iec80000"
        ]
Пример #22
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(build_script_folder="src")
     cmake.build()
Пример #23
0
 def build(self):
     cmake = CMake(self)
     cmake.configure()
     cmake.build()
     if self.settings.arch == "x86_64":
         cmake.test()
Пример #24
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(source_folder=None if self._run_tests else "src")
     cmake.build()
     if self._run_tests:
         cmake.test(output_on_failure=True)
Пример #25
0
class UnitsConan(ConanFile):
    name = "mp-units"
    version = get_version()
    homepage = "https://github.com/mpusz/units"
    description = "Physical Units library for C++"
    topics = ("units", "dimensions", "quantities", "dimensional-analysis",
              "physical-quantities", "physical-units", "system-of-units",
              "cpp23", "cpp20", "library", "quantity-manipulation")
    license = "MIT"
    url = "https://github.com/mpusz/units"
    settings = "compiler", "build_type"
    requires = ("fmt/7.1.3", "gsl-lite/0.37.0")
    options = {
        "downcast_mode": ["off", "on", "auto"],
        "build_docs": [True, False]
    }
    default_options = {"downcast_mode": "on", "build_docs": True}
    exports = ["LICENSE.md"]
    exports_sources = [
        "docs/*", "src/*", "test/*", "cmake/*", "example/*", "CMakeLists.txt"
    ]
    # scm = {
    #     "type": "git",
    #     "url": "auto",
    #     "revision": "auto",
    #     "submodule": "recursive"
    # }
    generators = "cmake_paths"

    _cmake = None

    @property
    def _run_tests(self):
        return tools.get_env("CONAN_RUN_TESTS", False)

    def _configure_cmake(self):
        if not self._cmake:
            self._cmake = CMake(self)
            if self._run_tests:
                # developer's mode (unit tests, examples, documentation, restrictive compilation warnings, ...)
                self._cmake.configure()
            else:
                # consumer's mode (library sources only)
                self._cmake.configure(source_folder="src")
        return self._cmake

    def validate(self):
        compiler = self.settings.compiler
        version = Version(self.settings.compiler.version)
        if compiler == "gcc":
            if version < "10.0":
                raise ConanInvalidConfiguration(
                    "mp-units requires at least g++-10")
        elif compiler == "Visual Studio":
            if version < "16":
                raise ConanInvalidConfiguration(
                    "mp-units requires at least Visual Studio 16.7")
        else:
            raise ConanInvalidConfiguration(
                "mp-units is supported only by gcc and Visual Studio so far")
        if compiler.get_safe("cppstd"):
            check_min_cppstd(self, "20")

    # TODO Uncomment this when environment is supported in the Conan toolchain
    # def config_options(self):
    #     if not self._run_tests:
    #         # build_docs has sense only in a development or CI build
    #         del self.options.build_docs

    def build_requirements(self):
        if self._run_tests:
            self.build_requires("catch2/2.13.4")
            self.build_requires("linear_algebra/0.7.0@public-conan/stable")
            if self.options.build_docs:
                self.build_requires("doxygen/1.8.20")

    def generate(self):
        tc = CMakeToolchain(self)
        tc.variables["UNITS_DOWNCAST_MODE"] = str(
            self.options.downcast_mode).upper()
        # if self._run_tests:  # TODO Enable this when environment is supported in the Conan toolchain
        tc.variables["UNITS_BUILD_DOCS"] = self.options.build_docs
        tc.generate()
        deps = CMakeDeps(self)
        deps.generate()

    def build(self):
        cmake = self._configure_cmake()
        cmake.build()
        if self._run_tests:
            cmake.test(output_on_failure=True)

    def package(self):
        self.copy(pattern="LICENSE.md", dst="licenses")
        cmake = self._configure_cmake()
        cmake.install()

    def package_id(self):
        self.info.header_only()

    def package_info(self):
        compiler = self.settings.compiler
        if compiler == "gcc":
            self.cpp_info.cxxflags = ["-Wno-non-template-friend"]
        elif compiler == "Visual Studio":
            self.cpp_info.cxxflags = ["/utf-8"]
Пример #26
0
 def build(self):
     cmake = CMake(self)
     cmake.configure("src")
     cmake.build()
Пример #27
0
 def build(self):
     cmake = CMake(self)
     cmake.configure()
     cmake.build()
     if self.options.build_tests:
         cmake.test(output_on_failure=True)