Skip to content

Commit

Permalink
Fix Macos build
Browse files Browse the repository at this point in the history
Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries committed Sep 19, 2023
1 parent 34022db commit 7d86026
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions recipes/compute_library/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from conan.tools.build import check_min_cppstd, cross_building, build_jobs
from conan.tools.scm import Version
from conan.tools.env import VirtualBuildEnv
from conan.tools.gnu import AutotoolsDeps
from conan.tools.layout import basic_layout
import os

Expand All @@ -29,7 +30,7 @@ class ComputeLibraryConan(ConanFile):
default_options = {
"shared": False,
"enable_openmp": False,
"enable_opencl": False,
"enable_opencl": True,
"enable_neon": True,
}

Expand All @@ -47,11 +48,14 @@ def _compilers_minimum_version(self):

def config_options(self):
# INFO: Neon option is reserved to arm architecture
if "arm" in str(self.settings.arch):
if "arm" not in str(self.settings.arch):
del self.options.enable_neon
# INFO: OpenCL option only works with g++, according to the documentation
# INFO: OpenMP option only works with g++, according to the documentation
if self.settings.compiler == "clang":
del self.options.enable_openmp
# INFO: OpenCL fails to build with MacOS
if self.settings.os == "Macos":
self.options.enable_opencl = False

def configure(self):
if self.options.shared:
Expand All @@ -63,6 +67,10 @@ def layout(self):
def build_requirements(self):
self.tool_requires("scons/4.3.0")

def requirements(self):
if self.options.enable_opencl:
self.requires("opencl-headers/2023.04.17")

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
Expand All @@ -81,21 +89,24 @@ def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = AutotoolsDeps(self)
tc.generate()
tc = VirtualBuildEnv(self)
tc.generate(scope="build")

def build(self):
# INFO: Using scons to build the library we don't have control over shared/static and install step, it is done all together always
# INFO: https://arm-software.github.io/ComputeLibrary/latest/how_to_build.xhtml
yes_no = lambda v: "1" if v else "0"
debug = yes_no(self.settings.build_type == "Debug")
os = str(self.settings.os).lower()
build_os = str(self.settings.os).lower()
arch = {"armv8": "armv8a", "x86": "x86_32", "armv7": "armv7a", "armv7hf": "armv7a-hf"}.get(str(self.settings.arch), str(self.settings.arch))
neon = yes_no(self.options.get_safe("enable_neon"))
opencl = yes_no(self.options.enable_opencl)
openmp = yes_no(self.options.get_safe("enable_openmp"))
build = "cross_compile" if cross_building(self) else "native"
with chdir(self, self.source_folder):
self.run(f"scons Werror=0 validation_tests=0 examples=0 openmp={openmp} debug={debug} neon={neon} opencl={opencl} os={os} arch={arch} build={build} build_dir={self.build_folder} install_dir={self.package_folder} -j{build_jobs(self)}", env="conanbuildenv")
self.run(f"scons Werror=0 validation_tests=0 examples=0 openmp={openmp} debug={debug} neon={neon} opencl={opencl} os={build_os} arch={arch} build={build} build_dir={self.build_folder} install_dir={self.package_folder} -j{build_jobs(self)}", env="conanbuild")

def package(self):
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
Expand Down

0 comments on commit 7d86026

Please sign in to comment.