Example #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)
Example #2
0
    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()
Example #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()
Example #4
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()
Example #5
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)
Example #6
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
Example #7
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()
Example #8
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()
 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')
Example #10
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
Example #11
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()
Example #12
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")
Example #13
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
Example #14
0
 def build(self):
     cmake=CMake(self)
     cmake.configure(defs={
         'PROJECT_VERSION': self.version
     })
     cmake.configure()
     cmake.build()
Example #15
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
Example #16
0
 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()
Example #17
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()
Example #18
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()
Example #19
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()
Example #20
0
 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()
Example #21
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
Example #22
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
Example #23
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")
Example #24
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
Example #25
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()
Example #26
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)*************")
Example #27
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()
Example #28
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(build_dir="./")
     cmake.build()
Example #29
0
 def package(self):
     cmake = CMake(self.settings)
     self.run(f"cmake --build . --target install {cmake.build_config}")
    def _configure_cmake(self):
        if self._cmake:
            return self._cmake

        cmake = CMake(self)

        # - Before 2020.5, the shared lib is always built, but static libs might be built as shared
        #   with BUILD_SHARED_LIBS injection (which doesn't work due to symbols visibility, at least for msvc)
        # - From 2020.5, static and shared libs are fully controlled by upstream CMakeLists.txt
        if tools.Version(self.version) < "2020.5":
            cmake.definitions["BUILD_SHARED_LIBS"] = False

        # Required by the project's CMakeLists.txt
        cmake.definitions["SPIRV-Headers_SOURCE_DIR"] = self.deps_cpp_info[
            "spirv-headers"].rootpath.replace("\\", "/")

        # There are some switch( ) statements that are causing errors
        # need to turn this off
        cmake.definitions["SPIRV_WERROR"] = False

        cmake.definitions["SKIP_SPIRV_TOOLS_INSTALL"] = False
        cmake.definitions["SPIRV_LOG_DEBUG"] = False
        cmake.definitions["SPIRV_SKIP_TESTS"] = True
        cmake.definitions["SPIRV_CHECK_CONTEXT"] = False
        cmake.definitions["SPIRV_BUILD_FUZZER"] = False

        cmake.configure(build_folder=self._build_subfolder)
        self._cmake = cmake
        return self._cmake
Example #31
0
 def _configure_cmake(self):
     if self._cmake:
         return self._cmake
     self._cmake = CMake(self)
     self._cmake.configure(build_folder=self._build_subfolder)
     return self._cmake
Example #32
0
class UTConan(ConanFile):
    name = "boost-ext-ut"
    description = ("C++20 single header/single module, "
                   "macro-free micro Unit Testing Framework")
    topics = ("ut", "header-only", "unit-test", "test", "tdd", "bdd")
    url = "https://github.com/conan-io/conan-center-index"
    homepage = "https://boost-ext.github.io/ut/"
    license = "BSL-1.0"
    settings = "os", "compiler", "arch", "build_type"
    no_copy_source = True
    options = {
        "disable_module": [True, False],
    }
    default_options = {
        "disable_module": False,
    }
    _cmake = None

    @property
    def _minimum_cpp_standard(self):
        return 17 if self.settings.compiler in [
            "clang", "gcc"
        ] and tools.Version(self.version) <= "1.1.8" else 20

    @property
    def _minimum_compilers_version(self):
        return {
            "apple-clang":
            "11" if tools.Version(self.version) < "1.1.8" else "12",
            "clang": "9",
            "gcc": "9",
            "msvc": "19",
            "Visual Studio": "16",
        }

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

    def validate(self):
        if self.settings.compiler.get_safe("cppstd"):
            tools.check_min_cppstd(self, self._minimum_cpp_standard)
        if tools.Version(
                self.version) <= "1.1.8" and self.settings.compiler in [
                    "msvc", "Visual Studio"
                ]:
            raise ConanInvalidConfiguration(
                "{} version 1.1.8 may not be built with MSVC. "
                "Please use at least version 1.1.9 with MSVC.")
        min_version = self._minimum_compilers_version.get(
            str(self.settings.compiler))
        if not min_version:
            self.output.warn("{} recipe lacks information about the {} "
                             "compiler support.".format(
                                 self.name, self.settings.compiler))
        else:
            if tools.Version(self.settings.compiler.version) < min_version:
                raise ConanInvalidConfiguration(
                    "{} requires C++{} support. "
                    "The current compiler {} {} does not support it.".format(
                        self.name, self._minimum_cpp_standard,
                        self.settings.compiler,
                        self.settings.compiler.version))

    def config_options(self):
        if tools.Version(self.version) <= "1.1.8":
            del self.options.disable_module

    def configure(self):
        if self.settings.compiler in ["msvc", "Visual Studio"]:
            if "disable_module" in self.options.values:
                self.options.disable_module = True

    def source(self):
        tools.get(**self.conan_data["sources"][self.version], strip_root=True)
        for patch in self.conan_data.get("patches", {}).get(self.version, []):
            tools.patch(**patch)

    def _configure_cmake(self):
        if self._cmake:
            return self._cmake
        self._cmake = CMake(self)
        self._cmake.definitions["BOOST_UT_BUILD_BENCHMARKS"] = False
        self._cmake.definitions["BOOST_UT_BUILD_EXAMPLES"] = False
        self._cmake.definitions["BOOST_UT_BUILD_TESTS"] = False
        self._cmake.definitions["PROJECT_DISABLE_VERSION_SUFFIX"] = True
        disable_module = self.options.get_safe("disable_module")
        if disable_module:
            self._cmake.definitions["BOOST_UT_DISABLE_MODULE"] = disable_module
        self._cmake.configure()
        return self._cmake

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

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

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

    def package_info(self):
        self.cpp_info.set_property("cmake_file_name", "ut")
        self.cpp_info.set_property("cmake_target_name", "boost::ut")

        self.cpp_info.names["cmake_find_package"] = "boost"
        self.cpp_info.names["cmake_find_package_multi"] = "boost"
        self.cpp_info.filenames["cmake_find_package"] = "ut"
        self.cpp_info.filenames["cmake_find_package_multi"] = "ut"
        self.cpp_info.components["ut"].names["cmake_find_package"] = "ut"
        self.cpp_info.components["ut"].names["cmake_find_package_multi"] = "ut"

        if tools.Version(self.version) > "1.1.8":
            self.cpp_info.components["ut"].includedirs = [
                os.path.join("include", "ut-" + self.version, "include")
            ]

        if self.options.get_safe("disable_module"):
            self.cpp_info.components["ut"].defines = [
                "BOOST_UT_DISABLE_MODULE=1"
            ]
Example #33
0
 def configure_cmake(self):
     cmake = CMake(self)
     cmake.definitions['GEOGRAPHICLIB_LIB_TYPE'] = 'SHARED' if self.options.shared else 'STATIC'
     cmake.configure(build_folder=self.build_subfolder)
     return cmake
