Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 25 additions & 30 deletions recipes/lief/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.microsoft import is_msvc
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
from conan.tools.microsoft import check_min_vs, is_msvc
from conan.tools.scm import Version

import os

required_conan_version = ">=1.53.0"
required_conan_version = ">=1.57.0"

class LiefConan(ConanFile):
name = "lief"
Expand All @@ -17,6 +17,7 @@ class LiefConan(ConanFile):
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/lief-project/LIEF"
topics = ("executable", "elf", "pe", "mach-o")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
Expand Down Expand Up @@ -48,8 +49,8 @@ class LiefConan(ConanFile):
}

@property
def _minimum_cpp_standard(self):
return 11
def _min_cppstd(self):
return "11"

def export_sources(self):
export_conandata_patches(self)
Expand All @@ -62,39 +63,36 @@ def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def validate(self):
if self.info.settings.compiler.cppstd:
check_min_cppstd(self, self._minimum_cpp_standard)

if ((self.info.settings.compiler == "Visual Studio" and Version(self.info.settings.compiler.version) <= "14")
or
(self.info.settings.compiler == "msvc" and Version(self.info.settings.compiler.version) <= "190")) \
and self.options.shared:
raise ConanInvalidConfiguration(f"{self.ref} does not support Visual Studio <= 14 with shared:True")

if self.info.settings.compiler.get_safe("libcxx") == "libstdc++":
raise ConanInvalidConfiguration(f"{self.ref} does not support libstdc++")

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("mbedtls/3.2.1")
if Version(self.version) < "0.12.2":
self.requires("rang/3.2")
self.requires("mbedtls/3.2.1")
else:
self.requires("utfcpp/3.2.3")
# lief doesn't supprot spdlog/1.11.0 with fmt/9.x yet.
self.requires("spdlog/1.10.0")
self.requires("boost/1.81.0", transitive_headers=True)
self.requires("tcb-span/cci.20220616", transitive_headers=True)
if self.options.with_json:
self.requires("nlohmann_json/3.11.2")
if self.options.with_frozen:
self.requires("frozen/1.1.1")
if Version(self.version) >= "0.12.2":
self.requires("utfcpp/3.2.2")
# lief doesn't supprot spdlog/1.11.0 with fmt/9.x yet.
self.requires("spdlog/1.10.0")
self.requires("boost/1.81.0")
self.requires("tcb-span/cci.20220616")

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

if self.options.shared and is_msvc(self) and not check_min_vs(self, "191", raise_invalid=False):
raise ConanInvalidConfiguration(f"{self.ref} does not support Visual Studio < 15 with shared:True")

if self.settings.compiler.get_safe("libcxx") == "libstdc++":
raise ConanInvalidConfiguration(f"{self.ref} does not support libstdc++")

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

def generate(self):
tc = CMakeToolchain(self)
Expand Down Expand Up @@ -157,8 +155,5 @@ def package_info(self):
self.cpp_info.system_libs.append("m")

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.filenames["cmake_find_package"] = "LIEF"
self.cpp_info.filenames["cmake_find_package_multi"] = "LIEF"
self.cpp_info.names["cmake_find_package"] = "LIEF"
self.cpp_info.names["cmake_find_package_multi"] = "LIEF"
self.cpp_info.names["pkg_config"] = "LIEF"