Exemple #1
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(defs={"BROTLI_BUNDLED_MODE":"ON"})
     pattern = "brotli%s"
     if not self.options.shared: pattern += "-static"
     for libname in ["dec", "enc"]:
         cmake.build(target=pattern % libname)
 def build(self):
     if self.settings.compiler == "Visual Studio" and self.settings.compiler.version != 12:
         self.settings.compiler.version = 12
     cmake = CMake(self)
     cmake.definitions["MYSQL_MAINTAINER_MODE"]=0
     cmake.configure(source_folder="mysqlclient", build_folder="mysqlclient/build")
     cmake.build()
Exemple #3
0
 def build(self):
     cmake = CMake(self)
     cmake.definitions["WITH_BOOST_IOSTREAMS"] = self.options.boost_iostreams
     cmake.definitions["WITH_CONAN"] = True
     cmake.configure()
     cmake.build()
     cmake.install()
Exemple #4
0
 def build(self):
     cmake=CMake(self)
     cmake.configure(defs={
         'PROJECT_VERSION': self.version
     })
     cmake.configure()
     cmake.build()
Exemple #5
0
 def package(self):
     cmake = CMake(self)
     cmake.definitions["PEGTL_BUILD_TESTS"] = "OFF"
     cmake.definitions["PEGTL_BUILD_EXAMPLES"] = "OFF"
     cmake.definitions["PEGTL_INSTALL_DOC_DIR"] = "licenses"
     cmake.configure()
     cmake.install()
Exemple #6
0
 def _configure_cmake(self):
     cmake = CMake(self)
     cmake.definitions['VERSION']=self.version
     cmake.definitions['PLATFORM']=self.options.platform
     cmake.definitions['SMP']=self.options.smp
     cmake.configure(source_folder=self.source_folder)
     return cmake
 def package(self):
     """Run CMake install"""
     cmake = CMake(self)
     cmake.definitions["NSSV_OPT_BUILD_TESTS"] = "OFF"
     cmake.definitions["NSSV_OPT_BUILD_EXAMPLES"] = "OFF"
     cmake.configure()
     cmake.install()
    def build(self):
        if self.settings.os == "Windows" and self.version == "master":
            raise ConanException("Trunk builds are not supported on Windows (cannot build directly from master git repository).")

        if self.settings.compiler == "Visual Studio":
            env = VisualStudioBuildEnvironment(self)
            with tools.environment_append(env.vars):
                version = min(12, int(self.settings.compiler.version.value))
                version = 10 if version == 11 else version
                cd_build = "cd %s\\%s\\build\\vc%s" % (self.conanfile_directory, self.source_directory, version)
                build_command = build_sln_command(self.settings, "glew.sln")
                vcvars = vcvars_command(self.settings)
                self.run("%s && %s && %s" % (vcvars, cd_build, build_command.replace("x86", "Win32")))
        else:
            if self.settings.os == "Windows":
                replace_in_file("%s/build/cmake/CMakeLists.txt" % self.source_directory, \
                                "if(WIN32 AND (NOT MSVC_VERSION LESS 1600)", \
                                "if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600)")

            if self.version == "master":
                self.run("make extensions")

            cmake = CMake(self)
            cmake.configure(source_dir="%s/build/cmake" % self.source_directory, defs={"BUILD_UTILS": "OFF"})
            cmake.build()
 def build(self):
     cmake = CMake(self)
     cmake.definitions['CMAKE_INSTALL_PREFIX'] = os.path.join(self.conanfile_directory, 'install')
     cmake.definitions['BUILD_TEST'] = False
     cmake.definitions['BUILD_SHARED'] = self.options.shared
     cmake.configure(build_dir='_build')
     cmake.build(target='install')
Exemple #10
0
    def build(self):
        cmake = CMake(self)
        # Configure which parts to build
        cmake.definitions["VCL_BUILD_BENCHMARKS"] = False
        cmake.definitions["VCL_BUILD_TESTS"] = False
        cmake.definitions["VCL_BUILD_TOOLS"] = False
        cmake.definitions["VCL_BUILD_EXAMPLES"] = False
        # Support multi-package configuration
        #cmake.definitions["CMAKE_DEBUG_POSTFIX"] = "_d"
        # Configure features
        cmake.definitions["VCL_VECTORIZE"] = str(self.options.vectorization)
        cmake.definitions["VCL_OPENGL_SUPPORT"] = True
        if self.settings.os != "Windows":
            cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.fPIC
        # Configure external targets
        cmake.definitions["vcl_ext_absl"] = "CONAN_PKG::abseil"
        cmake.definitions["vcl_ext_eigen"] = "CONAN_PKG::eigen"
        cmake.definitions["vcl_ext_fmt"] = "CONAN_PKG::fmt"
        cmake.definitions["vcl_ext_glew"] = "CONAN_PKG::glew"
        cmake.configure(source_dir=self.source_folder + "/src/")

        if cmake.is_multi_configuration:
            cmake.build(target="vcl_core",     args=["--config","Debug"])
            cmake.build(target="vcl_geometry", args=["--config","Debug"])
            cmake.build(target="vcl_graphics", args=["--config","Debug"])
            cmake.build(target="vcl_math",     args=["--config","Debug"])
            cmake.build(target="vcl_core",     args=["--config","Release"])
            cmake.build(target="vcl_geometry", args=["--config","Release"])
            cmake.build(target="vcl_graphics", args=["--config","Release"])
            cmake.build(target="vcl_math",     args=["--config","Release"])
        else:
            cmake.build(target="vcl_core")
            cmake.build(target="vcl_geometry")
            cmake.build(target="vcl_graphics")
            cmake.build(target="vcl_math")
Exemple #11
0
 def build(self):
     cmake = CMake(self)
     cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = os.path.join(os.getcwd(), 'conan_paths.cmake')
     cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared
     cmake.configure()
     cmake.build()
     cmake.install()
Exemple #12
0
 def _configure_cmake(self):
     cmake = CMake(self)
     cmake.definitions["TAOPQ_BUILD_TESTS"] = False
     cmake.definitions["TAOPQ_INSTALL_DOC_DIR"] = "licenses"
     if self.settings.os == 'Windows' and self.settings.compiler == 'Visual Studio':
         cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = self.options.shared
     cmake.configure()
     return cmake
Exemple #13
0
    def package(self):
        cmake = CMake(self)
        cmake.definitions["BUILD_TESTING"] = "OFF"
        cmake.definitions["CATCH_INSTALL_DOCS"] = "OFF"
        cmake.definitions["CATCH_INSTALL_HELPERS"] = "ON"
        cmake.configure()
        cmake.install()

        self.copy(pattern="LICENSE.txt", dst="licenses")
Exemple #14
0
 def build(self):
     cmake = CMake(self)
     configure_args = {
         'args': ['-DUNIASSERT_TESTS=ON', ] if self.develop else None,
         'source_dir': self.source_subdir(),
     }
     cmake.configure(**configure_args)
     cmake.build()
     cmake.test()
Exemple #15
0
 def build(self):
     cmake = CMake(self)
     cmake.definitions["BUILD_SHARED_LIBS"] = "ON" if self.options.shared else "OFF"
     cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = "ON" if self.options.fpic else "OFF"
     cmake.definitions["CONAN_SYSTEM_INCLUDES"] = "ON"
     if os.path.exists(self.source_folder + "/sgp4/conanfile.py"):
         self.src_dir = self.source_folder + "/sgp4"
     cmake.configure(source_dir=self.src_dir, build_dir=".")
     cmake.build()
Exemple #16
0
 def configure_cmake(self):
     """Create CMake instance and execute configure step
     """
     cmake = CMake(self)
     cmake.definitions["FLATBUFFERS_BUILD_TESTS"] = False
     cmake.definitions["FLATBUFFERS_BUILD_SHAREDLIB"] = self.options.shared
     cmake.definitions["FLATBUFFERS_BUILD_FLATLIB"] = not self.options.shared
     cmake.configure()
     return cmake
