-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7266d08
commit 493ad5b
Showing
7 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sources: | ||
"1.17.39": | ||
url: "https://github.com/oneapi-src/level-zero/archive/refs/tags/v1.17.39.tar.gz" | ||
sha256: "70473c7262eee80dbe7c17974684ba9d3e34efc15ecba919b85e3cea7b1e180e" | ||
patches: | ||
"1.17.39": | ||
- patch_file: "patches/1.17.39/001-patch-remove-qspectre.patch" | ||
patch_description: "Removed /Qspectre" | ||
patch_type: "portability" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.env import VirtualBuildEnv | ||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps | ||
from conan.tools.files import get, apply_conandata_patches, copy, export_conandata_patches, rmdir | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.scm import Version | ||
import os | ||
|
||
|
||
class LevelZeroConan(ConanFile): | ||
name = "level-zero" | ||
license = "MIT" | ||
homepage = "https://github.com/oneapi-src/level-zero" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
description = "OneAPI Level Zero Specification Headers and Loader" | ||
topics = ("api-headers", "loader", "level-zero", "oneapi") | ||
package_type = "shared-library" | ||
|
||
# Binary configuration | ||
settings = "os", "arch", "compiler", "build_type" | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 14 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"apple-clang": "10", | ||
"clang": "7", | ||
"gcc": "7", | ||
"msvc": "190", | ||
"Visual Studio": "15", | ||
} | ||
|
||
def requirements(self): | ||
self.requires("spdlog/1.14.1") | ||
|
||
def source(self): | ||
version_data = self.conan_data["sources"][self.version] | ||
get(self, **version_data, strip_root=True) | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def generate(self): | ||
deps = CMakeDeps(self) | ||
deps.generate() | ||
|
||
toolchain = CMakeToolchain(self) | ||
toolchain.generate() | ||
|
||
def validate(self): | ||
if self.settings.os == "Macos": | ||
raise ConanInvalidConfiguration("This recipe doesn't prepared for macOS.") | ||
if self.settings.os == "Windows": | ||
if self.settings.get_safe("subsystem") == "uwp": | ||
raise ConanInvalidConfiguration(f"{self.ref} does not support UWP on Windows.") | ||
if self.settings.compiler.cppstd: | ||
check_min_cppstd(self, self._min_cppstd) | ||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) | ||
if minimum_version and Version(self.settings.compiler.version) < minimum_version: | ||
raise ConanInvalidConfiguration( | ||
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." | ||
) | ||
|
||
def build(self): | ||
apply_conandata_patches(self) | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
cmake = CMake(self) | ||
cmake.install() | ||
copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
|
||
def package_info(self): | ||
self.cpp_info.components["ze-loader"].libs = ["ze_loader"] | ||
self.cpp_info.components["ze-loader"].includedirs = ["include", "include/level_zero"] | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.components["ze-loader"].system_libs = ["pthread"] | ||
elif self.settings.os == "Windows": | ||
self.cpp_info.components["ze-loader"].system_libs = ["cfgmgr32"] | ||
self.cpp_info.components["ze-loader"].set_property("pkg_config_name", "libze_loader") | ||
self.cpp_info.components["level-zero"].requires = ["ze-loader"] | ||
self.cpp_info.components["level-zero"].set_property("pkg_config_name", "level-zero") | ||
|
17 changes: 17 additions & 0 deletions
17
recipes/level-zero/all/patches/1.17.39/001-patch-remove-qspectre.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index ac2ab9f..5282757 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -132,12 +132,6 @@ if(MSVC) | ||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DYNAMICBASE") | ||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /guard:cf") | ||
# enable Spectre Mitigation, not supported by clang-cl | ||
- if((NOT CMAKE_CXX_COMPILER_ID STREQUAL Clang) AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL IntelLLVM)) | ||
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qspectre") | ||
- endif() | ||
- if((NOT CMAKE_C_COMPILER_ID STREQUAL Clang) AND NOT (CMAKE_C_COMPILER_ID STREQUAL IntelLLVM)) | ||
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Qspectre") | ||
- endif() | ||
endif() | ||
|
||
#CXX compiler support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.2.0) | ||
project(test_package LANGUAGES CXX) | ||
|
||
find_package(level-zero CONFIG REQUIRED) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE level-zero::level-zero) | ||
|
||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindir, "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "ze_api.h" | ||
|
||
int main() { | ||
zeInit(0); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"1.17.39": | ||
folder: "all" |