|
| 1 | +from conans import ConanFile, CMake, tools |
| 2 | +import os |
| 3 | + |
| 4 | +required_conan_version = ">=1.33.0" |
| 5 | + |
| 6 | + |
| 7 | +class VcConan(ConanFile): |
| 8 | + name = "vc" |
| 9 | + description = "SIMD Vector Classes for C++." |
| 10 | + license = "BSD-3-Clause" |
| 11 | + topics = ("vc", "simd", "vectorization", "parallel", "sse", "avx", "neon") |
| 12 | + homepage = "https://github.com/VcDevel/Vc" |
| 13 | + url = "https://github.com/conan-io/conan-center-index" |
| 14 | + |
| 15 | + settings = "os", "arch", "compiler", "build_type" |
| 16 | + options = {"fPIC": [True, False]} |
| 17 | + default_options = {"fPIC": True} |
| 18 | + |
| 19 | + exports_sources = "CMakeLists.txt" |
| 20 | + generators = "cmake" |
| 21 | + _cmake = None |
| 22 | + |
| 23 | + @property |
| 24 | + def _source_subfolder(self): |
| 25 | + return "source_subfolder" |
| 26 | + |
| 27 | + @property |
| 28 | + def _build_subfolder(self): |
| 29 | + return "build_subfolder" |
| 30 | + |
| 31 | + def config_options(self): |
| 32 | + if self.settings.os == "Windows": |
| 33 | + del self.options.fPIC |
| 34 | + |
| 35 | + def validate(self): |
| 36 | + if self.settings.compiler.get_safe("cppstd"): |
| 37 | + tools.check_min_cppstd(self, 11) |
| 38 | + |
| 39 | + def source(self): |
| 40 | + tools.get(**self.conan_data["sources"][self.version], |
| 41 | + destination=self._source_subfolder, strip_root=True) |
| 42 | + |
| 43 | + def _patch_sources(self): |
| 44 | + cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") |
| 45 | + tools.replace_in_file(cmakelists, "CMAKE_SOURCE_DIR", "CMAKE_CURRENT_SOURCE_DIR") |
| 46 | + tools.replace_in_file(cmakelists, "AddCompilerFlag(\"-fPIC\" CXX_FLAGS libvc_compile_flags)", "") |
| 47 | + |
| 48 | + def _configure_cmake(self): |
| 49 | + if self._cmake: |
| 50 | + return self._cmake |
| 51 | + self._cmake = CMake(self) |
| 52 | + self._cmake.configure(build_folder=self._build_subfolder) |
| 53 | + return self._cmake |
| 54 | + |
| 55 | + def build(self): |
| 56 | + self._patch_sources() |
| 57 | + cmake = self._configure_cmake() |
| 58 | + cmake.build() |
| 59 | + |
| 60 | + def package(self): |
| 61 | + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) |
| 62 | + cmake = self._configure_cmake() |
| 63 | + cmake.install() |
| 64 | + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) |
| 65 | + |
| 66 | + def package_info(self): |
| 67 | + self.cpp_info.names["cmake_find_package"] = "Vc" |
| 68 | + self.cpp_info.names["cmake_find_package_multi"] = "Vc" |
| 69 | + self.cpp_info.libs = ["Vc"] |
0 commit comments