Exemple #17
0
 def do_build(self):
     cmake = CMake(self)
     cmake.build_dir = "{staging_dir}/src".format(staging_dir=self.staging_dir)
     tools.untargz("procman-{v}.tar.gz".format(v=self.version), cmake.build_dir)
     cmake.configure(defs={
             "CMAKE_INSTALL_PREFIX": self.staging_dir,
             "CMAKE_INSTALL_LIBDIR": "lib"
         }, source_dir="procman-{v}".format(v=self.version))
     cmake.build(target="install")
Exemple #18
0
 def build(self):
     """Configure, build and install FlatBuffers using CMake.
     """
     self._inject_magic_lines()
     cmake = CMake(self)
     cmake.definitions["FLATBUFFERS_BUILD_TESTS"] = False
     cmake.definitions["FLATBUFFERS_BUILD_SHAREDLIB"] = self.options.shared
     cmake.configure()
     cmake.build()
     cmake.install()
Exemple #19
0
    def build(self):
	self.run("export PATH=$PATH:$PWD/../cmake/build/bin")
        cmake = CMake(self)
	
	# Not working?
	#cmake.definitions["CONAN_CMAKE_FIND_ROOT_PATH"] = "../cmake/build"
	
	cmake.verbose = True
        cmake.configure(source_folder="gflags")
        cmake.build()
Exemple #20
0
 def _configure_cmake(self):
     cmake = CMake(self)
     cmake.verbose = True
     cmake.definitions["CIVETWEB_ENABLE_SSL"] = self.options.enable_ssl
     cmake.definitions["CIVETWEB_ENABLE_WEBSOCKETS"] = self.options.enable_websockets
     cmake.definitions["CIVETWEB_ENABLE_IPV6"] = self.options.enable_ipv6
     cmake.definitions["CIVETWEB_ENABLE_CXX"] = self.options.enable_cxx
     cmake.definitions["CIVETWEB_BUILD_TESTING"] = False
     cmake.definitions["CIVETWEB_ENABLE_ASAN"] = False
     cmake.configure(build_dir="build_subfolder")
     return cmake
Exemple #21
0
    def package(self):
        cmake = CMake(self)
        cmake.definitions["RANGE_V3_TESTS"] = "OFF"
        cmake.definitions["RANGE_V3_EXAMPLES"] = "OFF"
        cmake.definitions["RANGE_V3_PERF"] = "OFF"
        cmake.definitions["RANGE_V3_DOCS"] = "OFF"
        cmake.definitions["RANGE_V3_HEADER_CHECKS"] = "OFF"
        cmake.configure()
        cmake.install()

        self.copy("LICENSE.txt", dst="licenses", ignore_case=True, keep_path=False)
Exemple #22
0
 def _configure_cmake(self):
     cmake = CMake(self)
     cmake.definitions["FRUIT_IS_BEING_BUILT_BY_CONAN"] = "YES"
     cmake.definitions["BUILD_SHARED_LIBS"] = "YES" if self.options.shared else "NO"
     if self.options.use_boost:
         if self.settings.os == "Windows":
             cmake.definitions["BOOST_DIR"] = "."
     else:
         cmake.definitions["FRUIT_USES_BOOST"] = "NO"
     if self.settings.os == "Windows":
         cmake.definitions["FRUIT_TESTS_USE_PRECOMPILED_HEADERS"] = "NO"
     cmake.definitions["CMAKE_BUILD_TYPE"] = self.settings.build_type
     cmake.configure(source_folder=self._source_subfolder)
     return cmake
Exemple #23
0
    def _configure_cmake(self):
        cmake = CMake(self)
        defs = {
            'BUILD_SHARED_LIBS': False,
            'CMAKE_BUILD_TYPE': self.settings.build_type,
            'BUILD_TESTS': True,
            'BUILD_VIEWER': self.options.viewer,
            'BUILD_TOOLS': self.options.tools,
            'TESTS_NODATA': not self.options.test_data,
            'USE_CONAN': True,
            'BOOST_STATIC': not self.options['boost'].shared,
        }

        cmake.configure(defs=defs)
        return cmake
Exemple #24
0
    def build(self):
        os.mkdir("build")
        tools.replace_in_file("CMakeLists.txt", "project(blosc)", '''project(blosc)
            include(${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake)
            conan_basic_setup(NO_OUTPUT_DIRS)''')
        cmake = CMake(self)
        cmake.definitions["BUILD_TESTS"] = "ON" if self.run_tests else "OFF"
        cmake.definitions["BUILD_BENCHMARKS"] = "ON" if self.run_tests else "OFF"
        cmake.definitions["BUILD_SHARED"] = "ON" if (self.options.shared or self.run_tests) else "OFF"
        cmake.definitions["BUILD_STATIC"] = "OFF" if self.options.shared else "ON"
        cmake.configure(build_folder="build")
        cmake.build()

        if self.run_tests:
            self.output.warn("Running tests!!")
            self.launch_tests()
Exemple #25
0
    def build(self):
        cmake = CMake(self)
        if 'build_test' in os.environ or 'build_all' in os.environ:
            cmake.definitions['BUILD_TEST'] = "1"
        if 'build_server' in os.environ or 'build_all' in os.environ:
            cmake.definitions['BUILD_SERVER'] = "1"
        if 'create_package' in os.environ:
            cmake.definitions['CREATE_PACKAGE'] = "1"

        cmake.configure(source_folder='{}'.format(self.source_folder))
        cmake.build()
        cmake.install()
        if 'create_package' in os.environ:
            cmake.build(target="package")
        if 'create_package_debug' in os.environ:
            cmake.build(target="package_debug")
Exemple #26
0
    def _configure_cmake(self):
        cmake = CMake(self)

        cmake.definitions["BENCHMARK_ENABLE_TESTING"] = "OFF"
        cmake.definitions["BENCHMARK_ENABLE_GTEST_TESTS"] = "OFF"
        cmake.definitions["BENCHMARK_ENABLE_LTO"] = "ON" if self.options.enable_lto else "OFF"
        cmake.definitions["BENCHMARK_ENABLE_EXCEPTIONS"] = "ON" if self.options.enable_exceptions else "OFF"

        # See https://github.com/google/benchmark/pull/638 for Windows 32 build explanation
        if self.settings.os != "Windows":
            cmake.definitions["BENCHMARK_BUILD_32_BITS"] = "ON" if "64" not in str(self.settings.arch) else "OFF"
            cmake.definitions["BENCHMARK_USE_LIBCXX"] = "ON" if (str(self.settings.compiler.libcxx) == "libc++") else "OFF"
        else:
            cmake.definitions["BENCHMARK_USE_LIBCXX"] = "OFF"

        cmake.configure(build_folder=self._build_subfolder)
        return cmake
Exemple #27
0
    def test(self):
        builder = b2.B2(self)
        builder.build_folder = os.path.join(self.build_folder, "base")
        builder.configure()
        builder.build()

        builder = b2.B2(self)
        builder.source_folder = os.path.join(self.source_folder, "pkgconfig")
        builder.build_folder = os.path.join(self.build_folder, "pkgconfig")
        builder.configure()
        builder.build()

        builder = CMake(self)
        builder.configure(
            source_folder=os.path.join(self.source_folder, "cmake"),
            build_folder=os.path.join(self.build_folder, "cmake"),
        )
        builder.build()
Exemple #28
0
 def build(self):
     """Build the package."""
     cmake = CMake(self)
     cmake.definitions["BUILD_TESTING"] = False
     cmake.definitions["USE_DBLPREC_AS_REAL"] = True
     cmake.configure(source_folder=".")
     cmake.build()
     print("***********(0.0)*************")
     try:
         # cmake.test()
         tests = False
         print(tests)
     except ConanException:
         raise
     finally:
         if os.path.isfile("TEST-cxxtest.xml"):
             with open("TEST-cxxtest.xml", "r") as f:
                 for line in f.readlines():
                     no_newline = line.strip('\n')
                     print(no_newline)
         print("***********(0.0)*************")
 def build(self):
     cmake = CMake(self, generator='Ninja')
     cmake.configure()
     cmake.build()
     cmake.test()  # If you dont have any tests this will fail!
