Skip to content

Commit aa39d61

Browse files
SpaceImmadebr
authored andcommitted
(conan-io#5913) add vc/1.4.1
1 parent 038b9a0 commit aa39d61

File tree

7 files changed

+127
-0
lines changed

7 files changed

+127
-0
lines changed

recipes/vc/all/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 2.8.11)
2+
project(cmake_wrapper)
3+
4+
include(conanbuildinfo.cmake)
5+
conan_basic_setup()
6+
7+
add_subdirectory(source_subfolder)

recipes/vc/all/conandata.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sources:
2+
"1.4.1":
3+
url: "https://github.com/VcDevel/Vc/releases/download/1.4.1/Vc-1.4.1.tar.gz"
4+
sha256: "68e609a735326dc3625e98bd85258e1329fb2a26ce17f32c432723b750a4119f"

recipes/vc/all/conanfile.py

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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"]
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(test_package)
3+
4+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5+
conan_basic_setup(TARGETS)
6+
7+
find_package(Vc REQUIRED CONFIG)
8+
9+
add_executable(${PROJECT_NAME} test_package.cpp)
10+
target_link_libraries(${PROJECT_NAME} Vc::Vc)
11+
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from conans import ConanFile, CMake, tools
2+
import os
3+
4+
5+
class TestPackageConan(ConanFile):
6+
settings = "os", "arch", "compiler", "build_type"
7+
generators = "cmake", "cmake_find_package_multi"
8+
9+
def build(self):
10+
cmake = CMake(self)
11+
cmake.configure()
12+
cmake.build()
13+
14+
def test(self):
15+
if not tools.cross_building(self.settings):
16+
bin_path = os.path.join("bin", "test_package")
17+
self.run(bin_path, run_environment=True)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <Vc/Vc>
2+
3+
#include <iostream>
4+
5+
using Vec3D = std::array<Vc::float_v, 3>;
6+
7+
Vc::float_v scalar_product(Vec3D a, Vec3D b) {
8+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
9+
}
10+
11+
int main() {
12+
Vec3D a{1, 2, 3};
13+
Vec3D b{3, 4, 5};
14+
std::cout << scalar_product(a, b) << std::endl;
15+
return 0;
16+
}

recipes/vc/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
"1.4.1":
3+
folder: all

0 commit comments

Comments
 (0)