Skip to content

Commit

Permalink
Fix dependency detection
Browse files Browse the repository at this point in the history
  • Loading branch information
laggykiller committed Sep 9, 2023
1 parent de5e718 commit c3a592f
Showing 1 changed file with 8 additions and 31 deletions.
39 changes: 8 additions & 31 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,8 @@ class ApngasmRecipe(ConanFile):
'foreach.hpp'
]

def check_lib_present(self, target):
if platform.system() != 'Linux':
return False

result = subprocess.run(
['sh', '-c', "ldconfig -p | tail -n +2 | grep -o '/.*/' | sort -u"],
stdout = subprocess.PIPE,
stderr = subprocess.PIPE
)
lib_dirs = result.stdout.decode().split('\n')

for lib_dir in lib_dirs:
if not os.path.exists(lib_dir):
continue

if target in os.listdir(lib_dir):
return True

return False

def check_header_present(self, target):
if platform.system() != 'Linux':
return False

if target in os.listdir('/usr/include'):
def check_file_present(self, target, search_path):
if target in os.listdir(search_path):
return True

return False
Expand All @@ -71,20 +48,20 @@ def requirements(self):
self.generators = ['CMakeToolchain', 'CMakeDeps']

if not (platform.system() == 'Linux' and
all([self.check_lib_present(i) for i in self.zlib_libs]) and
all([self.check_header_present(i) for i in self.zlib_headers])):
all([self.check_file_present(i, '/usr/lib') for i in self.zlib_libs]) and
all([self.check_file_present(i, '/usr/include') for i in self.zlib_headers])):

self.requires("zlib/1.2.13")

if not (platform.system() == 'Linux' and
all([self.check_lib_present(i) for i in self.libpng_libs]) and
all([self.check_header_present(i) for i in self.libpng_headers])):
all([self.check_file_present(i, '/usr/lib') for i in self.libpng_libs]) and
all([self.check_file_present(i, '/usr/include') for i in self.libpng_headers])):

self.requires("libpng/1.6.40")

if not (platform.system() == 'Linux' and
all([self.check_lib_present(i) for i in self.boost_libs]) and
all([self.check_header_present(i) for i in self.boost_headers])):
all([self.check_file_present(i, '/usr/lib') for i in self.boost_libs]) and
all([self.check_file_present(i, '/usr/include/boost') for i in self.boost_headers])):

self.requires("boost/1.82.0")

Expand Down

0 comments on commit c3a592f

Please sign in to comment.