Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vulkan-utility-libraries: add new recipe #21059

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3105641
vulkan-utility-libraries: add new recipe
valgur Nov 10, 2023
e21884a
vulkan-utility-libraries: rmdir lib/cmake
valgur Nov 17, 2023
325f6ba
vulkan-utility-libraries: fix OS check
valgur Nov 23, 2023
fff779e
vulkan-utility-libraries: apply PR suggestions
valgur Nov 27, 2023
9113788
Improve test_package.cpp
valgur Nov 29, 2023
68b624c
vulkan-utility-libraries: handle API change in test_package.cpp
valgur Nov 29, 2023
b74c6ff
Merge branch 'master' into new/vulkan-utility-libraries
valgur Nov 30, 2023
18ea3d2
Merge branch 'master' into new/vulkan-utility-libraries
valgur Nov 30, 2023
0a2fdd4
Merge branch 'master' into new/vulkan-utility-libraries
ErniGH Jun 11, 2024
45bd176
Do not enforce /MP
uilianries Jun 11, 2024
2ba23f3
Removing no opetion component
uilianries Jun 11, 2024
f8edcb6
Merge branch 'master' into new/vulkan-utility-libraries
ErniGH Jun 11, 2024
61b51d7
Add Vulkan SDK 1.3.290.0 library versions
valgur Sep 18, 2024
d230d6f
vulkan-utility-libraries: add SafeStruct component, shorter component…
valgur Oct 16, 2024
89a29a7
Merge remote-tracking branch 'upstream/master' into new/vulkan-utilit…
valgur Jan 21, 2025
2447510
vulkan-utility-libraries: drop Conan v1 compatibility features
valgur Jan 21, 2025
3a46755
vulkan-utility-libraries: drop exported warning flags
valgur Jan 21, 2025
e299be6
vulkan-utility-libraries: add missing license file
valgur Jan 21, 2025
514c0f8
vulkan-utility-libraries: drop old versions, add v1.3.296.0
valgur Jan 21, 2025
1be1909
vulkan-utility-libraries: fix cpp_info requires
valgur Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions recipes/vulkan-utility-libraries/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sources:
"1.3.268.0":
url: "https://github.com/KhronosGroup/Vulkan-Utility-Libraries/archive/refs/tags/vulkan-sdk-1.3.268.0.tar.gz"
sha256: "0352a6a9a703a969a805e0d6498e013cba2dc7091cc2013b7c89b1a21f61e3f8"
"1.3.261.1":
url: "https://github.com/KhronosGroup/Vulkan-Utility-Libraries/archive/refs/tags/sdk-1.3.261.1.tar.gz"
sha256: "32c8be9806fd412012752324c53cd661594edd21adf7ba5081229481274f802b"
178 changes: 178 additions & 0 deletions recipes/vulkan-utility-libraries/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name, is_apple_os
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import copy, get, rm, rmdir, replace_in_file
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version

required_conan_version = ">=1.55.0"


class VulkanUtilityLibrariesConan(ConanFile):
name = "vulkan-utility-libraries"
description = "Utility libraries for Vulkan developers"
license = "Apache-2.0"
topics = ("vulkan",)
homepage = "https://github.com/KhronosGroup/Vulkan-Utility-Libraries"
url = "https://github.com/conan-io/conan-center-index"

package_type = "static-library"
settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
}
default_options = {
"fPIC": True,
}

@property
def _min_cppstd(self):
return 17

@property
def _compilers_minimum_version(self):
return {
"apple-clang": "9",
"clang": "7",
"gcc": "8",
"msvc": "191",
"Visual Studio": "15.7",
}

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

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires(f"vulkan-headers/{self.version}", transitive_headers=True)

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)

def loose_lt_semver(v1, v2):
return all(int(p1) < int(p2) for p1, p2 in zip(v1.split("."), v2.split(".")))

minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version):
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.",
)

def build_requirements(self):
self.tool_requires("cmake/[>=3.17.2 <4]")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
env = VirtualBuildEnv(self)
env.generate()
tc = CMakeToolchain(self)
tc.variables["BUILD_TESTS"] = False
tc.generate()
deps = CMakeDeps(self)
deps.generate()

def _patch_sources(self):
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
"set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "")

def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
fix_apple_shared_install_name(self)