class Open62541Conan(ConanFile):
    name = "open62541"
    license = "MPLv2"
    exports_sources = ["CMakeLists.txt", "patches/**"]
    exports = "submoduledata.yml"
    homepage = "https://open62541.org/"
    url = "https://github.com/conan-io/conan-center-index"
    description = "open62541 is an open source and free implementation of OPC UA (OPC Unified Architecture) written in the common subset of the C99 and C++98 languages. The library is usable with all major compilers and provides the necessary tools to implement dedicated OPC UA clients and servers, or to integrate OPC UA-based communication into existing applications. open62541 library is platform independent. All platform-specific functionality is implemented via exchangeable plugins. Plugin implementations are provided for the major operating systems."
    topics = ("OPC UA", "open62541", "sdk", "server/client", "c", "iec-62541",
              "industrial automation", "tsn", "time sensetive networks",
              "publish-subscirbe", "pubsub")
    settings = "os", "compiler", "build_type", "arch"
    options = {
        "fPIC": [True, False],
        "shared": [True, False],
        "historize": [True, False, "Experimental"],
        "logging_level":
        ["Fatal", "Error", "Warning", "Info", "Debug", "Trace"],
        "subscription": [True, False, "With Events"],
        "methods": [True, False],
        "dynamic_nodes": [True, False],
        "single_header": [True, False],
        "multithreading": ["None", "Threadsafe", "Internal threads"],
        "imutable_nodes": [True, False],
        "web_socket": [True, False],
        "discovery": [True, False, "With Multicast"],
        "discovery_semaphore": [True, False],
        "query": [True, False],
        "encryption": [False, "openssl", "mbedtls-apache", "mbedtls-gpl"],
        "json_support": [True, False],
        "pub_sub": [False, "Simple", "Ethernet", "Ethernet_XDP"],
        "data_access": [True, False],
        "compiled_nodeset_descriptions": [True, False],
        "namespace_zero": ["MINIMAL", "REDUCED", "FULL"],
        "embedded_profile": [True, False],
        "typenames": [True, False],
        "hardening": [True, False],
        "cpp_compatible": [True, False],
        "readable_statuscodes": [True, False]
    }
    default_options = {
        "fPIC": True,
        "shared": False,
        "historize": False,
        "logging_level": "Info",
        "subscription": True,
        "methods": True,
        "dynamic_nodes": True,
        "single_header": False,
        "multithreading": "None",
        "imutable_nodes": False,
        "web_socket": False,
        "discovery": True,
        "discovery_semaphore": True,
        "query": False,
        "encryption": False,
        "json_support": False,
        "pub_sub": False,
        "data_access": True,
        "compiled_nodeset_descriptions": True,
        "namespace_zero": "FULL",
        "embedded_profile": False,
        "typenames": True,
        "hardening": True,
        "cpp_compatible": False,
        "readable_statuscodes": True
    }
    generators = "cmake", "cmake_find_package"

    _cmake = None

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

    def requirements(self):
        if tools.Version(self.version) >= "1.1.0":
            if self.options.encryption == "mbedtls-apache":
                self.requires("mbedtls/2.16.3-apache")
            elif self.options.encryption == "mbedtls-gpl":
                self.requires("mbedtls/2.16.3-gpl")
            elif self.options.encryption == "openssl":
                self.requires("openssl/1.1.1j")

            if self.options.web_socket:
                self.requires("libwebsockets/4.1.6")
        else:
            if self.options.encryption == "mbedtls-apache":
                self.requires("mbedtls/2.16.3-apache")
            elif self.options.encryption == "mbedtls-gpl":
                self.requires("mbedtls/2.16.3-gpl")

        if self.options.discovery == "With Multicast":
            self.requires("pro-mdnsd/0.8.4")

    def _patch_sources(self):
        for patch in self.conan_data["patches"][self.version]:
            tools.patch(**patch)

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

        if not self.options.subscription:
            if self.options.subscription_events:
                raise ConanInvalidConfiguration(
                    "Open62541 requires subscription option")

        if not self.options.discovery:
            if self.options.discovery_semaphore:
                raise ConanInvalidConfiguration(
                    "Open62541 discovery sempahore option requires discovery option to be enabled"
                )

        if tools.Version(self.version) < "1.1.0":
            if self.options.encryption == "openssl":
                raise ConanInvalidConfiguration(
                    "Lower Open62541 versions than 1.1.0 do not support openssl"
                )

            if self.options.multithreading != "None":
                raise ConanInvalidConfiguration(
                    "Lower Open62541 versions than 1.1.0 do not fully support multithreading"
                )

            if self.options.web_socket:
                raise ConanInvalidConfiguration(
                    "Lower Open62541 versions than 1.1.0 do not fully support websockets"
                )

            if self.options.cpp_compatible:
                raise ConanInvalidConfiguration(
                    "Lower Open62541 versions than 1.1.0 are not cpp compatible due to -fpermisive flags"
                )

        # FIXME: correct clang versions condition
        max_clang_version = "8" if tools.Version(
            self.version) < "1.1.0" else "9"
        if self.settings.compiler == "clang" and tools.Version(
                self.settings.compiler.version) > max_clang_version:
            raise ConanInvalidConfiguration(
                "Open62541 supports Clang up to {} compiler version".format(
                    max_clang_version))

        if self.settings.compiler == "clang":
            if tools.Version(self.settings.compiler.version) < "5":
                raise ConanInvalidConfiguration(
                    "Older clang compiler version than 5.0 are not supported")

        if self.options.pub_sub != False and self.settings.os != "Linux":
            raise ConanInvalidConfiguration(
                "PubSub over Ethernet is not supported for your OS!")

        if self.options.web_socket:
            self.options["libwebsockets"].with_ssl = self.options.encryption

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

        if not self.options.cpp_compatible:
            del self.settings.compiler.cppstd
            del self.settings.compiler.libcxx

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

        submodule_filename = os.path.join(self.recipe_folder,
                                          'submoduledata.yml')
        with open(submodule_filename, 'r') as submodule_stream:
            submodules_data = yaml.load(submodule_stream)
            for path, submodule in submodules_data["submodules"][
                    self.version].items():
                filename = os.path.basename(submodule["url"])
                archive_name = submodule["archive_pattern"].format(
                    version=os.path.splitext(filename.replace('v', ''))[0])

                submodule_data = {
                    "url": submodule["url"],
                    "sha256": submodule["sha256"]
                }

                tools.get(**submodule_data)
                submodule_source = os.path.join(self._source_subfolder, path)
                tools.rmdir(submodule_source)
                os.rename(archive_name, submodule_source)

    def _get_log_level(self):
        return {
            "Fatal": "600",
            "Error": "500",
            "Warning": "400",
            "Info": "300",
            "Debug": "200",
            "Trace": "100",
            "PackageOption": "300"
        }.get(str(self.options.logging_level), "300")

    def _get_multithreading_option(self):
        return {
            "None": "0",
            "Threadsafe": "100",
            "Internal threads": "200"
        }.get(str(self.options.multithreading), "0")

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

        self._cmake = CMake(self)
        self._cmake.verbose = True

        version = tools.Version(self.version)
        self._cmake.definitions["OPEN62541_VER_MAJOR"] = version.major
        self._cmake.definitions["OPEN62541_VER_MINOR"] = version.minor
        self._cmake.definitions["OPEN62541_VER_PATCH"] = version.patch

        self._cmake.definitions["UA_LOGLEVEL"] = self._get_log_level()
        if self.options.subscription != False:
            self._cmake.definitions["UA_ENABLE_SUBSCRIPTIONS"] = True
            if self.options.subscription == "With Events":
                self._cmake.definitions[
                    "UA_ENABLE_SUBSCRIPTIONS_EVENTS"] = True
        self._cmake.definitions["UA_ENABLE_METHODCALLS"] = self.options.methods
        self._cmake.definitions[
            "UA_ENABLE_NODEMANAGEMENT"] = self.options.dynamic_nodes
        self._cmake.definitions[
            "UA_ENABLE_AMALGAMATION"] = self.options.single_header
        if version >= "1.1.3":
            self._cmake.definitions[
                "UA_MULTITHREADING"] = self._get_multithreading_option()
        self._cmake.definitions[
            "UA_ENABLE_IMMUTABLE_NODES"] = self.options.imutable_nodes
        self._cmake.definitions[
            "UA_ENABLE_WEBSOCKET_SERVER"] = self.options.web_socket
        if self.options.historize != False:
            self._cmake.definitions["UA_ENABLE_HISTORIZING"] = True
            if self.options.historize == "Experimental":
                self._cmake.definitions[
                    "UA_ENABLE_EXPERIMENTAL_HISTORIZING"] = True
        if self.options.discovery != False:
            self._cmake.definitions[
                "UA_ENABLE_DISCOVERY"] = self.options.discovery
            if self.options.discovery == "With Multicast":
                self._cmake.definitions["UA_ENABLE_DISCOVERY_MULTICAST"] = True
            self._cmake.definitions[
                "UA_ENABLE_DISCOVERY_SEMAPHORE"] = self.options.discovery_semaphore
        self._cmake.definitions["UA_ENABLE_QUERY"] = self.options.query
        if self.options.encryption != False:
            self._cmake.definitions["UA_ENABLE_ENCRYPTION"] = True
            if self.options.encryption == "openssl":
                self._cmake.definitions["UA_ENABLE_ENCRYPTION_OPENSSL"] = True
        self._cmake.definitions[
            "UA_ENABLE_JSON_ENCODING"] = self.options.json_support
        if self.options.pub_sub != False:
            self._cmake.definitions["UA_ENABLE_PUBSUB"] = True
            if self.settings.os == "Linux" and self.options.pub_sub == "Ethernet":
                self._cmake.definitions["UA_ENABLE_PUBSUB_ETH_UADP"] = True
            elif self.settings.os == "Linux" and self.options.pub_sub == "Ethernet_XDP":
                self._cmake.definitions["UA_ENABLE_PUBSUB_ETH_UADP_XDP"] = True
        self._cmake.definitions["UA_ENABLE_DA"] = self.options.data_access
        if self.options.compiled_nodeset_descriptions == True:
            self._cmake.definitions[
                "UA_ENABLE_NODESET_COMPILER_DESCRIPTIONS"] = self.options.compiled_nodeset_descriptions
            self._cmake.definitions["UA_NAMESPACE_ZERO"] = "FULL"
        else:
            self._cmake.definitions[
                "UA_NAMESPACE_ZERO"] = self.options.namespace_zero
        self._cmake.definitions[
            "UA_ENABLE_MICRO_EMB_DEV_PROFILE"] = self.options.embedded_profile
        self._cmake.definitions["UA_ENABLE_TYPENAMES"] = self.options.typenames
        self._cmake.definitions[
            "UA_ENABLE_STATUSCODE_DESCRIPTIONS"] = self.options.readable_statuscodes
        self._cmake.definitions["UA_ENABLE_HARDENING"] = self.options.hardening
        if self.settings.compiler == "Visual Studio" and self.options.shared == True:
            self._cmake.definitions["UA_MSVC_FORCE_STATIC_CRT"] = True
        self._cmake.definitions[
            "UA_COMPILE_AS_CXX"] = self.options.cpp_compatible

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

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

    def package(self):
        self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
        self.copy("LICENSE-CC0", dst="licenses", src=self._source_subfolder)
        cmake = self._configure_cmake()
        cmake.install()

        tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"),
                                   '*.pdb')
        tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"),
                                   '*.pdb')

        tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
        tools.rmdir(os.path.join(self.package_folder, "share"))
        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))

    def package_info(self):
        self.cpp_info.names["cmake_find_package"] = "open62541"
        self.cpp_info.names["cmake_find_package_multi"] = "open62541"
        self.cpp_info.libs = tools.collect_libs(self)
        self.cpp_info.includedirs = [
            "include", os.path.join("include", "plugin")
        ]

        if self.options.single_header:
            self.cpp_info.defines.append("UA_ENABLE_AMALGAMATION")
        if self.settings.os == "Windows":
            self.cpp_info.system_libs.append("ws2_32")
            self.cpp_info.includedirs.append(os.path.join("include", "win32"))
        else:
            self.cpp_info.includedirs.append(os.path.join("include", "posix"))
        self.cpp_info.builddirs = [
            "lib",
            os.path.join("lib", "cmake"),
            os.path.join("lib", "cmake", "open62541")
        ]
Example #35
0
 def build(self):
     cmake = CMake(self)
     # Current dir is "test_package/build/<build_id>" and CMakeLists.txt is in "test_package"
     cmake.configure(source_dir=self.conanfile_directory, build_dir="./")
     cmake.build()
Example #36
0
 def _configure_cmake(self):
     cmake = CMake(self)
     cmake.definitions["BUILD_TESTING"] = "OFF"
     cmake.definitions["HIPONY_ENUMERATE_AGGREGATES_ENABLED"] = self.options.aggregates
     cmake.configure()
     return cmake
Example #37
0
 def _configure_cmake(self):
     if self._cmake:
         return self._cmake
     self._cmake = CMake(self)
     self._cmake.configure()
     return self._cmake
Example #38
0
 def build(self):
     cmake = CMake(self)
     cmake.configure()
     cmake.build()
Example #39
0
 def _configure_cmake(self):
     cmake = CMake(self)
     cmake.configure(build_folder=self._build_subfolder)
     return cmake
Example #40
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(source_folder=self.source_folder)
     cmake.build()
