|
| 1 | +from conans import ConanFile, CMake, tools |
| 2 | +import os |
| 3 | + |
| 4 | + |
| 5 | +class LibmodplugConan(ConanFile): |
| 6 | + name = "libmodplug" |
| 7 | + description = "libmodplug - the library which was part of the Modplug-xmms project" |
| 8 | + topics = ("conan", "libmodplug", "auduo", "multimedia", "sound", "music", "mod", "mod music", |
| 9 | + "tracket music") |
| 10 | + url = "https://github.com/conan-io/conan-center-index" |
| 11 | + homepage = "http://modplug-xmms.sourceforge.net" |
| 12 | + license = "Unlicense" # public domain |
| 13 | + exports_sources = ["CMakeLists.txt"] |
| 14 | + generators = "cmake" |
| 15 | + |
| 16 | + settings = "os", "arch", "compiler", "build_type" |
| 17 | + options = {"shared": [True, False], "fPIC": [True, False]} |
| 18 | + default_options = {"shared": False, "fPIC": True} |
| 19 | + |
| 20 | + _source_subfolder = "source_subfolder" |
| 21 | + _build_subfolder = "build_subfolder" |
| 22 | + |
| 23 | + def config_options(self): |
| 24 | + if self.settings.os == "Windows": |
| 25 | + del self.options.fPIC |
| 26 | + |
| 27 | + def source(self): |
| 28 | + commit = os.path.splitext(os.path.basename(self.conan_data["sources"][self.version]["url"]))[0] |
| 29 | + tools.get(**self.conan_data["sources"][self.version]) |
| 30 | + extracted_dir = self.name + "-" + commit |
| 31 | + os.rename(extracted_dir, self._source_subfolder) |
| 32 | + |
| 33 | + def _configure_cmake(self): |
| 34 | + cmake = CMake(self) |
| 35 | + cmake.configure(build_folder=self._build_subfolder) |
| 36 | + return cmake |
| 37 | + |
| 38 | + def build(self): |
| 39 | + cmake = self._configure_cmake() |
| 40 | + cmake.build() |
| 41 | + |
| 42 | + def package(self): |
| 43 | + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) |
| 44 | + cmake = self._configure_cmake() |
| 45 | + cmake.install() |
| 46 | + |
| 47 | + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) |
| 48 | + |
| 49 | + def package_info(self): |
| 50 | + self.cpp_info.libs = ["modplug"] |
| 51 | + self.cpp_info.bindirs = ["lib"] |
| 52 | + self.cpp_info.includedirs.append(os.path.join("include", "libmodplug")) |
| 53 | + if not self.options.shared: |
| 54 | + self.cpp_info.defines.append("MODPLUG_STATIC") |
0 commit comments