class PistacheConan(ConanFile):
    name = "pistache"
    license = "Apache-2.0"
    homepage = "https://github.com/pistacheio/pistache"
    url = "https://github.com/conan-io/conan-center-index"
    topics = ("http", "rest", "framework", "networking")
    description = "Pistache is a modern and elegant HTTP and REST framework for C++"

    settings = "os", "arch", "compiler", "build_type"
    options = {
        "shared": [True, False],
        "fPIC": [True, False],
        "with_ssl": [True, False],
    }
    default_options = {
        "shared": False,
        "fPIC": True,
        "with_ssl": False,
    }

    generators = "cmake", "cmake_find_package"
    _cmake = None

    @property
    def _source_subfolder(self):
        return "source_subfolder"

    @property
    def _build_subfolder(self):
        return "build_subfolder"

    def export_sources(self):
        self.copy("CMakeLists.txt")
        for patch in self.conan_data.get("patches", {}).get(self.version, []):
            self.copy(patch["patch_file"])

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

    def requirements(self):
        self.requires("rapidjson/1.1.0")
        if self.options.with_ssl:
            self.requires("openssl/1.1.1q")

    def validate(self):
        compilers = {
            "gcc": "7",
            "clang": "6",
        }
        if self.settings.os != "Linux":
            raise ConanInvalidConfiguration(
                "Pistache is only support by Linux.")

        if self.settings.compiler == "clang":
            raise ConanInvalidConfiguration(
                "Clang support is broken. See pistacheio/pistache#835.")

        if self.settings.compiler.cppstd:
            tools.check_min_cppstd(self, 17)
        minimum_compiler = compilers.get(str(self.settings.compiler))
        if minimum_compiler:
            if tools.Version(
                    self.settings.compiler.version) < minimum_compiler:
                raise ConanInvalidConfiguration(
                    "Pistache requires c++17, which your compiler does not support."
                )
        else:
            self.output.warn(
                "Pistache requires c++17, but this compiler is unknown to this recipe. Assuming your compiler supports c++17."
            )

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

    def _configure_cmake(self):
        if self._cmake:
            return self._cmake
        self._cmake = CMake(self)
        self._cmake.definitions["PISTACHE_ENABLE_NETWORK_TESTS"] = False
        self._cmake.definitions["PISTACHE_USE_SSL"] = self.options.with_ssl
        # pistache requires explicit value for fPIC
        self._cmake.definitions[
            "CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe(
                "fPIC", True)
        self._cmake.configure(build_folder=self._build_subfolder)
        return self._cmake

    def build(self):
        for patch in self.conan_data.get("patches", {}).get(self.version, []):
            tools.patch(**patch)
        cmake = self._configure_cmake()
        cmake.build()

    def package(self):
        self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
        cmake = self._configure_cmake()
        cmake.install()
        tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
        if self.options.shared:
            tools.remove_files_by_mask(
                os.path.join(self.package_folder, "lib"), "*.a")

    def package_info(self):
        # TODO: Pistache does not use namespace
        # TODO: Pistache variables are CamelCase e.g Pistache_BUILD_DIRS
        self.cpp_info.filenames["cmake_find_package"] = "Pistache"
        self.cpp_info.filenames["cmake_find_package_multi"] = "Pistache"
        self.cpp_info.names["pkg_config"] = "libpistache"
        suffix = "_{}".format("shared" if self.options.shared else "static")
        self.cpp_info.components["libpistache"].names[
            "cmake_find_package"] = "pistache" + suffix
        self.cpp_info.components["libpistache"].names[
            "cmake_find_package_multi"] = "pistache" + suffix
        self.cpp_info.components["libpistache"].libs = tools.collect_libs(self)
        self.cpp_info.components["libpistache"].requires = [
            "rapidjson::rapidjson"
        ]
        if self.options.with_ssl:
            self.cpp_info.components["libpistache"].requires.append(
                "openssl::openssl")
            self.cpp_info.components["libpistache"].defines = [
                "PISTACHE_USE_SSL=1"
            ]
        if self.settings.os == "Linux":
            self.cpp_info.components["libpistache"].system_libs = ["pthread"]
Exemple #31
0
 def build(self):
     cmake = CMake(self)
     cmake.configure()
     cmake.build()
 def build(self):
     cmake = CMake(self)
     cmake.configure(source_dir=self.conanfile_directory, build_dir='.')
     cmake.build()
Exemple #33
0
class RedisPlusPlusConan(ConanFile):
    name = "redis-plus-plus"
    homepage = "https://github.com/sewenew/redis-plus-plus"
    description = "Redis client written in C++"
    topics = ("conan", "database", "redis", "client", "tls")
    url = "https://github.com/conan-io/conan-center-index"
    license = "Apache-2.0"
    exports_sources = ["CMakeLists.txt", "patches/**"]
    generators = "cmake", "cmake_find_package_multi"
    settings = "os", "compiler", "build_type", "arch"
    options = {
        "shared": [True, False],
        "fPIC": [True, False],
        "with_tls": [True, False]
    }
    default_options = {"shared": False, "fPIC": True, "with_tls": False}

    _cmake = None

    @property
    def _source_subfolder(self):
        return "source_subfolder"

    @property
    def _build_subfolder(self):
        return "build_subfolder"

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

    def configure(self):
        if self.options.shared:
            del self.options.fPIC
        if self.settings.compiler.get_safe("cppstd"):
            tools.check_min_cppstd(self, 11)

    def requirements(self):
        self.requires("hiredis/1.0.0")

    def validate(self):
        if self.options.with_tls != self.options["hiredis"].with_ssl:
            raise ConanInvalidConfiguration(
                "with_tls must match hiredis.with_ssl option")

    def source(self):
        tools.get(**self.conan_data["sources"][self.version])
        extracted_dir = self.name + "-" + self.version
        os.rename(extracted_dir, self._source_subfolder)

    def _configure_cmake(self):
        if not self._cmake:
            self._cmake = CMake(self)
            self._cmake.definitions[
                "REDIS_PLUS_PLUS_USE_TLS"] = self.options.with_tls
            self._cmake.definitions["REDIS_PLUS_PLUS_BUILD_TEST"] = False
            self._cmake.definitions[
                "REDIS_PLUS_PLUS_BUILD_STATIC"] = not self.options.shared
            self._cmake.definitions[
                "REDIS_PLUS_PLUS_BUILD_SHARED"] = self.options.shared
            if tools.Version(self.version) >= "1.2.3":
                self._cmake.definitions[
                    "REDIS_PLUS_PLUS_BUILD_STATIC_WITH_PIC"] = self.options.shared
            self._cmake.configure(build_folder=self._build_subfolder)
        return self._cmake

    def _patch_sources(self):
        for patch in self.conan_data.get("patches", {}).get(self.version, []):
            tools.patch(**patch)
        if tools.Version(self.version) < "1.2.3":
            tools.replace_in_file(
                os.path.join(self._source_subfolder, "CMakeLists.txt"),
                "set_target_properties(${STATIC_LIB} PROPERTIES POSITION_INDEPENDENT_CODE ON)",
                "")

    def build(self):
        self._patch_sources()
        cmake = self._configure_cmake()
        cmake.build()

    def package(self):
        self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
        cmake = self._configure_cmake()
        cmake.install()
        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
        tools.rmdir(os.path.join(self.package_folder, "share"))

    def package_info(self):
        # Introduced in 1.2.3
        self.cpp_info.names["cmake_find_package"] = "redis++"
        self.cpp_info.names["cmake_find_package_multi"] = "redis++"
        self.cpp_info.names["pkg_config"] = "redis++"
        self.cpp_info.components["redis++lib"].names[
            "cmake_find_package"] = "redis++" + "_static" if not self.options.shared else ""
        self.cpp_info.components["redis++lib"].names[
            "cmake_find_package_multi"] = "redis++" + "_static" if not self.options.shared else ""

        suffix = "_static" if self.settings.os == "Windows" and not self.options.shared else ""
        self.cpp_info.components["redis++lib"].libs = ["redis++" + suffix]
        self.cpp_info.components["redis++lib"].requires = ["hiredis::hiredis"]
        if self.options.with_tls:
            self.cpp_info.components["redis++lib"].requires.append(
                "hiredis::hiredis_ssl")
        if self.settings.os in ["Linux", "FreeBSD"]:
            self.cpp_info.components["redis++lib"].system_libs.append(
                "pthread")
Exemple #34
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()
Exemple #35
0
 def build(self):
     cmake = CMake(self)
     cmake.configure()
     cmake.build()