class CppBenchmark(ConanFile):
    name = "cppbenchmark"
    license = "MIT"
    url = "https://github.com/conan-io/conan-center-index"
    homepage = "https://github.com/chronoxor/CppBenchmark"
    description = "Performance benchmark framework for C++ with nanoseconds measure precision."
    topics = ("conan", "utils", "library", "benchmark")
    settings = "os", "compiler", "build_type", "arch"
    options = {"fPIC": [True, False], "shared": [True, False]}
    default_options = {"fPIC": True, "shared": False}
    requires = ["hdrhistogram-c/0.11.1", "cpp-optparse/cci.20171104"]
    generators = "cmake"
    exports_sources = ["patches/**", "CMakeLists.txt"]
    _cmake = None

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

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

    @property
    def _compilers_minimum_version(self):
        return {
            "apple-clang": 10,
            "clang": 6,
            "gcc": 7,
            "Visual Studio": 16,
        }

    def _configure_cmake(self):
        if not self._cmake:
            self._cmake = CMake(self)
            self._cmake.definitions["CPPBENCHMARK_MODULE"] = "OFF"
            self._cmake.configure(build_folder=self._build_subfolder)
        return self._cmake

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

    def source(self):
        tools.get(**self.conan_data["sources"][self.version])
        extracted_dir = glob.glob("CppBenchmark-*")[0]
        os.rename(extracted_dir, self._source_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.cppstd:
            tools.check_min_cppstd(self, "17")

        minimum_version = self._compilers_minimum_version.get(
            str(self.settings.compiler), False)
        if minimum_version:
            if tools.Version(self.settings.compiler.version) < minimum_version:
                raise ConanInvalidConfiguration(
                    "cppbenchmark requires C++17, which your compiler does not support."
                )
        else:
            self.output.warn(
                "cppbenchmark requires C++17. Your compiler is unknown. Assuming it supports C++17."
            )

    def build(self):
        self._patch()

        cmake = self._configure_cmake()
        cmake.build()

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

    def package_info(self):
        self.cpp_info.libs = tools.collect_libs(self)
        if self.settings.os == "Linux":
            self.cpp_info.system_libs = ["pthread"]
    def _configure_cmake(self):
        if self._cmake:
            return self._cmake

        self._cmake = CMake(self)
        self._cmake.verbose = True

        version = tools.Version(self.version)
        self._cmake.definitions["OPEN62541_VER_MAJOR"] = version.major
        self._cmake.definitions["OPEN62541_VER_MINOR"] = version.minor
        self._cmake.definitions["OPEN62541_VER_PATCH"] = version.patch

        self._cmake.definitions["UA_LOGLEVEL"] = self._get_log_level()
        if self.options.subscription != False:
            self._cmake.definitions["UA_ENABLE_SUBSCRIPTIONS"] = True
            if self.options.subscription == "With Events":
                self._cmake.definitions[
                    "UA_ENABLE_SUBSCRIPTIONS_EVENTS"] = True
        self._cmake.definitions["UA_ENABLE_METHODCALLS"] = self.options.methods
        self._cmake.definitions[
            "UA_ENABLE_NODEMANAGEMENT"] = self.options.dynamic_nodes
        self._cmake.definitions[
            "UA_ENABLE_AMALGAMATION"] = self.options.single_header
        if version >= "1.1.3":
            self._cmake.definitions[
                "UA_MULTITHREADING"] = self._get_multithreading_option()
        self._cmake.definitions[
            "UA_ENABLE_IMMUTABLE_NODES"] = self.options.imutable_nodes
        self._cmake.definitions[
            "UA_ENABLE_WEBSOCKET_SERVER"] = self.options.web_socket
        if self.options.historize != False:
            self._cmake.definitions["UA_ENABLE_HISTORIZING"] = True
            if self.options.historize == "Experimental":
                self._cmake.definitions[
                    "UA_ENABLE_EXPERIMENTAL_HISTORIZING"] = True
        if self.options.discovery != False:
            self._cmake.definitions[
                "UA_ENABLE_DISCOVERY"] = self.options.discovery
            if self.options.discovery == "With Multicast":
                self._cmake.definitions["UA_ENABLE_DISCOVERY_MULTICAST"] = True
            self._cmake.definitions[
                "UA_ENABLE_DISCOVERY_SEMAPHORE"] = self.options.discovery_semaphore
        self._cmake.definitions["UA_ENABLE_QUERY"] = self.options.query
        if self.options.encryption != False:
            self._cmake.definitions["UA_ENABLE_ENCRYPTION"] = True
            if self.options.encryption == "openssl":
                self._cmake.definitions["UA_ENABLE_ENCRYPTION_OPENSSL"] = True
        self._cmake.definitions[
            "UA_ENABLE_JSON_ENCODING"] = self.options.json_support
        if self.options.pub_sub != False:
            self._cmake.definitions["UA_ENABLE_PUBSUB"] = True
            if self.settings.os == "Linux" and self.options.pub_sub == "Ethernet":
                self._cmake.definitions["UA_ENABLE_PUBSUB_ETH_UADP"] = True
            elif self.settings.os == "Linux" and self.options.pub_sub == "Ethernet_XDP":
                self._cmake.definitions["UA_ENABLE_PUBSUB_ETH_UADP_XDP"] = True
        self._cmake.definitions["UA_ENABLE_DA"] = self.options.data_access
        if self.options.compiled_nodeset_descriptions == True:
            self._cmake.definitions[
                "UA_ENABLE_NODESET_COMPILER_DESCRIPTIONS"] = self.options.compiled_nodeset_descriptions
            self._cmake.definitions["UA_NAMESPACE_ZERO"] = "FULL"
        else:
            self._cmake.definitions[
                "UA_NAMESPACE_ZERO"] = self.options.namespace_zero
        self._cmake.definitions[
            "UA_ENABLE_MICRO_EMB_DEV_PROFILE"] = self.options.embedded_profile
        self._cmake.definitions["UA_ENABLE_TYPENAMES"] = self.options.typenames
        self._cmake.definitions[
            "UA_ENABLE_STATUSCODE_DESCRIPTIONS"] = self.options.readable_statuscodes
        self._cmake.definitions["UA_ENABLE_HARDENING"] = self.options.hardening
        if self.settings.compiler == "Visual Studio" and self.options.shared == True:
            self._cmake.definitions["UA_MSVC_FORCE_STATIC_CRT"] = True
        self._cmake.definitions[
            "UA_COMPILE_AS_CXX"] = self.options.cpp_compatible

        self._cmake.configure(source_dir=self._source_subfolder)
        return self._cmake
 def _configure_cmake(self):
     if not self._cmake:
         self._cmake = CMake(self)
         self._cmake.definitions["CPPBENCHMARK_MODULE"] = "OFF"
         self._cmake.configure(build_folder=self._build_subfolder)
     return self._cmake
Example #44
0
    def _configure_cmake(self):
        cmake = CMake(self)
        cmake.definitions["THREADSAFE"] = self.options.threadsafe
        cmake.definitions["USE_SSH"] = self.options.with_libssh2

        cmake.definitions["USE_ICONV"] = self.options.get_safe(
            "with_iconv", False)

        cmake.definitions["USE_HTTPS"] = self._cmake_https[str(
            self.options.with_https)]
        cmake.definitions["USE_SHA1"] = self._cmake_sha1[str(
            self.options.with_sha1)]

        cmake.definitions["BUILD_CLAR"] = False
        cmake.definitions["BUILD_EXAMPLES"] = False
        cmake.definitions["USE_HTTP_PARSER"] = "system"

        cmake.definitions["REGEX_BACKEND"] = self.options.with_regex

        if is_msvc(self):
            cmake.definitions["STATIC_CRT"] = is_msvc_static_runtime(self)

        cmake.configure()
        return cmake
Example #45
0
class LibcurlConan(ConanFile):
    name = "libcurl"

    description = "command line tool and library for transferring data with URLs"
    topics = ("conan", "curl", "libcurl", "data-transfer")
    url = "https://github.com/conan-io/conan-center-index"
    homepage = "https://curl.haxx.se"
    license = "MIT"
    exports_sources = ["lib_Makefile_add.am", "CMakeLists.txt"]
    generators = "cmake", "pkg_config"

    settings = "os", "arch", "compiler", "build_type"
    options = {
        "shared": [True, False],
        "fPIC": [True, False],
        "with_openssl": [True, False],
        "with_winssl": [True, False],
        "with_ldap": [True, False],
        "darwin_ssl": [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_brotli": [True, False]
    }
    default_options = {
        'shared': False,
        'fPIC': True,
        'with_openssl': True,
        'with_winssl': False,
        'with_ldap': False,
        'darwin_ssl': True,
        'with_libssh2': False,
        'with_libidn': False,
        'with_librtmp': False,
        'with_libmetalink': False,
        'with_libpsl': False,
        'with_largemaxwritesize': False,
        'with_nghttp2': False,
        'with_brotli': False
    }
    _source_subfolder = "source_subfolder"
    _build_subfolder = "build_subfolder"
    _autotools = False

    _cmake = None

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

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

    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 config_options(self):
        if not tools.is_apple_os(self.settings.os):
            del self.options.darwin_ssl

        if self.settings.os != "Windows":
            del self.options.with_winssl

        if self.settings.os == "Windows":
            del self.options.fPIC

    def configure(self):
        del self.settings.compiler.libcxx
        del self.settings.compiler.cppstd

        # be careful with those flags:
        # - with_openssl AND darwin_ssl uses darwin_ssl (to maintain recipe compatibilty)
        # - with_openssl AND NOT darwin_ssl uses openssl
        # - with_openssl AND with_winssl raises to error
        # - with_openssl AND NOT with_winssl uses openssl
        # Moreover darwin_ssl is set by default and with_winssl is not

        if self.settings.os == "Windows" and self.options.with_winssl and self.options.with_openssl:
            raise ConanInvalidConfiguration(
                'Specify only with_winssl or with_openssl')

        if self.options.with_openssl:
            # enforce shared linking due to openssl dependency
            if not tools.is_apple_os(
                    self.settings.os) or not self.options.darwin_ssl:
                self.options["openssl"].shared = self.options.shared
        if self.options.with_libssh2:
            if self.settings.compiler != "Visual Studio":
                self.options["libssh2"].shared = self.options.shared

    def system_requirements(self):
        # TODO: Declare tools needed to compile. The idea is Conan checking that they are
        #   installed and providing a meaningful message before starting the compilation. It
        #   would be much better than installed them (sudo required).
        pass

    def build_requirements(self):
        if self._is_mingw and tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH") and \
           tools.os_info.detect_windows_subsystem() != "msys2":
            self.build_requires("msys2/20190524")
        elif self._is_win_x_android:
            self.build_requires("ninja/1.9.0")
        elif self.settings.os == "Linux":
            self.build_requires("libtool/2.4.6")

    def requirements(self):
        if self.options.with_openssl:
            if tools.is_apple_os(self.settings.os) and self.options.darwin_ssl:
                pass
            elif self.settings.os == "Windows" and self.options.with_winssl:
                pass
            else:
                self.requires("openssl/1.1.1g")
        if self.options.with_libssh2:
            if self.settings.compiler != "Visual Studio":
                self.requires("libssh2/1.9.0")
        if self.options.with_nghttp2:
            self.requires("libnghttp2/1.40.0")

        self.requires("zlib/1.2.11")

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

    def build(self):
        self._patch_misc_files()
        if self.settings.compiler == "Visual Studio" or self._is_win_x_android:
            self._build_with_cmake()
        else:
            self._build_with_autotools()

    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.darwin_ssl:
                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 _get_configure_command_args(self):
        params = []
        params.append("--without-libidn2"
                      if not self.options.with_libidn else "--with-libidn2")
        params.append("--without-librtmp"
                      if not self.options.with_librtmp else "--with-librtmp")
        params.append("--without-libmetalink" if not self.options.
                      with_libmetalink else "--with-libmetalink")
        params.append("--without-libpsl"
                      if not self.options.with_libpsl else "--with-libpsl")
        params.append("--without-brotli"
                      if not self.options.with_brotli else "--with-brotli")

        if tools.is_apple_os(self.settings.os) and self.options.darwin_ssl:
            params.append("--with-darwinssl")
            params.append("--without-ssl")
        elif self.settings.os == "Windows" and self.options.with_winssl:
            params.append("--with-winssl")
            params.append("--without-ssl")
        elif self.options.with_openssl:
            openssl_path = self.deps_cpp_info["openssl"].rootpath.replace(
                '\\', '/')
            params.append("--with-ssl=%s" % openssl_path)
        else:
            params.append("--without-ssl")

        if self.options.with_libssh2:
            params.append(
                "--with-libssh2=%s" %
                self.deps_cpp_info["libssh2"].lib_paths[0].replace('\\', '/'))
        else:
            params.append("--without-libssh2")

        if self.options.with_nghttp2:
            params.append(
                "--with-nghttp2=%s" %
                self.deps_cpp_info["libnghttp2"].rootpath.replace('\\', '/'))
        else:
            params.append("--without-nghttp2")

        params.append(
            "--with-zlib=%s" %
            self.deps_cpp_info["zlib"].lib_paths[0].replace('\\', '/'))

        if not self.options.shared:
            params.append("--disable-shared")
            params.append("--enable-static")
        else:
            params.append("--enable-shared")
            params.append("--disable-static")

        if not self.options.with_ldap:
            params.append("--disable-ldap")

        # 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 _patch_mingw_files(self):
        if not self._is_mingw:
            return
        # patch autotools files
        # for mingw builds - do not compile curl tool, just library
        # linking errors are much harder to fix than to exclude curl tool
        tools.replace_in_file("Makefile.am", 'SUBDIRS = lib src',
                              'SUBDIRS = lib')

        tools.replace_in_file("Makefile.am", 'include src/Makefile.inc', '')

        # patch for zlib naming in mingw
        # when cross-building, the name is correct
        if not tools.cross_building(self.settings):
            tools.replace_in_file("configure.ac", '-lz ', '-lzlib ')

        # patch for openssl extras in mingw
        if self.options.with_openssl:
            tools.replace_in_file("configure", '-lcrypto ',
                                  '-lcrypto -lcrypt32 ')

        if self.options.shared:
            # patch for shared mingw build
            tools.replace_in_file(os.path.join('lib', 'Makefile.am'),
                                  'noinst_LTLIBRARIES = libcurlu.la', '')
            tools.replace_in_file(os.path.join('lib', 'Makefile.am'),
                                  'noinst_LTLIBRARIES =', '')
            tools.replace_in_file(os.path.join('lib', 'Makefile.am'),
                                  '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(
                    os.path.join(self.source_folder, 'lib_Makefile_add.am'))
                tools.save(os.path.join('lib', 'Makefile.am'),
                           added_content,
                           append=True)

    def _build_with_autotools(self):
        with tools.chdir(self._source_subfolder):
            use_win_bash = self._is_mingw and not tools.cross_building(
                self.settings)

            # autoreconf
            self.run('./buildconf',
                     win_bash=use_win_bash,
                     run_environment=True)

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

            self.run("chmod +x configure")

            env_run = RunEnvironment(self)
            # run configure with *LD_LIBRARY_PATH env vars it allows to pick up shared openssl
            self.output.info("Run vars: " + repr(env_run.vars))
            with tools.environment_append(env_run.vars):
                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'

            del autotools_vars['LIBS']
            self.output.info("Autotools env vars: " + repr(autotools_vars))

        if tools.cross_building(self.settings):
            if self.settings.os == "iOS":
                iphoneos = tools.apple_sdk_name(self.settings)
                ios_dev_target = str(self.settings.os.version).split(".")[0]

                env_cppflags = tools.get_env("CPPFLAGS", "")
                socket_flags = " -DHAVE_SOCKET -DHAVE_FCNTL_O_NONBLOCK"
                if self.settings.arch in ["x86", "x86_64"]:
                    autotools_vars[
                        'CPPFLAGS'] = "-D__IPHONE_OS_VERSION_MIN_REQUIRED={}0000 {} {}".format(
                            ios_dev_target, socket_flags, env_cppflags)
                elif self.settings.arch in ["armv7", "armv7s", "armv8"]:
                    autotools_vars['CPPFLAGS'] = "{} {}".format(
                        socket_flags, env_cppflags)
                else:
                    raise ConanInvalidConfiguration(
                        "Unsuported iOS arch {}".format(self.settings.arch))

                cc = tools.XCRun(self.settings, iphoneos).cc
                sysroot = "-isysroot {}".format(
                    tools.XCRun(self.settings, iphoneos).sdk_path)

                if self.settings.arch == "armv8":
                    configure_arch = "arm64"
                    configure_host = "arm"  #unused, autodetected
                else:
                    configure_arch = self.settings.arch
                    configure_host = self.settings.arch  #unused, autodetected

                arch_flag = "-arch {}".format(configure_arch)
                ios_min_version = tools.apple_deployment_target_flag(
                    self.settings.os, self.settings.os.version)
                extra_flag = "-Werror=partial-availability"

                # if we debug, maybe add a -gdwarf-2 , but why would we want that?

                autotools_vars['CC'] = cc
                autotools_vars['IPHONEOS_DEPLOYMENT_TARGET'] = ios_dev_target
                env_cflags = tools.get_env("CFLAGS", "")
                autotools_vars['CFLAGS'] = "{} {} {} {}".format(
                    sysroot, arch_flag, ios_min_version, env_cflags)

                if self.options.with_openssl:
                    openssl_path = self.deps_cpp_info["openssl"].rootpath
                    openssl_libdir = self.deps_cpp_info["openssl"].libdirs[0]
                    autotools_vars['LDFLAGS'] = "{} {} -L{}/{}".format(
                        arch_flag, sysroot, openssl_path, openssl_libdir)
                else:
                    autotools_vars['LDFLAGS'] = "{} {}".format(
                        arch_flag, sysroot)

            elif self.settings.os == "Android":
                # nothing do to at the moment, this seems to just work
                pass

        return autotools_vars

    def _configure_autotools(self):

        if not self._autotools:
            use_win_bash = self._is_mingw and not tools.cross_building(
                self.settings)
            self._autotools = AutoToolsBuildEnvironment(self,
                                                        win_bash=use_win_bash)

            if self.settings.os != "Windows":
                self._autotools.fpic = self.options.fPIC

            autotools_vars = self._configure_autotools_vars()

            # tweaks for mingw
            if self._is_mingw:
                # patch autotools files
                self._patch_mingw_files()

                self._autotools.defines.append('_AMD64_')

            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=autotools_vars,
                                          args=configure_args,
                                          build=False)
            else:
                self._autotools.configure(vars=autotools_vars,
                                          args=configure_args)

        return self._autotools, self._configure_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'] = ''
        self._cmake.definitions[
            'CMAKE_USE_LIBSSH2'] = self.options.with_libssh2

        # all these options are exclusive. set just one of them
        # mac builds do not use cmake so don't even bother about darwin_ssl
        self._cmake.definitions[
            'CMAKE_USE_WINSSL'] = 'with_winssl' in self.options and self.options.with_winssl
        self._cmake.definitions[
            'CMAKE_USE_OPENSSL'] = 'with_openssl' in self.options and self.options.with_openssl
        self._cmake.configure(build_folder=self._build_subfolder)
        return self._cmake

    def _build_with_cmake(self):
        # patch cmake files
        with tools.chdir(self._source_subfolder):
            tools.replace_in_file("CMakeLists.txt",
                                  "include(CurlSymbolHiding)", "")

        cmake = self._configure_cmake()
        cmake.build()

    def package(self):
        self.copy(pattern="COPYING",
                  dst="licenses",
                  src=self._source_subfolder)

        # Execute install
        if self.settings.compiler == "Visual Studio" or self._is_win_x_android:
            cmake = self._configure_cmake()
            cmake.install()
        else:
            env_run = RunEnvironment(self)
            with tools.environment_append(env_run.vars):
                with tools.chdir(self._source_subfolder):
                    autotools, autotools_vars = self._configure_autotools()
                    autotools.install(vars=autotools_vars)
        if self._is_mingw:
            # 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="*.def", dst="lib", keep_path=False)
            self.copy(pattern="*.lib", dst="lib", keep_path=False)

        self.copy("cacert.pem", dst="res")

        # no need to distribute share folder (docs/man pages)
        tools.rmdir(os.path.join(self.package_folder, 'share'))
        # no need for pc files
        tools.rmdir(os.path.join(self.package_folder, 'lib', 'pkgconfig'))
        # no need for cmake files
        tools.rmdir(os.path.join(self.package_folder, 'lib', 'cmake'))
        # Remove libtool files (*.la)
        if os.path.isfile(
                os.path.join(self.package_folder, 'lib', 'libcurl.la')):
            os.remove(os.path.join(self.package_folder, 'lib', 'libcurl.la'))

    def package_info(self):
        self.cpp_info.names['cmake_find_package'] = 'CURL'
        self.cpp_info.names['cmake_find_package_multi'] = 'CURL'

        if self.settings.compiler != "Visual Studio":
            self.cpp_info.libs = ['curl']
            if self.settings.os == "Linux":
                self.cpp_info.system_libs.extend(["rt", "pthread"])
                if self.options.with_libssh2:
                    self.cpp_info.libs.extend(["ssh2"])
                if self.options.with_libidn:
                    self.cpp_info.libs.extend(["idn"])
                if self.options.with_librtmp:
                    self.cpp_info.libs.extend(["rtmp"])
                if self.options.with_brotli:
                    self.cpp_info.libs.extend(["brotlidec"])
            if self.settings.os == "Macos":
                if self.options.with_ldap:
                    self.cpp_info.system_libs.extend(["ldap"])
                if self.options.darwin_ssl:
                    self.cpp_info.frameworks.extend(["Cocoa", "Security"])
        else:
            self.cpp_info.libs = ['libcurl_imp'
                                  ] if self.options.shared else ['libcurl']

        if self.settings.os == "Windows":
            # used on Windows for VS build, native and cross mingw build
            self.cpp_info.system_libs.append('ws2_32')
            if self.options.with_ldap:
                self.cpp_info.system_libs.append("wldap32")
            if self.options.with_winssl:
                self.cpp_info.system_libs.append("Crypt32")

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

        if not self.options.shared:
            self.cpp_info.defines.append("CURL_STATICLIB=1")
Example #46
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(source_dir="%s/oidn-%s" %
                     (self.source_folder, self.version))
     cmake.build()
Example #47
0
class LibSigCppConan(ConanFile):
    name = "libsigcpp"
    homepage = "https://github.com/libsigcplusplus/libsigcplusplus"
    url = "https://github.com/conan-io/conan-center-index"
    license = "LGPL-3.0"
    description = "libsigc++ implements a typesafe callback system for standard C++."
    topics = ("libsigcpp", "callback")

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

    generators = "cmake"
    _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 config_options(self):
        if self.settings.os == "Windows":
            del self.options.fPIC

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

    @property
    def _minimum_compilers_version(self):
        return {
            "Visual Studio": "15.7",
            "gcc": "7",
            "clang": "6",
            "apple-clang": "10",
        }

    def validate(self):
        if self.settings.compiler.get_safe("cppstd"):
            tools.check_min_cppstd(self, 17)

        def lazy_lt_semver(v1, v2):
            lv1 = [int(v) for v in v1.split(".")]
            lv2 = [int(v) for v in v2.split(".")]
            min_length = min(len(lv1), len(lv2))
            return lv1[:min_length] < lv2[:min_length]

        minimum_version = self._minimum_compilers_version.get(
            str(self.settings.compiler), False)
        if not minimum_version:
            self.output.warn(
                "libsigcpp requires C++17. Your compiler is unknown. Assuming it supports C++17."
            )
        elif lazy_lt_semver(str(self.settings.compiler.version),
                            minimum_version):
            raise ConanInvalidConfiguration(
                "libsigcpp requires C++17, which your compiler does not support."
            )

    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.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)
        if not self.options.shared:
            tools.replace_in_file(
                os.path.join(self._source_subfolder, "sigc++config.h.cmake"),
                "define SIGC_DLL 1", "undef SIGC_DLL")
        cmake = self._configure_cmake()
        cmake.build()

    def package(self):
        self.copy("COPYING", dst="licenses", src=self._source_subfolder)
        cmake = self._configure_cmake()
        cmake.install()
        for header_file in glob.glob(
                os.path.join(self.package_folder, "lib", "sigc++-3.0",
                             "include", "*.h")):
            shutil.move(
                header_file,
                os.path.join(self.package_folder, "include", "sigc++-3.0",
                             os.path.basename(header_file)))
        for dir_to_remove in ["cmake", "pkgconfig", "sigc++-3.0"]:
            tools.rmdir(os.path.join(self.package_folder, "lib",
                                     dir_to_remove))

        # TODO: to remove in conan v2 once cmake_find_package* generators removed
        self._create_cmake_module_alias_targets(
            os.path.join(self.package_folder, self._module_file_rel_path),
            {"sigc-3.0": "sigc++-3::sigc-3.0"})

    @staticmethod
    def _create_cmake_module_alias_targets(module_file, targets):
        content = ""
        for alias, aliased in targets.items():
            content += textwrap.dedent("""\
                if(TARGET {aliased} AND NOT TARGET {alias})
                    add_library({alias} INTERFACE IMPORTED)
                    set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
                endif()
            """.format(alias=alias, aliased=aliased))
        tools.save(module_file, content)

    @property
    def _module_file_rel_path(self):
        return os.path.join(
            "lib", "cmake",
            "conan-official-{}-targets.cmake".format(self.name))

    def package_info(self):
        self.cpp_info.set_property("cmake_file_name", "sigc++-3")
        self.cpp_info.set_property("cmake_target_name", "sigc-3.0")
        self.cpp_info.set_property("pkg_config_name", "sigc++-3.0")

        # TODO: back to global scope in conan v2 once cmake_find_package* generators removed
        self.cpp_info.components["sigc++"].includedirs = [
            os.path.join("include", "sigc++-3.0")
        ]
        self.cpp_info.components["sigc++"].libs = tools.collect_libs(self)
        if self.settings.os in ("FreeBSD", "Linux"):
            self.cpp_info.components["sigc++"].system_libs.append("m")

        # TODO: to remove in conan v2 once cmake_find_package* generators removed
        self.cpp_info.names["cmake_find_package"] = "sigc++-3"
        self.cpp_info.names["cmake_find_package_multi"] = "sigc++-3"
        self.cpp_info.components["sigc++"].names[
            "cmake_find_package"] = "sigc-3.0"
        self.cpp_info.components["sigc++"].names[
            "cmake_find_package_multi"] = "sigc-3.0"
        self.cpp_info.components["sigc++"].build_modules[
            "cmake_find_package"] = [self._module_file_rel_path]
        self.cpp_info.components["sigc++"].build_modules[
            "cmake_find_package_multi"] = [self._module_file_rel_path]
        self.cpp_info.components["sigc++"].set_property(
            "pkg_config_name", "sigc++-3.0")