@property
def _exported_cxxflags(self):
# https://github.com/KhronosGroup/Vulkan-Utility-Libraries/blob/vulkan-sdk-1.3.268.0/src/CMakeLists.txt#L9-L40
cxxflags = []
if self.settings.compiler in ["gcc", "clang", "apple-clang"]:
cxxflags += [
"-Wpedantic",
"-Wunreachable-code",
"-Wunused-function",
"-Wall",
"-Wextra",
"-Wpointer-arith",
"-Wextra-semi",
]
if self.settings.compiler != "gcc":
cxxflags += [
"-Wunreachable-code-return",
"-Wconversion",
"-Wimplicit-fallthrough",
"-Wstring-conversion",
]
elif is_msvc(self):
cxxflags += [
"/W4",
"/we5038",
"/permissive-",
"/MP",
]
return cxxflags

@property
def _exported_defines(self):
# https://github.com/KhronosGroup/Vulkan-Utility-Libraries/blob/vulkan-sdk-1.3.268.0/src/CMakeLists.txt#L42-L56
defines = ["VK_ENABLE_BETA_EXTENSIONS"]
if self.settings.os == "Windows":
defines += [
"NOMINMAX",
"WIN32_LEAN_AND_MEAN",
"VK_USE_PLATFORM_WIN32_KHR",
]
elif self.settings.os == "Android":
defines.append("VK_USE_PLATFORM_ANDROID_KHR")
elif is_apple_os(self):
defines.append("VK_USE_PLATFORM_METAL_EXT")
if self.settings.os == "iOS":
defines.append("VK_USE_PLATFORM_IOS_MVK")
else:
defines.append("VK_USE_PLATFORM_MACOS_MVK")
return defines

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "VulkanUtilityLibraries")

# Vulkan::UtilityHeaders
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scondratev Could you please elaborate a bit more your case? What specific cmake variable is not available? Still, is possible to manage cmake variables generated by Conan CMakeDeps too.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've solved my problem, I forgot to add --config Release when I was building my project with the VS generator. Sorry.

self.cpp_info.components["VulkanUtilityHeaders"].set_property("cmake_target_name", "Vulkan::UtilityHeaders")
self.cpp_info.components["VulkanUtilityHeaders"].requires = ["vulkan-headers::vulkanheaders"]
self.cpp_info.components["VulkanUtilityHeaders"].libdirs = []
self.cpp_info.components["VulkanUtilityHeaders"].bindirs = []

# Vulkan::LayerSettings
self.cpp_info.components["VulkanLayerSettings"].set_property("cmake_target_name", "Vulkan::LayerSettings")
self.cpp_info.components["VulkanLayerSettings"].requires = ["vulkan-headers::vulkanheaders", "VulkanUtilityHeaders"]
self.cpp_info.components["VulkanLayerSettings"].libs = ["VulkanLayerSettings"]
self.cpp_info.components["VulkanLayerSettings"].bindirs = []

# Vulkan::CompilerConfiguration
if Version(self.version) >= "1.3.265":
self.cpp_info.components["VulkanCompilerConfiguration"] = self.cpp_info.components["VulkanCompilerConfiguration"]
self.cpp_info.components["VulkanCompilerConfiguration"].set_property("cmake_target_name", "Vulkan::CompilerConfiguration")
self.cpp_info.components["VulkanCompilerConfiguration"].requires = ["vulkan-headers::vulkanheaders"]
self.cpp_info.components["VulkanCompilerConfiguration"].cxxflags = self._exported_cxxflags
self.cpp_info.components["VulkanCompilerConfiguration"].defines = self._exported_defines
self.cpp_info.components["VulkanCompilerConfiguration"].includedirs = []
self.cpp_info.components["VulkanCompilerConfiguration"].libdirs = []
self.cpp_info.components["VulkanCompilerConfiguration"].bindirs = []
self.cpp_info.components["VulkanLayerSettings"].requires.append("VulkanCompilerConfiguration")
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(VulkanUtilityLibraries REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE Vulkan::LayerSettings)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
26 changes: 26 additions & 0 deletions recipes/vulkan-utility-libraries/all/test_package/conanfile.py
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, cmake_layout
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

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")
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <vulkan/layer/vk_layer_settings.hpp>
#include <iostream>

int main() {
std::cout << VK_EXT_LAYER_SETTINGS_EXTENSION_NAME << std::endl;
return 0;
}
5 changes: 5 additions & 0 deletions recipes/vulkan-utility-libraries/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
versions:
"1.3.268.0":
folder: all
"1.3.261.1":
folder: all