Exemple #36
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(build_dir="./")
     cmake.build()
class Mosquitto(ConanFile):
    name = "mosquitto"
    license = "EPL-2.0"
    url = "https://github.com/conan-io/conan-center-index"
    homepage = "https://mosquitto.org"
    description = """Eclipse Mosquitto MQTT library, broker and more"""
    topics = ("MQTT", "IoT", "eclipse")
    settings = "os", "arch", "compiler", "build_type"
    options = {
        "shared": [True, False],
        "ssl": [True, False],
        "clients": [True, False],
        "broker": [True, False],
        "apps": [True, False],
        "cjson": [True, False],
        "build_cpp": [True, False],
        "websockets": [True, False],
    }
    default_options = {
        "shared": False,
        "ssl": True,
        "clients": False,
        "broker": False,
        "apps": False,
        "cjson":
        True,  # https://github.com/eclipse/mosquitto/commit/bbe0afbfbe7bb392361de41e275759ee4ef06b1c
        "build_cpp": True,
        "websockets": False,
    }
    exports_sources = ["CMakeLists.txt"]
    generators = "cmake", "cmake_find_package"
    _cmake = None

    @property
    def _source_subfolder(self):
        return "source_subfolder"

    @property
    def _build_subfolder(self):
        return "build_subfolder"

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

    def configure(self):
        if self.options.shared:
            del self.options.fPIC
        if not self.options.clients:
            del self.options.cjson
        if not self.options.broker:
            del self.options.websockets
        if not self.options.build_cpp:
            del self.settings.compiler.libcxx
            del self.settings.compiler.cppstd

    def requirements(self):
        if self.options.ssl:
            self.requires("openssl/1.1.1i")
        if self.options.get_safe("cjson"):
            self.requires("cjson/1.7.14")
        if self.options.get_safe("websockets"):
            self.requires("libwebsockets/4.1.6")

    def source(self):
        tools.get(**self.conan_data["sources"][self.version])
        extracted_dir = self.name.replace("-", ".") + "-" + self.version
        os.rename(extracted_dir, self._source_subfolder)

    def _configure_cmake(self):
        if self._cmake:
            return self._cmake
        self._cmake = CMake(self)
        self._cmake.definitions[
            "WITH_STATIC_LIBRARIES"] = not self.options.shared
        self._cmake.definitions["WITH_PIC"] = self.options.get_safe(
            "fPIC", False)
        self._cmake.definitions["WITH_TLS"] = self.options.ssl
        self._cmake.definitions["WITH_CLIENTS"] = self.options.clients
        if tools.Version(self.version) < "2.0.6":
            self._cmake.definitions[
                "CMAKE_DISABLE_FIND_PACKAGE_cJSON"] = not self.options.get_safe(
                    "cjson")
        else:
            self._cmake.definitions["WITH_CJSON"] = self.options.get_safe(
                "cjson")
        self._cmake.definitions["WITH_BROKER"] = self.options.broker
        self._cmake.definitions["WITH_APPS"] = self.options.apps
        self._cmake.definitions["WITH_PLUGINS"] = False
        self._cmake.definitions["WITH_LIB_CPP"] = self.options.build_cpp
        self._cmake.definitions[
            "WITH_THREADING"] = self.settings.compiler != "Visual Studio"
        self._cmake.definitions["WITH_WEBSOCKETS"] = self.options.get_safe(
            "websockets", False)
        self._cmake.definitions["STATIC_WEBSOCKETS"] = self.options.get_safe(
            "websockets", False) and not self.options["libwebsockets"].shared
        self._cmake.definitions["DOCUMENTATION"] = False
        self._cmake.definitions["CMAKE_INSTALL_SYSCONFDIR"] = os.path.join(
            self.package_folder, "res").replace("\\", "/")
        self._cmake.configure(build_folder=self._build_subfolder)
        return self._cmake

    def _patch_sources(self):
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "client", "CMakeLists.txt"),
            "static)", "static ${CONAN_LIBS})")
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "client", "CMakeLists.txt"),
            "quitto)", "quitto ${CONAN_LIBS})")
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "apps", "mosquitto_ctrl",
                         "CMakeLists.txt"), "static)", "static ${CONAN_LIBS})")
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "apps", "mosquitto_ctrl",
                         "CMakeLists.txt"), "quitto)", "quitto ${CONAN_LIBS})")
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "apps", "mosquitto_passwd",
                         "CMakeLists.txt"), "OPENSSL_LIBRARIES", "CONAN_LIBS")
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "apps", "mosquitto_ctrl",
                         "CMakeLists.txt"), "OPENSSL_LIBRARIES", "CONAN_LIBS")
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "src", "CMakeLists.txt"),
            "OPENSSL_LIBRARIES", "CONAN_LIBS")
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "lib", "CMakeLists.txt"),
            "OPENSSL_LIBRARIES", "CONAN_LIBS")
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "src", "CMakeLists.txt"),
            "MOSQ_LIBS", "CONAN_LIBS")
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "include", "mosquitto.h"),
            "__declspec(dllimport)", "")
        tools.replace_in_file(
            os.path.join(self._source_subfolder, "lib", "cpp",
                         "mosquittopp.h"), "__declspec(dllimport)", "")
        # dynlibs for apple mobile want code signatures and that will not work here
        # this would actually be the right patch for static builds also, but this would have other side effects, so
        if (self.settings.os in ["iOS", "watchOS", "tvOS"]):
            tools.replace_in_file(
                os.path.join(self._source_subfolder, "lib", "CMakeLists.txt"),
                "SHARED", "")
            tools.replace_in_file(
                os.path.join(self._source_subfolder, "lib", "cpp",
                             "CMakeLists.txt"), "SHARED", "")

    def build(self):
        self._patch_sources()
        cmake = self._configure_cmake()
        cmake.build()

    def package(self):
        self.copy("edl-v10", src=self._source_subfolder, dst="licenses")
        self.copy("epl-v20", src=self._source_subfolder, dst="licenses")
        self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses")
        cmake = self._configure_cmake()
        cmake.install()
        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
        tools.remove_files_by_mask(os.path.join(self.package_folder, "res"),
                                   "*.example")
        if not self.options.shared:
            tools.remove_files_by_mask(
                os.path.join(self.package_folder, "lib"), "*.so*")
            tools.remove_files_by_mask(
                os.path.join(self.package_folder, "lib"), "*.dylib")
            tools.remove_files_by_mask(
                os.path.join(self.package_folder, "bin"), "*.dll")
        elif self.options.shared and self.settings.compiler == "Visual Studio":
            self.copy("mosquitto.lib",
                      src=os.path.join(self._build_subfolder, "lib"),
                      dst="lib")
            if self.options.build_cpp:
                self.copy("mosquittopp.lib",
                          src=os.path.join(self._build_subfolder, "lib"),
                          dst="lib")

    def package_info(self):
        libsuffix = "" if self.options.shared else "_static"
        self.cpp_info.components["libmosquitto"].names[
            "pkg_config"] = "libmosquitto"
        self.cpp_info.components["libmosquitto"].libs = [
            "mosquitto" + libsuffix
        ]
        if self.options.ssl:
            self.cpp_info.components["libmosquitto"].requires = [
                "openssl::openssl"
            ]
        if self.settings.os == "Linux":
            self.cpp_info.components["libmosquitto"].system_libs = [
                "pthread", "m"
            ]
        elif self.settings.os == "Windows":
            self.cpp_info.components["libmosquitto"].system_libs = ["ws2_32"]

        if self.options.build_cpp:
            self.cpp_info.components["libmosquittopp"].names[
                "pkg_config"] = "libmosquittopp"
            self.cpp_info.components["libmosquittopp"].libs = [
                "mosquittopp" + libsuffix
            ]
            self.cpp_info.components["libmosquittopp"].requires = [
                "libmosquitto"
            ]
            if self.settings.os == "Linux":
                self.cpp_info.components["libmosquittopp"].system_libs = [
                    "pthread", "m"
                ]
            elif self.settings.os == "Windows":
                self.cpp_info.components["libmosquittopp"].system_libs = [
                    "ws2_32"
                ]

        if self.options.broker:
            self.cpp_info.components["broker"].libdirs = []
            self.cpp_info.components["broker"].include_dirs = []
            bin_path = os.path.join(self.package_folder, "bin")
            self.output.info(
                "Appending PATH env var with : {}".format(bin_path))
            self.env_info.PATH.append(bin_path)
            if self.options.websockets:
                self.cpp_info.components["broker"].requires.append(
                    "libwebsockets::libwebsockets")
            if self.settings.os in ("FreeBSD", "Linux"):
                self.cpp_info.components["broker"].system_libs = [
                    "pthread", "m"
                ]
            elif self.settings.os == "Windows":
                self.cpp_info.components["broker"].system_libs = ["ws2_32"]

        for option in ["apps", "clients"]:
            if self.options.get_safe(option):
                self.cpp_info.components[option].libdirs = []
                self.cpp_info.components[option].include_dirs = []
                bin_path = os.path.join(self.package_folder, "bin")
                self.output.info(
                    "Appending PATH env var with : {}".format(bin_path))
                self.env_info.PATH.append(bin_path)
                self.cpp_info.components[option].requires = [
                    "openssl::openssl", "libmosquitto"
                ]
                if self.options.cjson:
                    self.cpp_info.components[option].requires.append(
                        "cjson::cjson")