Example #48
0
 def build(self):
     cmake = CMake(self)
     cmake.configure()
     cmake.build()
Example #49
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(source_folder="src")
     cmake.build()
Example #50
0
 def build(self):
     cmake = CMake(self)
     cmake.definitions["CLIPPER_MAJOR_VERSION"] = tools.Version(
         self.deps_cpp_info["clipper"].version).major
     cmake.configure()
     cmake.build()
Example #51
0
class GlfwConan(ConanFile):
    name = "glfw"
    version = "3.3.4"
    description = "GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan" \
                  "application development. It provides a simple, platform-independent API for creating" \
                  "windows, contexts and surfaces, reading input, handling events, etc."
    settings = "os", "arch", "build_type", "compiler"
    license = "Zlib"
    url = "https://github.com/conan-io/conan-center-index"
    homepage = "https://github.com/glfw/glfw"
    topics = ("conan", "gflw", "opengl", "vulkan", "opengl-es")
    generators = "cmake"
    options = {
        "shared": [True, False],
        "fPIC": [True, False],
        "no_opengl": [True, False],
        "no_xorg": [True, False],
    }
    default_options = {
        "shared": False,
        "fPIC": True,
        "no_opengl": False,
        "no_xorg": False,
    }
    _source_subfolder = "source_subfolder"
    _build_subfolder = "build_subfolder"
    _cmake = None
    exports_sources = ["CMakeLists.txt"]

    def _configure_cmake(self):
        if not self._cmake:
            self._cmake = CMake(self)
            self._cmake.definitions["GLFW_BUILD_EXAMPLES"] = False
            self._cmake.definitions["GLFW_BUILD_TESTS"] = False
            self._cmake.definitions["GLFW_BUILD_DOCS"] = False
            if self.settings.compiler == "Visual Studio":
                self._cmake.definitions[
                    "USE_MSVC_RUNTIME_LIBRARY_DLL"] = "MD" in self.settings.compiler.runtime
            self._cmake.configure(source_folder=self._source_subfolder)
        return self._cmake

    def requirements(self):
        # stgatilov: Unfortunately, conan is not very good at deciding
        # which system packages to install in every version of every distro.
        # Since TDM links both packages directly, we can just skip system packages here
        if not self.options.no_opengl:
            self.requires("opengl/system")
        if self.settings.os == "Linux":
            if not self.options.no_xorg:
                self.requires("xorg/system")

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

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

    def source(self):
        #tools.get(**self.conan_data["sources"][self.version])
        tools.get("https://github.com/glfw/glfw/archive/{}.zip".format(
            self.version))
        extracted_dir = "{}-{}".format(self.name, self.version)
        os.rename(extracted_dir, self._source_subfolder)
        # stgatilov: pass conan settings (like -m32) to CMake
        os.rename(
            os.path.join(self._source_subfolder, "CMakeLists.txt"),
            os.path.join(self._source_subfolder, "CMakeLists_original.txt"))
        shutil.copy("CMakeLists.txt",
                    os.path.join(self._source_subfolder, "CMakeLists.txt"))

    def build(self):
        cmake = self._configure_cmake()
        cmake.build()
        if self.settings.os == "Macos" and self.options.shared:
            with tools.chdir(os.path.join(self._source_subfolder, 'src')):
                for filename in glob.glob('*.dylib'):
                    self.run(
                        'install_name_tool -id {filename} {filename}'.format(
                            filename=filename))

    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", "cmake"))
        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))

    def package_info(self):
        self.cpp_info.names["pkg_config"] = "glfw3"
        self.cpp_info.libs = tools.collect_libs(self)
        if self.settings.os == "Linux":
            self.cpp_info.system_libs.extend(["m", "pthread", "dl", "rt"])
        elif self.settings.os == "Macos":
            self.cpp_info.frameworks.extend(
                ["Cocoa", "IOKit", "CoreFoundation"])
