2020-05-14 07:50:43 +08:00
|
|
|
# pylint: disable=not-callable
|
2021-04-09 15:08:24 +08:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
2020-05-14 07:50:43 +08:00
|
|
|
from conans import CMake
|
|
|
|
from conans import ConanFile
|
2021-04-09 15:08:24 +08:00
|
|
|
from conans.tools import collect_libs
|
|
|
|
from conans.tools import load
|
2020-05-14 07:50:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
class ToxConan(ConanFile):
|
2021-04-09 15:08:24 +08:00
|
|
|
name = "c-toxcore"
|
|
|
|
url = "https://tox.chat"
|
|
|
|
description = "The future of online communications."
|
|
|
|
license = "GPL-3.0-only"
|
2020-05-14 07:50:43 +08:00
|
|
|
settings = "os", "compiler", "build_type", "arch"
|
2022-02-07 07:53:41 +08:00
|
|
|
requires = "libsodium/1.0.18", "opus/1.3.1", "msgpack/3.3.0", "libvpx/1.9.0"
|
2020-05-14 07:50:43 +08:00
|
|
|
generators = "cmake_find_package"
|
2021-04-09 15:08:24 +08:00
|
|
|
scm = {"type": "git", "url": "auto", "revision": "auto"}
|
|
|
|
|
|
|
|
options = {"with_tests": [True, False]}
|
|
|
|
default_options = {"with_tests": False}
|
|
|
|
|
|
|
|
_cmake = None
|
|
|
|
|
|
|
|
def _create_cmake(self):
|
|
|
|
if self._cmake is not None:
|
|
|
|
return self._cmake
|
|
|
|
|
|
|
|
self._cmake = CMake(self)
|
|
|
|
self._cmake.definitions["AUTOTEST"] = self.options.with_tests
|
|
|
|
self._cmake.definitions["BUILD_MISC_TESTS"] = self.options.with_tests
|
2022-02-10 00:47:17 +08:00
|
|
|
self._cmake.definitions["ENABLE_SHARED"] = False
|
|
|
|
self._cmake.definitions["ENABLE_STATIC"] = True
|
2021-04-09 15:08:24 +08:00
|
|
|
self._cmake.definitions["MUST_BUILD_TOXAV"] = True
|
|
|
|
if self.settings.compiler == "Visual Studio":
|
|
|
|
self._cmake.definitions["MSVC_STATIC_SODIUM"] = True
|
|
|
|
|
|
|
|
self._cmake.configure()
|
|
|
|
return self._cmake
|
|
|
|
|
|
|
|
def set_version(self):
|
|
|
|
content = load(os.path.join(self.recipe_folder, "CMakeLists.txt"))
|
|
|
|
version_major = re.search(r"set\(PROJECT_VERSION_MAJOR \"(.*)\"\)",
|
|
|
|
content).group(1)
|
|
|
|
version_minor = re.search(r"set\(PROJECT_VERSION_MINOR \"(.*)\"\)",
|
|
|
|
content).group(1)
|
|
|
|
version_patch = re.search(r"set\(PROJECT_VERSION_PATCH \"(.*)\"\)",
|
|
|
|
content).group(1)
|
|
|
|
self.version = "%s.%s.%s" % (
|
|
|
|
version_major.strip(),
|
|
|
|
version_minor.strip(),
|
|
|
|
version_patch.strip(),
|
|
|
|
)
|
2020-05-14 07:50:43 +08:00
|
|
|
|
|
|
|
def requirements(self):
|
|
|
|
if self.settings.os == "Windows":
|
|
|
|
self.requires("pthreads4w/3.0.0")
|
|
|
|
|
|
|
|
def build(self):
|
2021-04-09 15:08:24 +08:00
|
|
|
cmake = self._create_cmake()
|
|
|
|
cmake.build()
|
2020-05-14 07:50:43 +08:00
|
|
|
|
2021-04-09 15:08:24 +08:00
|
|
|
if self.options.with_tests:
|
2022-01-09 07:49:02 +08:00
|
|
|
cmake.test(output_on_failure=True)
|
2020-05-14 07:50:43 +08:00
|
|
|
|
2021-04-09 15:08:24 +08:00
|
|
|
def package(self):
|
|
|
|
cmake = self._create_cmake()
|
|
|
|
cmake.install()
|
2020-05-14 07:50:43 +08:00
|
|
|
|
2021-04-09 15:08:24 +08:00
|
|
|
def package_info(self):
|
|
|
|
self.cpp_info.libs = collect_libs(self)
|
|
|
|
|
|
|
|
if self.settings.os == "Windows":
|
|
|
|
self.cpp_info.system_libs = ["Ws2_32", "Iphlpapi"]
|