Exemple #38
0
class ProtobufConan(ConanFile):
    name = "protobuf"
    description = "Protocol Buffers - Google's data interchange format"
    topics = ("conan", "protobuf", "protocol-buffers", "protocol-compiler",
              "serialization", "rpc", "protocol-compiler")
    url = "https://github.com/conan-io/conan-center-index"
    homepage = "https://github.com/protocolbuffers/protobuf"
    license = "BSD-3-Clause"
    exports_sources = ["CMakeLists.txt", "patches/*"]
    generators = "cmake"
    short_paths = True
    settings = "os", "arch", "compiler", "build_type"
    options = {
        "shared": [True, False],
        "with_zlib": [True, False],
        "fPIC": [True, False],
        "lite": [True, False]
    }
    default_options = {
        "with_zlib": False,
        "shared": False,
        "fPIC": True,
        "lite": False
    }

    _cmake = None

    @property
    def _source_subfolder(self):
        return "source_subfolder"

    @property
    def _build_subfolder(self):
        return "build_subfolder"

    @property
    def _is_clang_x86(self):
        return self.settings.compiler == "clang" and self.settings.arch == "x86"

    def source(self):
        tools.get(**self.conan_data["sources"][self.version])
        extracted_folder = self.name + "-" + self.version
        os.rename(extracted_folder, self._source_subfolder)

    def configure(self):
        if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
            del self.options.fPIC
            compiler_version = Version(self.settings.compiler.version.value)
            if compiler_version < "14":
                raise ConanInvalidConfiguration(
                    "On Windows Protobuf can only be built with "
                    "Visual Studio 2015 or higher.")

    def requirements(self):
        if self.options.with_zlib:
            self.requires("zlib/1.2.11")

    @property
    def _cmake_install_base_path(self):
        return os.path.join("lib", "cmake", "protobuf")

    def _configure_cmake(self):
        if self._cmake:
            return self._cmake
        self._cmake = CMake(self)
        self._cmake.definitions[
            "CMAKE_INSTALL_CMAKEDIR"] = self._cmake_install_base_path.replace(
                "\\", "/")
        self._cmake.definitions["protobuf_BUILD_TESTS"] = False
        self._cmake.definitions["protobuf_WITH_ZLIB"] = self.options.with_zlib
        self._cmake.definitions[
            "protobuf_BUILD_PROTOC_BINARIES"] = not self.options.lite
        self._cmake.definitions[
            "protobuf_BUILD_PROTOBUF_LITE"] = self.options.lite
        if self.settings.compiler == "Visual Studio":
            self._cmake.definitions[
                "protobuf_MSVC_STATIC_RUNTIME"] = "MT" in self.settings.compiler.runtime
        self._cmake.configure(build_folder=self._build_subfolder)
        return self._cmake

    def build(self):
        for patch in self.conan_data["patches"][self.version]:
            tools.patch(**patch)
        cmake = self._configure_cmake()
        cmake.build()

    def package(self):
        self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
        cmake = self._configure_cmake()
        cmake.install()
        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))

    def package_info(self):
        self.cpp_info.libs = tools.collect_libs(self)
        self.cpp_info.libs.sort(reverse=True)

        if self.settings.os == "Linux":
            self.cpp_info.system_libs.append("pthread")
            if self._is_clang_x86 or "arm" in str(self.settings.arch):
                self.cpp_info.system_libs.append("atomic")

        if self.settings.os == "Windows":
            if self.options.shared:
                self.cpp_info.defines = ["PROTOBUF_USE_DLLS"]
        self.cpp_info.names["cmake_find_package"] = "Protobuf"
        self.cpp_info.names["cmake_find_package_multi"] = "Protobuf"
        self.cpp_info.builddirs = [
            self._cmake_install_base_path,
        ]
        self.cpp_info.build_modules = [
            os.path.join(self._cmake_install_base_path,
                         "protobuf-generate.cmake"),
            os.path.join(self._cmake_install_base_path,
                         "protobuf-module.cmake"),
            os.path.join(self._cmake_install_base_path,
                         "protobuf-options.cmake"),
        ]
        bindir = os.path.join(self.package_folder, "bin")
        self.output.info(
            "Appending PATH environment variable: {}".format(bindir))
        self.env_info.PATH.append(bindir)
Exemple #39
0
 def _configure_cmake(self):
     cmake = CMake(self)
     cmake.configure(build_folder=self._build_subfolder)
     return cmake