class PCREConan(ConanFile):
    name = "pcre"
    url = "https://github.com/conan-io/conan-center-index"
    homepage = "https://www.pcre.org"
    description = "Perl Compatible Regular Expressions"
    topics = ("regex", "regexp", "PCRE")
    license = "BSD-3-Clause"

    settings = "os", "arch", "compiler", "build_type"
    options = {
        "shared": [True, False],
        "fPIC": [True, False],
        "build_pcre_8": [True, False],
        "build_pcre_16": [True, False],
        "build_pcre_32": [True, False],
        "build_pcrecpp": [True, False],
        "build_pcregrep": [True, False],
        "with_bzip2": [True, False],
        "with_zlib": [True, False],
        "with_jit": [True, False],
        "with_utf": [True, False],
        "with_unicode_properties": [True, False],
        "with_stack_for_recursion": [True, False]
    }
    default_options = {
        "shared": False,
        "fPIC": True,
        "build_pcre_8": True,
        "build_pcre_16": True,
        "build_pcre_32": True,
        "build_pcrecpp": False,
        "build_pcregrep": True,
        "with_bzip2": True,
        "with_zlib": True,
        "with_jit": False,
        "with_utf": False,
        "with_unicode_properties": False,
        "with_stack_for_recursion": True
    }

    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.build_pcrecpp:
            del self.settings.compiler.libcxx
            del self.settings.compiler.cppstd
        if not self.options.build_pcregrep:
            del self.options.with_bzip2
            del self.options.with_zlib
        if not self.options.build_pcre_8 and not self.options.build_pcre_16 and not self.options.build_pcre_32:
            raise ConanInvalidConfiguration(
                "At least one of build_pcre_8, build_pcre_16 or build_pcre_32 must be enabled"
            )
        if self.options.build_pcrecpp and not self.options.build_pcre_8:
            raise ConanInvalidConfiguration(
                "build_pcre_8 must be enabled for the C++ library support")
        if self.options.build_pcregrep and not self.options.build_pcre_8:
            raise ConanInvalidConfiguration(
                "build_pcre_8 must be enabled for the pcregrep program")
        if self.options.with_unicode_properties:
            self.options.with_utf = True

    def requirements(self):
        if self.options.get_safe("with_bzip2"):
            self.requires("bzip2/1.0.8")
        if self.options.get_safe("with_zlib"):
            self.requires("zlib/1.2.11")

    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 _patch_sources(self):
        cmake_file = os.path.join(self._source_subfolder, "CMakeLists.txt")
        # Avoid man and share during install stage
        tools.replace_in_file(cmake_file,
                              "INSTALL(FILES ${man1} DESTINATION man/man1)",
                              "")
        tools.replace_in_file(cmake_file,
                              "INSTALL(FILES ${man3} DESTINATION man/man3)",
                              "")
        tools.replace_in_file(
            cmake_file,
            "INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)", "")
        # Do not override CMAKE_MODULE_PATH and do not add ${PROJECT_SOURCE_DIR}/cmake
        # because it contains a custom FindPackageHandleStandardArgs.cmake which
        # can break conan generators
        tools.replace_in_file(
            cmake_file, "SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)",
            "")
        # Avoid CMP0006 error (macos bundle)
        tools.replace_in_file(
            cmake_file, "RUNTIME DESTINATION bin",
            "RUNTIME DESTINATION bin\n        BUNDLE DESTINATION bin")

    def _configure_cmake(self):
        if self._cmake:
            return self._cmake
        self._cmake = CMake(self)
        self._cmake.definitions["PCRE_BUILD_TESTS"] = False
        self._cmake.definitions["PCRE_BUILD_PCRE8"] = self.options.build_pcre_8
        self._cmake.definitions[
            "PCRE_BUILD_PCRE16"] = self.options.build_pcre_16
        self._cmake.definitions[
            "PCRE_BUILD_PCRE32"] = self.options.build_pcre_32
        self._cmake.definitions[
            "PCRE_BUILD_PCREGREP"] = self.options.build_pcregrep
        self._cmake.definitions[
            "PCRE_BUILD_PCRECPP"] = self.options.build_pcrecpp
        self._cmake.definitions["PCRE_SUPPORT_LIBZ"] = self.options.get_safe(
            "with_zlib", False)
        self._cmake.definitions["PCRE_SUPPORT_LIBBZ2"] = self.options.get_safe(
            "with_bzip2", False)
        self._cmake.definitions["PCRE_SUPPORT_JIT"] = self.options.with_jit
        self._cmake.definitions["PCRE_SUPPORT_UTF"] = self.options.with_utf
        self._cmake.definitions[
            "PCRE_SUPPORT_UNICODE_PROPERTIES"] = self.options.with_unicode_properties
        self._cmake.definitions["PCRE_SUPPORT_LIBREADLINE"] = False
        self._cmake.definitions["PCRE_SUPPORT_LIBEDIT"] = False
        self._cmake.definitions[
            "PCRE_NO_RECURSE"] = not self.options.with_stack_for_recursion
        if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
            self._cmake.definitions[
                "PCRE_STATIC_RUNTIME"] = not self.options.shared and "MT" in self.settings.compiler.runtime
        self._cmake.configure(build_folder=self._build_subfolder)
        return self._cmake

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

    def package(self):
        self.copy(pattern="LICENCE",
                  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.names["cmake_find_package"] = "PCRE"
        self.cpp_info.names["cmake_find_package_multi"] = "PCRE"
        if self.options.build_pcre_8:
            # pcre
            self.cpp_info.components["libpcre"].names["pkg_config"] = "libpcre"
            self.cpp_info.components["libpcre"].libs = [self._lib_name("pcre")]
            if not self.options.shared:
                self.cpp_info.components["libpcre"].defines.append(
                    "PCRE_STATIC=1")
            # pcreposix
            self.cpp_info.components["libpcreposix"].names[
                "pkg_config"] = "libpcreposix"
            self.cpp_info.components["libpcreposix"].libs = [
                self._lib_name("pcreposix")
            ]
            self.cpp_info.components["libpcreposix"].requires = ["libpcre"]
            # pcrecpp
            if self.options.build_pcrecpp:
                self.cpp_info.components["libpcrecpp"].names[
                    "pkg_config"] = "libpcrecpp"
                self.cpp_info.components["libpcrecpp"].libs = [
                    self._lib_name("pcrecpp")
                ]
                self.cpp_info.components["libpcrecpp"].requires = ["libpcre"]
        # pcre16
        if self.options.build_pcre_16:
            self.cpp_info.components["libpcre16"].names[
                "pkg_config"] = "libpcre16"
            self.cpp_info.components["libpcre16"].libs = [
                self._lib_name("pcre16")
            ]
            if not self.options.shared:
                self.cpp_info.components["libpcre16"].defines.append(
                    "PCRE_STATIC=1")
        # pcre32
        if self.options.build_pcre_32:
            self.cpp_info.components["libpcre32"].names[
                "pkg_config"] = "libpcre32"
            self.cpp_info.components["libpcre32"].libs = [
                self._lib_name("pcre32")
            ]
            if not self.options.shared:
                self.cpp_info.components["libpcre32"].defines.append(
                    "PCRE_STATIC=1")

        if self.options.build_pcregrep:
            bin_path = os.path.join(self.package_folder, "bin")
            self.output.info(
                "Appending PATH environment variable: {}".format(bin_path))
            self.env_info.PATH.append(bin_path)
            # FIXME: This is a workaround to avoid ConanException. zlib and bzip2
            # are optional requirements of pcregrep executable, not of any pcre lib.
            if self.options.with_bzip2:
                self.cpp_info.components["libpcre"].requires.append(
                    "bzip2::bzip2")
            if self.options.with_zlib:
                self.cpp_info.components["libpcre"].requires.append(
                    "zlib::zlib")

    def _lib_name(self, name):
        if self.settings.os == "Windows" and self.settings.build_type == "Debug":
            return name + "d"
        return name
Example #53
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()
Example #54
0
class HarfbuzzConan(ConanFile):
    name = "harfbuzz"
    description = "HarfBuzz is an OpenType text shaping engine."
    topics = ("conan", "harfbuzz", "opentype", "text", "engine")
    url = "https://github.com/conan-io/conan-center-index"
    homepage = "http://harfbuzz.org"
    license = "MIT"
    exports_sources = ["CMakeLists.txt", "patches/*.patch"]
    generators = "cmake"
    short_paths = True

    settings = "os", "arch", "compiler", "build_type"
    
    options = {
        "shared": [True, False],
        "fPIC": [True, False],
        "with_freetype": [True, False],
        "with_icu": [True, False],
        "with_glib": [True, False],
        "with_gdi": [True, False],
        "with_uniscribe": [True, False]
    }
    default_options = {
        "shared": False,
        "fPIC": True,
        "with_freetype": True,
        "with_icu": False,
        "with_glib": True,
        "with_gdi": True,
        "with_uniscribe": True
    }

    _source_subfolder = "source_subfolder"
    _build_subfolder = "build_subfolder"

    _cmake = None

    def requirements(self):
        if self.options.with_freetype:
            self.requires("freetype/2.10.4")
        if self.options.with_icu:
            self.requires("icu/68.2")
        if self.options.with_glib:
            self.requires("glib/2.67.6")

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

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

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

    def _configure_cmake_compiler_flags(self, cmake):
        flags = []
        compiler = str(self.settings.compiler)
        if compiler in ("clang", "apple-clang"):
            flags.append("-Wno-deprecated-declarations")
        if self.settings.compiler == "gcc" and self.settings.os == "Windows":
            flags.append("-Wa,-mbig-obj")
        cmake.definitions["CMAKE_C_FLAGS"] = " ".join(flags)
        cmake.definitions["CMAKE_CXX_FLAGS"] = cmake.definitions["CMAKE_C_FLAGS"]

        return cmake

    def _configure_cmake_macos(self, cmake):
        if tools.is_apple_os(self.settings.os):
            cmake.definitions["CMAKE_MACOSX_RPATH"] = True
        return cmake

    def _configure_cmake(self):
        if self._cmake:
            return self._cmake
        self._cmake = CMake(self)
        self._cmake = self._configure_cmake_compiler_flags(self._cmake)
        self._cmake = self._configure_cmake_macos(self._cmake)
        self._cmake.definitions["HB_HAVE_FREETYPE"] = self.options.with_freetype
        self._cmake.definitions["HB_BUILD_TESTS"] = False
        self._cmake.definitions["HB_HAVE_ICU"] = self.options.with_icu
        self._cmake.definitions["HB_HAVE_GLIB"] = self.options.with_glib

        if self.settings.os == "Windows":
            self._cmake.definitions["HB_HAVE_GDI"] = self.options.with_gdi
            self._cmake.definitions["HB_HAVE_UNISCRIBE"] = self.options.with_uniscribe

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

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

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


    def package_info(self):
        self.cpp_info.libs = tools.collect_libs(self)
        self.cpp_info.includedirs.append(os.path.join("include", "harfbuzz"))
        if self.settings.os == "Linux":
            self.cpp_info.system_libs.append("m")
        if self.settings.os == "Windows" and not self.options.shared:
            self.cpp_info.system_libs.extend(["dwrite", "rpcrt4", "usp10", "gdi32", "user32"])
        if self.settings.os == "Macos":
            self.cpp_info.frameworks.extend(["CoreFoundation", "CoreGraphics", "CoreText"])
Example #55
0
 def build(self):
     cmake = CMake(self)
     cmake.configure(source_folder=path.join(self.source_folder, "conan-wrapper"))
     cmake.build()
     cmake.install()
Example #56
0
class FruitConan(ConanFile):
    name = "fruit"
    description = "C++ dependency injection framework"
    url = "https://github.com/conan-io/conan-center-index"
    homepage = "https://github.com/google/fruit"
    license = "Apache-2.0"
    topics = ("conan", "fruit", "injection")
    settings = "os", "compiler", "build_type", "arch"
    options = {
        "shared": [True, False],
        "use_boost": [True, False],
        "fPIC": [True, False]
    }
    default_options = {"shared": False, "use_boost": True, "fPIC": True}
    generators = "cmake", "cmake_find_package"
    exports_sources = ["CMakeLists.txt", "patches/*"]
    _cmake = None

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

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

    def build_requirements(self):
        if self.options.use_boost:
            self.build_requires("boost/1.72.0")

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

    def configure(self):
        compiler = str(self.settings.compiler)
        compiler_version = Version(self.settings.compiler.version.value)

        minimal_version = {
            "gcc": "5",
            "clang": "3.5",
            "apple-clang": "7.3",
            "Visual Studio": "14"
        }

        if compiler in minimal_version and \
           compiler_version < minimal_version[compiler]:
            raise ConanInvalidConfiguration(
                "%s requires a compiler that supports"
                " at least C++11. %s %s is not"
                " supported." % (self.name, compiler, compiler_version))

        if self.settings.compiler.cppstd:
            tools.check_min_cppstd(self, "11")

    @property
    def _extracted_dir(self):
        return self.name + "-" + self.version

    def _get_source(self):
        filename = os.path.basename(
            self.conan_data["sources"][self.version]["url"])
        tools.download(filename=filename,
                       **self.conan_data["sources"][self.version])

        with tarfile.TarFile.open(filename, 'r:*') as tarredgzippedFile:
            # NOTE: The archive file contains the file names build and BULD
            # in the extras/bazel_root/third_party/fruit directory.
            # Extraction fails on a case-insensitive file system due to file
            # name conflicts.
            # Exclude build as a workaround.
            exclude_pattern = "%s/extras/bazel_root/third_party/fruit/build" % (
                self._extracted_dir, )
            members = list(
                filter(lambda m: not fnmatch(m.name, exclude_pattern),
                       tarredgzippedFile.getmembers()))
            tarredgzippedFile.extractall(".", members=members)

    def source(self):
        self._get_source()

        os.rename(self._extracted_dir, self._source_subfolder)

    def _configure_cmake(self):
        if not self._cmake:
            self._cmake = CMake(self)
            self._cmake.definitions[
                "FRUIT_USES_BOOST"] = self.options.use_boost
            self._cmake.definitions["FRUIT_ENABLE_COVERAGE"] = False

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

    def _patch_files(self):
        if self.version in self.conan_data["patches"]:
            for patch in self.conan_data["patches"][self.version]:
                tools.patch(**patch)

    def build(self):
        self._patch_files()

        cmake = self._configure_cmake()
        cmake.build()

    def package(self):
        self.copy("COPYING", dst="licenses", src=self._source_subfolder)

        cmake = self._configure_cmake()
        cmake.install()

    def package_info(self):
        self.cpp_info.libs = tools.collect_libs(self)
        if self.settings.os == "Linux":
            self.cpp_info.system_libs = ["m"]
Example #57
0
 def build(self):
     cmake = CMake(self)
     self.run('cmake %s/src %s' % (self.source_folder, cmake.command_line))
     self.run("cmake --build . %s" % cmake.build_config)
 def test(self):
     # TODO(jdee): This isn't necessarily the right idea. The idea is to use a project
     # that imports this one to test that we've been installed correctly, e.g. TestBed.
     CMake(self).test()
Example #59
0
class OpenEXRConan(ConanFile):
    name = "openexr"
    description = "OpenEXR is a high dynamic-range (HDR) image file format developed by Industrial Light & " \
                  "Magic for use in computer imaging applications."
    topics = ("conan", "openexr", "hdr", "image", "picture")
    license = "BSD-3-Clause"
    homepage = "https://github.com/AcademySoftwareFoundation/openexr"
    url = "https://github.com/conan-io/conan-center-index"
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False], "fPIC": [True, False]}
    default_options = {"shared": False, "fPIC": True}
    generators = "cmake", "cmake_find_package"
    exports_sources = "CMakeLists.txt"

    _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

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

    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["OPENEXR_BUILD_BOTH_STATIC_SHARED"] = False
        self._cmake.definitions["ILMBASE_BUILD_BOTH_STATIC_SHARED"] = False
        self._cmake.definitions["PYILMBASE_ENABLE"] = False
        if tools.Version(self.version) < "2.5.0":
            self._cmake.definitions["OPENEXR_VIEWERS_ENABLE"] = False
        else:
            self._cmake.definitions["INSTALL_OPENEXR_EXAMPLES"] = False
            self._cmake.definitions["INSTALL_OPENEXR_DOCS"] = False
        self._cmake.definitions["OPENEXR_BUILD_UTILS"] = False
        self._cmake.definitions["BUILD_TESTING"] = False
        self._cmake.configure(build_folder=self._build_subfolder)
        return self._cmake

    def _patch_files(self):

        pkg_version = tools.Version(self.version)
        if pkg_version < "2.5.2" and self.settings.os == "Windows":
            # This fixes symlink creation on Windows.
            # OpenEXR's build system no longer creates symlinks on windows, starting with commit
            # 7f9e1b410de92de244329b614cf551b30bc30421 (included in 2.5.2).
            for lib in ("OpenEXR", "IlmBase"):
                tools.replace_in_file(
                    os.path.join(self._source_subfolder, lib, "config",
                                 "LibraryDefine.cmake"),
                    "${CMAKE_COMMAND} -E chdir ${CMAKE_INSTALL_FULL_LIBDIR}",
                    "${CMAKE_COMMAND} -E chdir ${CMAKE_INSTALL_FULL_BINDIR}")

        # Add  "_d" suffix to lib file names.
        if pkg_version < "2.5.7" and self.settings.build_type == "Debug":
            for lib in ("OpenEXR", "IlmBase"):
                tools.replace_in_file(
                    os.path.join(self._source_subfolder, lib, "config",
                                 "LibraryDefine.cmake"),
                    "set(verlibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${@LIB@_LIB_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX})"
                    .replace("@LIB@", lib.upper()),
                    "set(verlibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${@LIB@_LIB_SUFFIX}_d${CMAKE_SHARED_LIBRARY_SUFFIX})"
                    .replace("@LIB@", lib.upper()))
                tools.replace_in_file(
                    os.path.join(self._source_subfolder, lib, "config",
                                 "LibraryDefine.cmake"),
                    "set(baselibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${CMAKE_SHARED_LIBRARY_SUFFIX})",
                    "set(baselibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}_d${CMAKE_SHARED_LIBRARY_SUFFIX})"
                )

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

    def package(self):
        self.copy("LICENSE.md", src=self._source_subfolder, dst="licenses")
        cmake = self._configure_cmake()
        cmake.install()
        tools.rmdir(os.path.join(self.package_folder, "share"))
        tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
        tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
        self._create_cmake_module_alias_targets(
            os.path.join(self.package_folder, self._module_file_rel_path), {
                "IlmBase::IlmBaseConfig": "OpenEXR::IlmBaseConfig",
                "IlmBase::Half": "OpenEXR::Half",
                "IlmBase::Iex": "OpenEXR::Iex",
                "IlmBase::IexMath": "OpenEXR::IexMath",
                "IlmBase::IMath": "OpenEXR::IMath",
                "IlmBase::IlmThread": "OpenEXR::IlmThread",
            })

    @staticmethod
    def _create_cmake_module_alias_targets(module_file, targets):
        content = ""
        for alias, aliased in targets.items():
            content += textwrap.dedent("""\
                if(TARGET {aliased} AND NOT TARGET {alias})
                    add_library({alias} INTERFACE IMPORTED)
                    set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
                endif()
            """.format(alias=alias, aliased=aliased))
        tools.save(module_file, content)

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

    @property
    def _module_file_rel_path(self):
        return os.path.join(
            self._module_subfolder,
            "conan-official-{}-targets.cmake".format(self.name))

    def package_info(self):
        # FIXME: we should generate 2 CMake config files: OpenEXRConfig.cmake and IlmBaseConfig.cmake
        #        waiting an implementation of https://github.com/conan-io/conan/issues/9000
        self.cpp_info.names["cmake_find_package"] = "OpenEXR"
        self.cpp_info.names["cmake_find_package_multi"] = "OpenEXR"
        self.cpp_info.names[
            "pkg_config"] = "openexr_full_package"  # not official, we want to avoid clash with OpenEXR.pc generated by IlmImf component

        openexr_version = tools.Version(self.version)
        lib_suffix = "-{}_{}".format(openexr_version.major,
                                     openexr_version.minor)
        if self.settings.build_type == "Debug":
            lib_suffix += "_d"

        include_dir = os.path.join("include", "OpenEXR")

        # IlmImfConfig
        self.cpp_info.components["openexr_ilmimfconfig"].names[
            "cmake_find_package"] = "IlmImfConfig"
        self.cpp_info.components["openexr_ilmimfconfig"].names[
            "cmake_find_package_multi"] = "IlmImfConfig"
        self.cpp_info.components["openexr_ilmimfconfig"].includedirs.append(
            include_dir)

        # IlmImf
        self.cpp_info.components["openexr_ilmimf"].names[
            "cmake_find_package"] = "IlmImf"
        self.cpp_info.components["openexr_ilmimf"].names[
            "cmake_find_package_multi"] = "IlmImf"
        self.cpp_info.components["openexr_ilmimf"].names[
            "pkg_config"] = "OpenEXR"
        self.cpp_info.components["openexr_ilmimf"].includedirs.append(
            include_dir)
        self.cpp_info.components["openexr_ilmimf"].libs = [
            "IlmImf{}".format(lib_suffix)
        ]
        self.cpp_info.components["openexr_ilmimf"].requires = [
            "openexr_ilmimfconfig",
            "ilmbase_iex",
            "ilmbase_half",
            "ilmbase_imath",
            "ilmbase_ilmthread",
            "zlib::zlib",
        ]

        # IlmImfUtil
        self.cpp_info.components["openexr_ilmimfutil"].names[
            "cmake_find_package"] = "IlmImfUtil"
        self.cpp_info.components["openexr_ilmimfutil"].names[
            "cmake_find_package_multi"] = "IlmImfUtil"
        self.cpp_info.components["openexr_ilmimfutil"].includedirs.append(
            include_dir)
        self.cpp_info.components["openexr_ilmimfutil"].libs = [
            "IlmImfUtil{}".format(lib_suffix)
        ]
        self.cpp_info.components["openexr_ilmimfutil"].requires = [
            "openexr_ilmimfconfig", "openexr_ilmimf"
        ]

        # IlmBaseConfig
        self.cpp_info.components["ilmbase_ilmbaseconfig"].names[
            "cmake_find_package"] = "IlmBaseConfig"
        self.cpp_info.components["ilmbase_ilmbaseconfig"].names[
            "cmake_find_package_multi"] = "IlmBaseConfig"
        self.cpp_info.components["ilmbase_ilmbaseconfig"].builddirs.append(
            self._module_subfolder)
        self.cpp_info.components["ilmbase_ilmbaseconfig"].build_modules[
            "cmake_find_package"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_ilmbaseconfig"].build_modules[
            "cmake_find_package_multi"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_ilmbaseconfig"].includedirs.append(
            include_dir)

        # Half
        self.cpp_info.components["ilmbase_half"].names[
            "cmake_find_package"] = "Half"
        self.cpp_info.components["ilmbase_half"].names[
            "cmake_find_package_multi"] = "Half"
        self.cpp_info.components["ilmbase_half"].builddirs.append(
            self._module_subfolder)
        self.cpp_info.components["ilmbase_half"].build_modules[
            "cmake_find_package"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_half"].build_modules[
            "cmake_find_package_multi"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_half"].includedirs.append(
            include_dir)
        self.cpp_info.components["ilmbase_half"].libs = [
            "Half{}".format(lib_suffix)
        ]
        self.cpp_info.components["ilmbase_half"].requires = [
            "ilmbase_ilmbaseconfig"
        ]

        # Iex
        self.cpp_info.components["ilmbase_iex"].names[
            "cmake_find_package"] = "Iex"
        self.cpp_info.components["ilmbase_iex"].names[
            "cmake_find_package_multi"] = "Iex"
        self.cpp_info.components["ilmbase_iex"].builddirs.append(
            self._module_subfolder)
        self.cpp_info.components["ilmbase_iex"].build_modules[
            "cmake_find_package"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_iex"].build_modules[
            "cmake_find_package_multi"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_iex"].includedirs.append(include_dir)
        self.cpp_info.components["ilmbase_iex"].libs = [
            "Iex{}".format(lib_suffix)
        ]
        self.cpp_info.components["ilmbase_iex"].requires = [
            "ilmbase_ilmbaseconfig"
        ]

        # IexMath
        self.cpp_info.components["ilmbase_iexmath"].names[
            "cmake_find_package"] = "IexMath"
        self.cpp_info.components["ilmbase_iexmath"].names[
            "cmake_find_package_multi"] = "IexMath"
        self.cpp_info.components["ilmbase_iexmath"].builddirs.append(
            self._module_subfolder)
        self.cpp_info.components["ilmbase_iexmath"].build_modules[
            "cmake_find_package"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_iexmath"].build_modules[
            "cmake_find_package_multi"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_iexmath"].includedirs.append(
            include_dir)
        self.cpp_info.components["ilmbase_iexmath"].libs = [
            "IexMath{}".format(lib_suffix)
        ]
        self.cpp_info.components["ilmbase_iexmath"].requires = [
            "ilmbase_ilmbaseconfig", "ilmbase_iex"
        ]

        # IMath
        self.cpp_info.components["ilmbase_imath"].names[
            "cmake_find_package"] = "IMath"
        self.cpp_info.components["ilmbase_imath"].names[
            "cmake_find_package_multi"] = "IMath"
        self.cpp_info.components["ilmbase_imath"].builddirs.append(
            self._module_subfolder)
        self.cpp_info.components["ilmbase_imath"].build_modules[
            "cmake_find_package"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_imath"].build_modules[
            "cmake_find_package_multi"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_imath"].includedirs.append(
            include_dir)
        self.cpp_info.components["ilmbase_imath"].libs = [
            "Imath{}".format(lib_suffix)
        ]
        self.cpp_info.components["ilmbase_imath"].requires = [
            "ilmbase_ilmbaseconfig", "ilmbase_half", "ilmbase_iexmath"
        ]

        # IlmThread
        self.cpp_info.components["ilmbase_ilmthread"].names[
            "cmake_find_package"] = "IlmThread"
        self.cpp_info.components["ilmbase_ilmthread"].names[
            "cmake_find_package_multi"] = "IlmThread"
        self.cpp_info.components["ilmbase_ilmthread"].builddirs.append(
            self._module_subfolder)
        self.cpp_info.components["ilmbase_ilmthread"].build_modules[
            "cmake_find_package"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_ilmthread"].build_modules[
            "cmake_find_package_multi"] = [self._module_file_rel_path]
        self.cpp_info.components["ilmbase_ilmthread"].includedirs.append(
            include_dir)
        self.cpp_info.components["ilmbase_ilmthread"].libs = [
            "IlmThread{}".format(lib_suffix)
        ]
        self.cpp_info.components["ilmbase_ilmthread"].requires = [
            "ilmbase_ilmbaseconfig", "ilmbase_iex"
        ]
        if self.settings.os in ["Linux", "FreeBSD"]:
            self.cpp_info.components["ilmbase_ilmthread"].system_libs.append(
                "pthread")

        # Convenient component to model official IlmBase.pc
        self.cpp_info.components["ilmbase_conan_pkgconfig"].names[
            "pkg_config"] = "IlmBase"
        self.cpp_info.components["ilmbase_conan_pkgconfig"].requires = [
            "ilmbase_ilmbaseconfig", "ilmbase_half", "ilmbase_iex",
            "ilmbase_iexmath", "ilmbase_imath", "ilmbase_ilmthread"
        ]

        if self.options.shared and self.settings.os == "Windows":
            self.cpp_info.components["openexr_ilmimfconfig"].defines.append(
                "OPENEXR_DLL")
            self.cpp_info.components["ilmbase_ilmbaseconfig"].defines.append(
                "OPENEXR_DLL")

        stdlib = tools.stdcpp_library(self)
        if not self.options.shared and stdlib:
            self.cpp_info.components[
                "openexr_ilmimfconfig"].system_libs.append(stdlib)
            self.cpp_info.components[
                "ilmbase_ilmbaseconfig"].system_libs.append(stdlib)
Example #60
0
class LibnameConan(ConanFile):
    name = "ModernVRML"
    description = "Keep it short"
    topics = ("conan", "libname", "logging")
    url = "https://github.com/themhmoritz3/conan-ModernVRML"
    homepage = "https://github.com/original_author/original_lib"
    license = "MIT"  # Indicates license type of the packaged library; please use SPDX Identifiers https://spdx.org/licenses/
    exports_sources = ["*"]
    generators = "cmake"

    version = "NVP"

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

    _source_subfolder = "."
    _build_subfolder = "build_subfolder"
    _cmake = None

    requires = ()

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

    def requirements(self):
        if self.settings.os == 'Linux':
            self.requires("boost/1.72.0")

    def source(self):
        tools.replace_in_file(
            self._source_subfolder + "/CMakeLists.txt",
            "project(ModernVRML VERSION 0.0.1 DESCRIPTION \"mylib description\")",
            '''if(EXISTS "${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake")
  include("${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake")
else()
  include(../conanbuildinfo.cmake)
endif()
conan_basic_setup()''')
        #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["BUILD_TESTS"] = False  # example
            self._cmake.configure(source_folder=self._source_subfolder,
                                  build_folder=self._build_subfolder)
        return self._cmake

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

    def package(self):
        self.copy(pattern="LICENSE",
                  dst="licenses",
                  src=self._source_subfolder)
        cmake = self._configure_cmake()
        cmake.install()
        # If the CMakeLists.txt has a proper install method, the steps below may be redundant
        # If so, you can just remove the lines below
        include_folder = os.path.join(self._source_subfolder, "include")
        self.copy(pattern="*", dst="include", src=include_folder)
        self.copy(pattern="*.dll", dst="bin", keep_path=False)
        self.copy(pattern="*.lib", dst="lib", keep_path=False)
        self.copy(pattern="*.a", dst="lib", keep_path=False)
        self.copy(pattern="*.so*", dst="lib", keep_path=False)
        self.copy(pattern="*.dylib", dst="lib", keep_path=False)

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