Skip to content

Commit

Permalink
Merge pull request #1 from madebr/pr_volk
Browse files Browse the repository at this point in the history
volk: use fixed commit hash
  • Loading branch information
Mark Nefedov authored May 7, 2020
2 parents 831b2ee + 02ba5aa commit 7d67d6c
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 30 deletions.
7 changes: 7 additions & 0 deletions recipes/volk/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory(source_subfolder)
4 changes: 4 additions & 0 deletions recipes/volk/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"20200318":
url: "https://github.com/zeux/volk/archive/ed4c168595bc7c5d36925f0036ea14d36b20c87c.zip"
sha256: "7c7179db256e54cbb2b1e21dfa8ed7f050d0129723f0a2be3d607feb5b53ba1a"
59 changes: 48 additions & 11 deletions recipes/volk/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from conans import ConanFile, CMake, tools
import os


class VolkConan(ConanFile):
Expand All @@ -14,24 +15,60 @@ class VolkConan(ConanFile):
loading Vulkan entrypoints directly from the driver which \
can increase performance by skipping loader dispatch \
overhead."
topics = ("Vulkan", "graphics")
topics = ("Vulkan", "loader", "extension", "entrypoint", "graphics")
settings = "os", "compiler", "build_type", "arch"
options = {
"fPIC": [True, False],
}
default_options = {
"fPIC": True,
}
exports_sources = "CMakeLists.txt"
generators = "cmake"
no_copy_source = True

_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def requirements(self):
self.requires("vulkan-headers/1.2.135.0")

def source(self):
self.run("git clone https://github.com/zeux/volk.git")
self.run("cd volk/ && git checkout %s" % self.version)
tools.get(**self.conan_data["sources"][self.version])
commithash, _ = os.path.splitext(os.path.basename(self.conan_data["sources"][self.version]["url"]))
os.rename("volk-{}".format(commithash), self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["VOLK_INSTALL"] = True
self._cmake.configure()
return self._cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("*volk.h", dst="include")
self.copy("*volk.c", dst="include")
self.copy("*LICENSE.md", dst="licenses")
self.copy("LICENSE.md", src=self._source_subfolder, dst="licenses")
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
self.cpp_info.components["volk_headers"].requires = ["vulkan-headers::vulkan-headers"]
if self.settings.os == "Linux":
self.cpp_info.libs.extend(["dl"])

def package_id(self):
self.info.header_only()
self.cpp_info.components["volk_headers"].system_libs = ["dl"]

self.cpp_info.components["libvolk"].libs = ["volk"]
self.cpp_info.components["libvolk"].system_libs = ["dl"]
self.cpp_info.components["libvolk"].requires = ["volk_headers"]
self.cpp_info.components["libvolk"].names["cmake_find_package"] = ["volk"]
self.cpp_info.components["libvolk"].names["cmake_find_package_multi"] = ["volk"]
16 changes: 7 additions & 9 deletions recipes/volk/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
cmake_minimum_required(VERSION 2.8.12)
project(PackageTest CXX)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup()

add_executable(example example.cpp)
target_link_libraries(example ${CONAN_LIBS})
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})

# CTest is a testing tool that can be used to test your project.
# enable_testing()
# add_test(NAME example
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
# COMMAND example)
add_executable(${PROJECT_NAME}_nolibs test_package.c)
target_compile_definitions(${PROJECT_NAME}_nolibs PRIVATE VOLK_IMPLEMENTATION)
target_link_libraries(${PROJECT_NAME}_nolibs ${CONAN_SYSTEM_LIBS_VOLK})
7 changes: 3 additions & 4 deletions recipes/volk/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ class VolkTestConan(ConanFile):

def build(self):
cmake = CMake(self)
# Current dir is "test_package/build/<build_id>" and CMakeLists.txt is
# in "test_package"
cmake.verbose = True
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
os.chdir("bin")
self.run(".%sexample" % os.sep)
self.run(os.path.join("bin", "test_package"))
self.run(os.path.join("bin", "test_package_nolibs"))
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <iostream>
#define VOLK_IMPLEMENTATION
#include <volk/volk.h>
#include "volk.h"

#include <stdio.h>

int main() {
/* Try to initialize volk. This might not work on CI builds,
Expand All @@ -13,4 +13,3 @@ int main() {
VK_VERSION_PATCH(version)
);
}

5 changes: 3 additions & 2 deletions recipes/volk/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
versions:
"ed4c168595bc7c5d36925f0036ea14d36b20c87c":
folder: all
"20200318":
folder: "all"

0 comments on commit 7d67d6c

Please sign in to comment.