Exemple #40
0
class LibcurlConan(ConanFile):
    name = "libcurl"

    description = "command line tool and library for transferring data with URLs"
    topics = ("curl", "libcurl", "data-transfer")
    url = "https://github.com/conan-io/conan-center-index"
    homepage = "https://curl.haxx.se"
    license = "MIT"

    settings = "os", "arch", "compiler", "build_type"
    options = {
        "shared": [True, False],
        "fPIC": [True, False],
        "with_ssl": [False, "openssl", "wolfssl", "schannel", "darwinssl"],
        "with_file": [True, False],
        "with_ftp": [True, False],
        "with_http": [True, False],
        "with_ldap": [True, False],
        "with_rtsp": [True, False],
        "with_dict": [True, False],
        "with_telnet": [True, False],
        "with_tftp": [True, False],
        "with_pop3": [True, False],
        "with_imap": [True, False],
        "with_smb": [True, False],
        "with_smtp": [True, False],
        "with_gopher": [True, False],
        "with_mqtt": [True, False],
        "with_libssh2": [True, False],
        "with_libidn": [True, False],
        "with_librtmp": [True, False],
        "with_libmetalink": [True, False],
        "with_libpsl": [True, False],
        "with_largemaxwritesize": [True, False],
        "with_nghttp2": [True, False],
        "with_zlib": [True, False],
        "with_brotli": [True, False],
        "with_zstd": [True, False],
        "with_c_ares": [True, False],
        "with_proxy": [True, False],
        "with_crypto_auth": [True, False],
        "with_ntlm": [True, False],
        "with_ntlm_wb": [True, False],
        "with_cookies": [True, False],
        "with_ipv6": [True, False],
        "with_docs": [True, False],
        "with_verbose_debug": [True, False],
        "with_symbol_hiding": [True, False],
        "with_unix_sockets": [True, False],
    }
    default_options = {
        "shared": False,
        "fPIC": True,
        "with_ssl": "openssl",
        "with_dict": True,
        "with_file": True,
        "with_ftp": True,
        "with_gopher": True,
        "with_http": True,
        "with_imap": True,
        "with_ldap": False,
        "with_mqtt": True,
        "with_pop3": True,
        "with_rtsp": True,
        "with_smb": True,
        "with_smtp": True,
        "with_telnet": True,
        "with_tftp": True,
        "with_libssh2": False,
        "with_libidn": False,
        "with_librtmp": False,
        "with_libmetalink": False,
        "with_libpsl": False,
        "with_largemaxwritesize": False,
        "with_nghttp2": False,
        "with_zlib": True,
        "with_brotli": False,
        "with_zstd": False,
        "with_c_ares": False,
        "with_proxy": True,
        "with_crypto_auth": True,
        "with_ntlm": True,
        "with_ntlm_wb": True,
        "with_cookies": True,
        "with_ipv6": True,
        "with_docs": False,
        "with_verbose_debug": True,
        "with_symbol_hiding": False,
        "with_unix_sockets": True,
    }

    generators = "cmake", "cmake_find_package_multi", "pkg_config"
    _autotools = None
    _autotools_vars = None
    _cmake = None

    @property
    def _source_subfolder(self):
        return "source_subfolder"

    @property
    def _build_subfolder(self):
        return "build_subfolder"

    @property
    def _is_msvc(self):
        return str(self.settings.compiler) in ["Visual Studio", "msvc"]

    @property
    def _is_mingw(self):
        return self.settings.os == "Windows" and self.settings.compiler == "gcc"

    @property
    def _is_win_x_android(self):
        return self.settings.os == "Android" and tools.os_info.is_windows

    @property
    def _settings_build(self):
        return getattr(self, "settings_build", self.settings)

    @property
    def _is_using_cmake_build(self):
        return self._is_msvc or self._is_win_x_android

    @property
    def _has_zstd_option(self):
        return tools.Version(self.version) >= "7.72.0"

    @property
    def _has_metalink_option(self):
        # Support for metalink was removed in version 7.78.0 https://github.com/curl/curl/pull/7176
        return tools.Version(self.version) < "7.78.0" and not self._is_using_cmake_build

    def export_sources(self):
        self.copy("CMakeLists.txt")
        self.copy("lib_Makefile_add.am")
        for patch in self.conan_data.get("patches", {}).get(self.version, []):
            self.copy(patch["patch_file"])

    def config_options(self):
        if self.settings.os == "Windows":
            del self.options.fPIC
        if not self._has_zstd_option:
            del self.options.with_zstd
        if not self._has_metalink_option:
            del self.options.with_libmetalink
        # Default options
        self.options.with_ssl = "darwinssl" if tools.is_apple_os(self.settings.os) else "openssl"

    def configure(self):
        if self.options.shared:
            del self.options.fPIC
        del self.settings.compiler.libcxx
        del self.settings.compiler.cppstd

        # These options are not used in CMake build yet
        if self._is_using_cmake_build:
            if tools.Version(self.version) < "7.75.0":
                del self.options.with_libidn
            del self.options.with_libpsl

    def requirements(self):
        if self.options.with_ssl == "openssl":
            self.requires("openssl/1.1.1o")
        elif self.options.with_ssl == "wolfssl":
            self.requires("wolfssl/5.2.0")
        if self.options.with_nghttp2:
            self.requires("libnghttp2/1.47.0")
        if self.options.with_libssh2:
            self.requires("libssh2/1.10.0")
        if self.options.with_zlib:
            self.requires("zlib/1.2.12")
        if self.options.with_brotli:
            self.requires("brotli/1.0.9")
        if self.options.get_safe("with_zstd"):
            self.requires("zstd/1.5.2")
        if self.options.with_c_ares:
            self.requires("c-ares/1.18.1")

    def validate(self):
        if self.options.with_ssl == "schannel" and self.settings.os != "Windows":
            raise ConanInvalidConfiguration("schannel only suppported on Windows.")
        if self.options.with_ssl == "darwinssl" and not tools.is_apple_os(self.settings.os):
            raise ConanInvalidConfiguration("darwinssl only suppported on Apple like OS (Macos, iOS, watchOS or tvOS).")
        if self.options.with_ssl == "wolfssl" and self._is_using_cmake_build and tools.Version(self.version) < "7.70.0":
            raise ConanInvalidConfiguration("Before 7.70.0, libcurl has no wolfssl support for Visual Studio or \"Windows to Android cross compilation\"")
        if self.options.with_ssl == "openssl":
            if self.options.with_ntlm and self.options["openssl"].no_des:
                raise ConanInvalidConfiguration("option with_ntlm=True requires openssl:no_des=False")

    def build_requirements(self):
        if self._is_using_cmake_build:
            if self._is_win_x_android:
                self.build_requires("ninja/1.10.2")
        else:
            self.build_requires("libtool/2.4.6")
            self.build_requires("pkgconf/1.7.4")
            if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"):
                self.build_requires("msys2/cci.latest")

    def source(self):
        tools.get(**self.conan_data["sources"][self.version],
                  destination=self._source_subfolder, strip_root=True)
        tools.download("https://curl.haxx.se/ca/cacert.pem", "cacert.pem", verify=True)

    # TODO: remove imports once rpath of shared libs of libcurl dependencies fixed on macOS
    def imports(self):
        # Copy shared libraries for dependencies to fix DYLD_LIBRARY_PATH problems
        #
        # Configure script creates conftest that cannot execute without shared openssl binaries.
        # Ways to solve the problem:
        # 1. set *LD_LIBRARY_PATH (works with Linux with RunEnvironment
        #     but does not work on OS X 10.11 with SIP)
        # 2. copying dylib's to the build directory (fortunately works on OS X)
        if self.settings.os == "Macos":
            self.copy("*.dylib*", dst=self._source_subfolder, keep_path=False)

    def build(self):
        self._patch_sources()
        if self._is_using_cmake_build:
            self._build_with_cmake()
        else:
            self._build_with_autotools()

    def _patch_sources(self):
        for patch in self.conan_data.get("patches", {}).get(self.version, []):
            tools.patch(**patch)
        self._patch_misc_files()
        self._patch_autotools()
        self._patch_cmake()

    def _patch_misc_files(self):
        if self.options.with_largemaxwritesize:
            tools.replace_in_file(os.path.join(self._source_subfolder, "include", "curl", "curl.h"),
                                  "define CURL_MAX_WRITE_SIZE 16384",
                                  "define CURL_MAX_WRITE_SIZE 10485760")

        # https://github.com/curl/curl/issues/2835
        # for additional info, see this comment https://github.com/conan-io/conan-center-index/pull/1008#discussion_r386122685
        if self.settings.compiler == "apple-clang" and self.settings.compiler.version == "9.1":
            if self.options.with_ssl == "darwinssl":
                tools.replace_in_file(os.path.join(self._source_subfolder, "lib", "vtls", "sectransp.c"),
                                      "#define CURL_BUILD_MAC_10_13 MAC_OS_X_VERSION_MAX_ALLOWED >= 101300",
                                      "#define CURL_BUILD_MAC_10_13 0")

    def _patch_autotools(self):
        if self._is_using_cmake_build:
            return

        # Disable curl tool for these reasons:
        # - link errors if mingw shared or iOS/tvOS/watchOS
        # - it makes recipe consistent with CMake build where we don't build curl tool
        top_makefile = os.path.join(self._source_subfolder, "Makefile.am")
        tools.replace_in_file(top_makefile, "SUBDIRS = lib src", "SUBDIRS = lib")
        tools.replace_in_file(top_makefile, "include src/Makefile.inc", "")

        if self._is_mingw:
            # patch for zlib naming in mingw
            if self.options.with_zlib:
                configure_ac = os.path.join(self._source_subfolder, "configure.ac")
                zlib_name = self.deps_cpp_info["zlib"].libs[0]
                tools.replace_in_file(configure_ac,
                                      "AC_CHECK_LIB(z,",
                                      "AC_CHECK_LIB({},".format(zlib_name))
                tools.replace_in_file(configure_ac,
                                      "-lz ",
                                      "-l{} ".format(zlib_name))

            if self.options.shared:
                # patch for shared mingw build
                lib_makefile = os.path.join(self._source_subfolder, "lib", "Makefile.am")
                tools.replace_in_file(lib_makefile,
                                      "noinst_LTLIBRARIES = libcurlu.la",
                                      "")
                tools.replace_in_file(lib_makefile,
                                      "noinst_LTLIBRARIES =",
                                      "")
                tools.replace_in_file(lib_makefile,
                                      "lib_LTLIBRARIES = libcurl.la",
                                      "noinst_LTLIBRARIES = libcurl.la")
                # add directives to build dll
                # used only for native mingw-make
                if not tools.cross_building(self.settings):
                    added_content = tools.load("lib_Makefile_add.am")
                    tools.save(lib_makefile, added_content, append=True)

    def _patch_cmake(self):
        if not self._is_using_cmake_build:
            return
        # Custom findZstd.cmake file relies on pkg-config file, make sure that it's consumed on all platforms
        if self._has_zstd_option:
            tools.replace_in_file(os.path.join(self._source_subfolder, "CMake", "FindZstd.cmake"),
                                  "if(UNIX)", "if(TRUE)")
        # TODO: check this patch, it's suspicious
        tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
                              "include(CurlSymbolHiding)", "")

    def _get_configure_command_args(self):
        yes_no = lambda v: "yes" if v else "no"
        params = [
            "--with-libidn2={}".format(yes_no(self.options.with_libidn)),
            "--with-librtmp={}".format(yes_no(self.options.with_librtmp)),
            "--with-libpsl={}".format(yes_no(self.options.with_libpsl)),
            "--with-schannel={}".format(yes_no(self.options.with_ssl == "schannel")),
            "--with-secure-transport={}".format(yes_no(self.options.with_ssl == "darwinssl")),
            "--with-brotli={}".format(yes_no(self.options.with_brotli)),
            "--enable-shared={}".format(yes_no(self.options.shared)),
            "--enable-static={}".format(yes_no(not self.options.shared)),
            "--enable-dict={}".format(yes_no(self.options.with_dict)),
            "--enable-file={}".format(yes_no(self.options.with_file)),
            "--enable-ftp={}".format(yes_no(self.options.with_ftp)),
            "--enable-gopher={}".format(yes_no(self.options.with_gopher)),
            "--enable-http={}".format(yes_no(self.options.with_http)),
            "--enable-imap={}".format(yes_no(self.options.with_imap)),
            "--enable-ldap={}".format(yes_no(self.options.with_ldap)),
            "--enable-mqtt={}".format(yes_no(self.options.with_mqtt)),
            "--enable-pop3={}".format(yes_no(self.options.with_pop3)),
            "--enable-rtsp={}".format(yes_no(self.options.with_rtsp)),
            "--enable-smb={}".format(yes_no(self.options.with_smb)),
            "--enable-smtp={}".format(yes_no(self.options.with_smtp)),
            "--enable-telnet={}".format(yes_no(self.options.with_telnet)),
            "--enable-tftp={}".format(yes_no(self.options.with_tftp)),
            "--enable-debug={}".format(yes_no(self.settings.build_type == "Debug")),
            "--enable-ares={}".format(yes_no(self.options.with_c_ares)),
            "--enable-threaded-resolver={}".format(yes_no(self.options.with_c_ares)),
            "--enable-cookies={}".format(yes_no(self.options.with_cookies)),
            "--enable-ipv6={}".format(yes_no(self.options.with_ipv6)),
            "--enable-manual={}".format(yes_no(self.options.with_docs)),
            "--enable-verbose={}".format(yes_no(self.options.with_verbose_debug)),
            "--enable-symbol-hiding={}".format(yes_no(self.options.with_symbol_hiding)),
            "--enable-unix-sockets={}".format(yes_no(self.options.with_unix_sockets)),
        ]
        if self.options.with_ssl == "openssl":
            params.append("--with-ssl={}".format(tools.unix_path(self.deps_cpp_info["openssl"].rootpath)))
        else:
            params.append("--without-ssl")
        if self.options.with_ssl == "wolfssl":
            params.append("--with-wolfssl={}".format(tools.unix_path(self.deps_cpp_info["wolfssl"].rootpath)))
        else:
            params.append("--without-wolfssl")

        if self.options.with_libssh2:
            params.append("--with-libssh2={}".format(tools.unix_path(self.deps_cpp_info["libssh2"].rootpath)))
        else:
            params.append("--without-libssh2")

        if self.options.with_nghttp2:
            params.append("--with-nghttp2={}".format(tools.unix_path(self.deps_cpp_info["libnghttp2"].rootpath)))
        else:
            params.append("--without-nghttp2")

        if self.options.with_zlib:
            params.append("--with-zlib={}".format(tools.unix_path(self.deps_cpp_info["zlib"].rootpath)))
        else:
            params.append("--without-zlib")

        if self._has_zstd_option:
            params.append("--with-zstd={}".format(yes_no(self.options.with_zstd)))

        if self._has_metalink_option:
            params.append("--with-libmetalink={}".format(yes_no(self.options.with_libmetalink)))

        if not self.options.with_proxy:
            params.append("--disable-proxy")

        if not self.options.with_rtsp:
            params.append("--disable-rtsp")

        if not self.options.with_crypto_auth:
            params.append("--disable-crypto-auth") # also disables NTLM in versions of curl prior to 7.78.0

        # ntlm will default to enabled if any SSL options are enabled
        if not self.options.with_ntlm:
            if tools.Version(self.version) <= "7.77.0":
                params.append("--disable-crypto-auth")
            else:
                params.append("--disable-ntlm")

        if not self.options.with_ntlm_wb:
            params.append("--disable-ntlm-wb")

        # Cross building flags
        if tools.cross_building(self.settings):
            if self.settings.os == "Linux" and "arm" in self.settings.arch:
                params.append("--host=%s" % self._get_linux_arm_host())
            elif self.settings.os == "iOS":
                params.append("--enable-threaded-resolver")
                params.append("--disable-verbose")
            elif self.settings.os == "Android":
                pass # this just works, conan is great!

        return params

    def _get_linux_arm_host(self):
        arch = None
        if self.settings.os == "Linux":
            arch = "arm-linux-gnu"
            # aarch64 could be added by user
            if "aarch64" in self.settings.arch:
                arch = "aarch64-linux-gnu"
            elif "arm" in self.settings.arch and "hf" in self.settings.arch:
                arch = "arm-linux-gnueabihf"
            elif "arm" in self.settings.arch and self._arm_version(str(self.settings.arch)) > 4:
                arch = "arm-linux-gnueabi"
        return arch

    # TODO, this should be a inner fuction of _get_linux_arm_host since it is only used from there
    # it should not polute the class namespace, since there are iOS and Android arm aritectures also
    def _arm_version(self, arch):
        version = None
        match = re.match(r"arm\w*(\d)", arch)
        if match:
            version = int(match.group(1))
        return version

    def _build_with_autotools(self):
        with tools.chdir(self._source_subfolder):
            # autoreconf
            self.run("{} -fiv".format(tools.get_env("AUTORECONF") or "autoreconf"), win_bash=tools.os_info.is_windows, run_environment=True)

            # fix generated autotools files to have relocatable binaries
            if tools.is_apple_os(self.settings.os):
                tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name @rpath/")

            self.run("chmod +x configure")

            # run configure with *LD_LIBRARY_PATH env vars it allows to pick up shared openssl
            with tools.run_environment(self):
                autotools, autotools_vars = self._configure_autotools()
                autotools.make(vars=autotools_vars)

    def _configure_autotools_vars(self):
        autotools_vars = self._autotools.vars
        # tweaks for mingw
        if self._is_mingw:
            autotools_vars["RCFLAGS"] = "-O COFF"
            if self.settings.arch == "x86":
                autotools_vars["RCFLAGS"] += " --target=pe-i386"
            else:
                autotools_vars["RCFLAGS"] += " --target=pe-x86-64"
        return autotools_vars

    def _configure_autotools(self):
        if self._autotools and self._autotools_vars:
            return self._autotools, self._autotools_vars

        self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)

        if self.settings.os != "Windows":
            self._autotools.fpic = self.options.get_safe("fPIC", True)

        self._autotools_vars = self._configure_autotools_vars()

        # tweaks for mingw
        if self._is_mingw:
            self._autotools.defines.append("_AMD64_")

        if tools.cross_building(self) and tools.is_apple_os(self.settings.os):
            self._autotools.defines.extend(['HAVE_SOCKET', 'HAVE_FCNTL_O_NONBLOCK'])

        configure_args = self._get_configure_command_args()

        if self.settings.os == "iOS" and self.settings.arch == "x86_64":
            # please do not autodetect --build for the iOS simulator, thanks!
            self._autotools.configure(vars=self._autotools_vars, args=configure_args, build=False)
        else:
            self._autotools.configure(vars=self._autotools_vars, args=configure_args)

        return self._autotools, self._autotools_vars

    def _configure_cmake(self):
        if self._cmake:
            return self._cmake
        if self._is_win_x_android:
            self._cmake = CMake(self, generator="Ninja")
        else:
            self._cmake = CMake(self)
        self._cmake.definitions["BUILD_TESTING"] = False
        self._cmake.definitions["BUILD_CURL_EXE"] = False
        self._cmake.definitions["CURL_DISABLE_LDAP"] = not self.options.with_ldap
        self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared
        self._cmake.definitions["CURL_STATICLIB"] = not self.options.shared
        self._cmake.definitions["CMAKE_DEBUG_POSTFIX"] = ""
        if tools.Version(self.version) >= "7.81.0":
            self._cmake.definitions["CURL_USE_SCHANNEL"] = self.options.with_ssl == "schannel"
        elif tools.Version(self.version) >= "7.72.0":
            self._cmake.definitions["CMAKE_USE_SCHANNEL"] = self.options.with_ssl == "schannel"
        else:
            self._cmake.definitions["CMAKE_USE_WINSSL"] = self.options.with_ssl == "schannel"
        if tools.Version(self.version) >= "7.81.0":
            self._cmake.definitions["CURL_USE_OPENSSL"] = self.options.with_ssl == "openssl"
        else:
            self._cmake.definitions["CMAKE_USE_OPENSSL"] = self.options.with_ssl == "openssl"
        if tools.Version(self.version) >= "7.81.0":
            self._cmake.definitions["CURL_USE_WOLFSSL"] = self.options.with_ssl == "wolfssl"
        elif tools.Version(self.version) >= "7.70.0":
            self._cmake.definitions["CMAKE_USE_WOLFSSL"] = self.options.with_ssl == "wolfssl"
        self._cmake.definitions["USE_NGHTTP2"] = self.options.with_nghttp2
        self._cmake.definitions["CURL_ZLIB"] = self.options.with_zlib
        self._cmake.definitions["CURL_BROTLI"] = self.options.with_brotli
        if self._has_zstd_option:
            self._cmake.definitions["CURL_ZSTD"] = self.options.with_zstd
        if tools.Version(self.version) >= "7.81.0":
            self._cmake.definitions["CURL_USE_LIBSSH2"] = self.options.with_libssh2
        else:
            self._cmake.definitions["CMAKE_USE_LIBSSH2"] = self.options.with_libssh2
        self._cmake.definitions["ENABLE_ARES"] = self.options.with_c_ares
        self._cmake.definitions["CURL_DISABLE_PROXY"] = not self.options.with_proxy
        self._cmake.definitions["USE_LIBRTMP"] = self.options.with_librtmp
        if tools.Version(self.version) >= "7.75.0":
            self._cmake.definitions["USE_LIBIDN2"] = self.options.with_libidn
        self._cmake.definitions["CURL_DISABLE_RTSP"] = not self.options.with_rtsp
        self._cmake.definitions["CURL_DISABLE_CRYPTO_AUTH"] = not self.options.with_crypto_auth

        # Also disables NTLM_WB if set to false
        if not self.options.with_ntlm:
            if tools.Version(self.version) <= "7.77.0":
                self._cmake.definitions["CURL_DISABLE_CRYPTO_AUTH"] = True
            else:
                self._cmake.definitions["CURL_DISABLE_NTLM"] = True
        self._cmake.definitions["NTLM_WB_ENABLED"] = self.options.with_ntlm_wb

        self._cmake.configure(build_folder=self._build_subfolder)
        return self._cmake

    def _build_with_cmake(self):
        cmake = self._configure_cmake()
        cmake.build()

    def package(self):
        self.copy("COPYING", dst="licenses", src=self._source_subfolder)
        self.copy("cacert.pem", dst="res")
        if self._is_using_cmake_build:
            cmake = self._configure_cmake()
            cmake.install()
            tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
        else:
            with tools.run_environment(self):
                with tools.chdir(self._source_subfolder):
                    autotools, autotools_vars = self._configure_autotools()
                    autotools.install(vars=autotools_vars)
            tools.rmdir(os.path.join(self.package_folder, "share"))
            for la_file in glob.glob(os.path.join(self.package_folder, "lib", "*.la")):
                os.remove(la_file)
            if self._is_mingw and self.options.shared:
                # Handle only mingw libs
                self.copy(pattern="*.dll", dst="bin", keep_path=False)
                self.copy(pattern="*.dll.a", dst="lib", keep_path=False)
                self.copy(pattern="*.lib", dst="lib", keep_path=False)
        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))

    def package_info(self):
        self.cpp_info.set_property("cmake_file_name", "CURL")
        self.cpp_info.set_property("cmake_target_name", "CURL::libcurl")
        self.cpp_info.set_property("cmake_find_mode", "both")
        self.cpp_info.set_property("pkg_config_name", "libcurl")

        if self._is_msvc:
            self.cpp_info.components["curl"].libs = ["libcurl_imp"] if self.options.shared else ["libcurl"]
        else:
            self.cpp_info.components["curl"].libs = ["curl"]
            if self.settings.os in ["Linux", "FreeBSD"]:
                if self.options.with_libidn:
                    self.cpp_info.components["curl"].libs.append("idn")
                if self.options.with_librtmp:
                    self.cpp_info.components["curl"].libs.append("rtmp")

        if self.settings.os in ["Linux", "FreeBSD"]:
            self.cpp_info.components["curl"].system_libs = ["rt", "pthread"]
        elif self.settings.os == "Windows":
            # used on Windows for VS build, native and cross mingw build
            self.cpp_info.components["curl"].system_libs = ["ws2_32"]
            if self.options.with_ldap:
                self.cpp_info.components["curl"].system_libs.append("wldap32")
            if self.options.with_ssl == "schannel":
                self.cpp_info.components["curl"].system_libs.append("crypt32")
        elif tools.is_apple_os(self.settings.os):
            if tools.Version(self.version) >= "7.77.0":
                self.cpp_info.components["curl"].frameworks.append("SystemConfiguration")
            if self.options.with_ldap:
                self.cpp_info.components["curl"].system_libs.append("ldap")
            if self.options.with_ssl == "darwinssl":
                self.cpp_info.components["curl"].frameworks.extend(["CoreFoundation", "Security"])

        if self._is_mingw:
            # provide pthread for dependent packages
            self.cpp_info.components["curl"].cflags.append("-pthread")
            self.cpp_info.components["curl"].exelinkflags.append("-pthread")
            self.cpp_info.components["curl"].sharedlinkflags.append("-pthread")

        if not self.options.shared:
            self.cpp_info.components["curl"].defines.append("CURL_STATICLIB=1")

        if self.options.with_ssl == "openssl":
            self.cpp_info.components["curl"].requires.append("openssl::openssl")
        if self.options.with_ssl == "wolfssl":
            self.cpp_info.components["curl"].requires.append("wolfssl::wolfssl")
        if self.options.with_nghttp2:
            self.cpp_info.components["curl"].requires.append("libnghttp2::libnghttp2")
        if self.options.with_libssh2:
            self.cpp_info.components["curl"].requires.append("libssh2::libssh2")
        if self.options.with_zlib:
            self.cpp_info.components["curl"].requires.append("zlib::zlib")
        if self.options.with_brotli:
            self.cpp_info.components["curl"].requires.append("brotli::brotli")
        if self.options.get_safe("with_zstd"):
            self.cpp_info.components["curl"].requires.append("zstd::zstd")
        if self.options.with_c_ares:
            self.cpp_info.components["curl"].requires.append("c-ares::c-ares")

        # TODO: to remove in conan v2 once cmake_find_package* generators removed
        self.cpp_info.names["cmake_find_package"] = "CURL"
        self.cpp_info.names["cmake_find_package_multi"] = "CURL"
        self.cpp_info.components["curl"].names["cmake_find_package"] = "libcurl"
        self.cpp_info.components["curl"].names["cmake_find_package_multi"] = "libcurl"
        self.cpp_info.components["curl"].set_property("cmake_target_name", "CURL::libcurl")
        self.cpp_info.components["curl"].set_property("pkg_config_name", "libcurl")
 def build(self):
     cmake = CMake(self)
     cmake.configure(source_folder="ether")
     cmake.build()