diff --git a/recipes/moltenvk/all/CMakeLists.txt b/recipes/moltenvk/all/CMakeLists.txt new file mode 100644 index 0000000000000..86653777217f5 --- /dev/null +++ b/recipes/moltenvk/all/CMakeLists.txt @@ -0,0 +1,265 @@ +cmake_minimum_required(VERSION 3.12) +project(MoltenVK) + +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR + CMAKE_SYSTEM_NAME STREQUAL "iOS" OR + CMAKE_SYSTEM_NAME STREQUAL "tvOS")) + message(FATAL_ERROR "MoltenVK only supports MacOS, iOS and tvOS") +endif() + +option(MVK_WITH_SPIRV_TOOLS "Build MoltenVK without the MVK_EXCLUDE_SPIRV_TOOLS build setting" ON) +option(MVK_BUILD_SHADERCONVERTER_TOOL "Build MoltenVKShaderConverter" ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# PIC required for objects targets linked into shared MoltenVK +if(BUILD_SHARED_LIBS) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endif() + +# Required Apple Frameworks +find_library(METAL_FRAMEWORK Metal) +if(NOT METAL_FRAMEWORK) + message(FATAL_ERROR "Metal framework not found") +endif() +find_library(FOUNDATION_FRAMEWORK Foundation) +if(NOT FOUNDATION_FRAMEWORK) + message(FATAL_ERROR "Foundation framework not found") +endif() +find_library(QUARTZ_CORE_FRAMEWORK QuartzCore) +if(NOT QUARTZ_CORE_FRAMEWORK) + message(FATAL_ERROR "QuartzCore framework not found") +endif() +find_library(APPKIT_FRAMEWORK AppKit) +if(NOT APPKIT_FRAMEWORK) + message(FATAL_ERROR "AppKit framework not found") +endif() +find_library(IOSURFACE_FRAMEWORK IOSurface) +if(NOT IOSURFACE_FRAMEWORK) + message(FATAL_ERROR "IOSurface framework not found") +endif() +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + find_library(IO_OR_UI_KIT_FRAMEWORK IOKit) + if(NOT IO_OR_UI_KIT_FRAMEWORK) + message(FATAL_ERROR "IOKit framework not found") + endif() +else() + find_library(IO_OR_UI_KIT_FRAMEWORK UIKit) + if(NOT IO_OR_UI_KIT_FRAMEWORK) + message(FATAL_ERROR "UIKit framework not found") + endif() +endif() + +set(MVK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder) +set(MVK_INSTALL_TARGETS "") + +# MoltenVKCommon +# * direct dependencies: +# - external: None +# - internal: None +# - frameworks: Foundation +file(GLOB MVK_COMMON_SOURCES ${MVK_DIR}/common/*.mm) +add_library(MoltenVKCommon OBJECT ${MVK_COMMON_SOURCES}) +target_include_directories(MoltenVKCommon PUBLIC ${MVK_DIR}/common) +target_compile_definitions(MoltenVKCommon PRIVATE $<$:DEBUG=1>) +target_link_libraries(MoltenVKCommon PRIVATE ${FOUNDATION_FRAMEWORK}) + +# MoltenVKShaderConverter +# * direct dependencies: +# - external: spirv-cross, glslang, and spirv-tools (optional) +# - internal: MoltenVKCommon +# - frameworks: Foundation +file(GLOB MVK_SC_COMMON_SOURCES ${MVK_DIR}/MoltenVKShaderConverter/common/*.cpp) +if(MVK_VERSION VERSION_LESS "1.1.0") + file(GLOB MVK_SC_CONVERTERS_SOURCES + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKGLSLToSPIRVConverter/*.cpp + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKGLSLToSPIRVConverter/*.mm + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter/*.cpp + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter/*.mm + ) +else() + file(GLOB MVK_SC_CONVERTERS_SOURCES + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverter/*.cpp + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverter/*.mm + ) +endif() +add_library(MoltenVKShaderConverter OBJECT ${MVK_SC_COMMON_SOURCES} ${MVK_SC_CONVERTERS_SOURCES}) +target_include_directories(MoltenVKShaderConverter + PRIVATE ${MVK_DIR}/MoltenVKShaderConverter/common + INTERFACE ${MVK_DIR}/MoltenVKShaderConverter +) +if(MVK_VERSION VERSION_LESS "1.1.0") + target_include_directories(MoltenVKShaderConverter PRIVATE + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter + ) +endif() +target_link_libraries(MoltenVKShaderConverter + PRIVATE + CONAN_PKG::glslang + MoltenVKCommon + ${FOUNDATION_FRAMEWORK} + PUBLIC + CONAN_PKG::spirv-cross +) +if(NOT MVK_WITH_SPIRV_TOOLS) + target_compile_definitions(MoltenVKShaderConverter PRIVATE MVK_EXCLUDE_SPIRV_TOOLS) + target_link_libraries(MoltenVKShaderConverter PRIVATE CONAN_PKG::spirv-tools) +endif() + +# MoltenVKShaderConverterTool +# * direct dependencies: +# - external: None +# - internal: MoltenVKShaderConverter and MoltenVKCommon +# - frameworks: Metal and Foundation +if(MVK_BUILD_SHADERCONVERTER_TOOL) + file(GLOB MVK_SCT_SOURCES + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverterTool/*.cpp + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverterTool/*.mm + ) + add_executable(MoltenVKShaderConverterTool ${MVK_SCT_SOURCES}) + set_property(TARGET MoltenVKShaderConverterTool PROPERTY OUTPUT_NAME "MoltenVKShaderConverter") + target_include_directories(MoltenVKShaderConverterTool PRIVATE + ${MVK_DIR}/MoltenVKShaderConverter/common + ) + if(MVK_VERSION VERSION_LESS "1.1.0") + target_include_directories(MoltenVKShaderConverterTool PRIVATE + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKGLSLToSPIRVConverter + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter + ) + else() + target_include_directories(MoltenVKShaderConverterTool PRIVATE + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverter + ) + endif() + target_link_libraries(MoltenVKShaderConverterTool PRIVATE + MoltenVKCommon + MoltenVKShaderConverter + ${METAL_FRAMEWORK} + ${FOUNDATION_FRAMEWORK} + ) + list(APPEND MVK_INSTALL_TARGETS MoltenVKShaderConverterTool) +endif() + +# MoltenVK +# * direct dependencies: +# - external: cereal, spirv-cross and vulkan-headers (+ vulkan-portability if moltenvk < 1.1.0) +# - internal: MoltenVKShaderConverter and MoltenVKCommon +# - frameworks: Foundation, Metal, QuartzCore, AppKit, IOSurface + IOKit (Macos) or UIKit (iOS/tvOS) +file(GLOB_RECURSE MVK_SOURCES + ${MVK_DIR}/MoltenVK/*.m + ${MVK_DIR}/MoltenVK/*.mm + ${MVK_DIR}/MoltenVK/*.cpp +) +add_library(MoltenVK ${MVK_SOURCES}) +target_include_directories(MoltenVK PRIVATE + ${MVK_DIR}/MoltenVK/MoltenVK/API + ${MVK_DIR}/MoltenVK/MoltenVK/Commands + ${MVK_DIR}/MoltenVK/MoltenVK/GPUObjects + ${MVK_DIR}/MoltenVK/MoltenVK/Layers + ${MVK_DIR}/MoltenVK/MoltenVK/OS + ${MVK_DIR}/MoltenVK/MoltenVK/Utility + ${MVK_DIR}/MoltenVK/MoltenVK/Vulkan +) +target_link_libraries(MoltenVK + PRIVATE + CONAN_PKG::cereal + CONAN_PKG::spirv-cross + MoltenVKCommon + MoltenVKShaderConverter + ${FOUNDATION_FRAMEWORK} + ${QUARTZ_CORE_FRAMEWORK} + ${APPKIT_FRAMEWORK} + ${IO_OR_UI_KIT_FRAMEWORK} + PUBLIC + CONAN_PKG::vulkan-headers + ${METAL_FRAMEWORK} + ${IOSURFACE_FRAMEWORK} +) +if(MVK_VERSION VERSION_LESS "1.1.0") + target_link_libraries(MoltenVK PUBLIC CONAN_PKG::vulkan-portability) +endif() +target_compile_options(MoltenVK PRIVATE + -Wno-unguarded-availability-new + -Wno-deprecated-declarations + -Wno-nonportable-include-path +) +list(APPEND MVK_INSTALL_TARGETS MoltenVK) + +# Custom Target to generate internal header file required by MoltenVK target. +# This header should contain: +# - if moltenvk < 1.44 : spirv-cross commit hash in spirvCrossRevisionString variable +# - if moltenvk >= 1.44: moltenvk commit hash in mvkRevString variable (but we still +# use spirv-cross commit hash, since MoltenVK hash is not available in this context, +# and hash value is no really important) +set(MVK_REVISION_FILE ${MVK_DIR}/ExternalRevisions/SPIRV-Cross_repo_revision) +set(MVK_REVISION_HEADER_DIR ${CMAKE_CURRENT_BINARY_DIR}/mvk_hash_generated) +if(MVK_VERSION VERSION_LESS "1.0.44") + set(MVK_REVISION_HEADER ${MVK_REVISION_HEADER_DIR}/SPIRV-Cross/mvkSpirvCrossRevisionDerived.h) + set(MVK_REV_VAR_NAME "spirvCrossRevisionString") +else() + set(MVK_REVISION_HEADER ${MVK_REVISION_HEADER_DIR}/mvkGitRevDerived.h) + set(MVK_REV_VAR_NAME "mvkRevString") +endif() +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/mvk_git_hash_generator.in + "file(READ @MVK_REVISION_FILE@ MVK_SPIRV_CROSS_GIT_REV)\n" + "string(REPLACE \"\\n\" \"\" MVK_SPIRV_CROSS_GIT_REV \${MVK_SPIRV_CROSS_GIT_REV})\n" + "file(WRITE @MVK_REVISION_HEADER@ \"static const char* @MVK_REV_VAR_NAME@ = \\\"\${MVK_SPIRV_CROSS_GIT_REV}\\\";\")\n" +) +configure_file( + ${CMAKE_CURRENT_BINARY_DIR}/mvk_git_hash_generator.in + ${CMAKE_CURRENT_BINARY_DIR}/mvk_git_hash_generator.cmake + @ONLY +) +add_custom_target(mvk-commit-hash-header DEPENDS ${MVK_REVISION_FILE} ${MVK_REVISION_HEADER}) +add_custom_command( + COMMENT "Create ${MVK_REVISION_HEADER}" + OUTPUT ${MVK_REVISION_HEADER} + DEPENDS ${MVK_REVISION_FILE} + COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/mvk_git_hash_generator.cmake" +) +add_dependencies(MoltenVK mvk-commit-hash-header) +target_include_directories(MoltenVK PRIVATE ${MVK_REVISION_HEADER_DIR}) + +# Installation +install( + TARGETS ${MVK_INSTALL_TARGETS} + BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +if(BUILD_SHARED_LIBS) + install( + FILES ${MVK_DIR}/MoltenVK/icd/MoltenVK_icd.json + DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) +endif() + +file(GLOB MVK_PUBLIC_HEADERS ${MVK_DIR}/MoltenVK/MoltenVK/API/*.h) +install( + FILES ${MVK_PUBLIC_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/MoltenVK +) + +if(MVK_VERSION VERSION_LESS "1.1.0") + file(GLOB MVK_SC_PUBLIC_HEADERS + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKGLSLToSPIRVConverter/*Conversion.h + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKGLSLToSPIRVConverter/*Converter.h + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter/*Conversion.h + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKSPIRVToMSLConverter/*Converter.h + ) +else() + file(GLOB MVK_SC_PUBLIC_HEADERS + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverter/*Conversion.h + ${MVK_DIR}/MoltenVKShaderConverter/MoltenVKShaderConverter/*Converter.h + ) +endif() +install( + FILES ${MVK_SC_PUBLIC_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/MoltenVKShaderConverter +) diff --git a/recipes/moltenvk/all/conandata.yml b/recipes/moltenvk/all/conandata.yml new file mode 100644 index 0000000000000..91e76e3474938 --- /dev/null +++ b/recipes/moltenvk/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.1.1": + url: "https://github.com/KhronosGroup/MoltenVK/archive/v1.1.1.tar.gz" + sha256: "cd1712c571d4155f4143c435c8551a5cb8cbb311ad7fff03595322ab971682c0" +patches: + "1.1.1": + - patch_file: "patches/0001-fix-spirv-cross-includes-1.1.x.patch" + base_path: "source_subfolder" diff --git a/recipes/moltenvk/all/conanfile.py b/recipes/moltenvk/all/conanfile.py new file mode 100644 index 0000000000000..bf1880b292429 --- /dev/null +++ b/recipes/moltenvk/all/conanfile.py @@ -0,0 +1,161 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.32.0" + + +class MoltenVKConan(ConanFile): + name = "moltenvk" + description = "MoltenVK is a Vulkan Portability implementation. It " \ + "layers a subset of the high-performance, industry-standard " \ + "Vulkan graphics and compute API over Apple's Metal " \ + "graphics framework, enabling Vulkan applications to run " \ + "on iOS and macOS." + license = "Apache-2.0" + topics = ("conan", "moltenvk", "khronos", "vulkan", "metal") + homepage = "https://github.com/KhronosGroup/MoltenVK" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_spirv_tools": [True, False], + "tools": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "with_spirv_tools": True, + "tools": True + } + + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def configure(self): + if self.options.shared: + del self.options.fPIC + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + if self.settings.os not in ["Macos", "iOS", "tvOS"]: + raise ConanInvalidConfiguration("MoltenVK only supported on MacOS, iOS and tvOS") + if self.settings.compiler != "apple-clang": + raise ConanInvalidConfiguration("MoltenVK requires apple-clang") + + def requirements(self): + self.requires("cereal/1.3.0") + self.requires("glslang/8.13.3559") + self.requires("spirv-cross/{}".format(self._spirv_cross_version)) + self.requires("vulkan-headers/{}".format(self._vulkan_headers_version)) + if self.options.with_spirv_tools: + self.requires("spirv-tools/v2020.5") + if tools.Version(self.version) < "1.1.0": + raise ConanInvalidConfiguration("MoltenVK < 1.1.0 requires vulkan-portability, not yet available in CCI") + self.requires("vulkan-portability/0.2") + + @property + def _spirv_cross_version(self): + return { + "1.1.1": "20210115", # can't compile with spirv-cross < 20210115 + "1.1.0": "20200917", # compiles only with spirv-cross 20200917 + "1.0.44": "20200917", # compiles only with spirv-cross 20200917 + "1.0.43": "20200519", # compiles only with spirv-cross 20200519 + "1.0.42": "20200519", # compiles only with spirv-cross 20200519 + "1.0.41": "20200519", # compiles only with spirv-cross 20200403 or 20200519 + "1.0.40": "20200519", # compiles only with spirv-cross 20200403 or 20200519 + "1.0.39": "20200519", # compiles only with spirv-cross 20200403 or 20200519 + }[self.version] + + @property + def _vulkan_headers_version(self): + return { + "1.1.1": "1.2.162.0", + "1.1.0": "1.2.154.0", + "1.0.44": "1.2.148.0", + "1.0.43": "1.2.141.0", + "1.0.42": "1.2.141.0", + "1.0.41": "1.2.135.0", + "1.0.40": "1.2.131.1", + "1.0.39": "1.1.130.0", + "1.0.38": "1.1.126.0", + "1.0.37": "1.1.121.0", + "1.0.36": "1.1.114.0", + "1.0.35": "1.1.108.0", + "1.0.34": "1.1.106.0", + "1.0.33": "1.1.101.0", + "1.0.32": "1.1.97.0", + "1.0.31": "1.1.97.0", + "1.0.30": "1.1.92.0", + "1.0.29": "1.1.92.0", + "1.0.28": "1.1.92.0", + "1.0.27": "1.1.92.0", + "1.0.26": "1.1.85.0", + "1.0.25": "1.1.85.0", + "1.0.24": "1.1.85.0", + "1.0.23": "1.1.85.0", + "1.0.22": "1.1.82.0", + "1.0.21": "1.1.82.0", + "1.0.20": "1.1.82.0", + "1.0.19": "1.1.82.0", + "1.0.18": "1.1.82.0", + "1.0.17": "1.1.82.0", + }[self.version] + + def package_id(self): + # MoltenVK >=1.O.42 requires at least XCode 12.0 (11.4 actually) at build + # time but can be consumed by older compiler versions + if tools.Version(self.version) >= "1.0.42": + if tools.Version(self.settings.compiler.version) < "12.0": + compatible_pkg = self.info.clone() + compatible_pkg.settings.compiler.version = "12.0" + self.compatible_packages.append(compatible_pkg) + + def validate(self): + if tools.Version(self.version) >= "1.0.42": + if tools.Version(self.settings.compiler.version) < "12.0": + raise ConanInvalidConfiguration("MoltenVK {} requires XCode 12.0 or higher at build time".format(self.version)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + os.rename("MoltenVK-" + self.version, self._source_subfolder) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["MVK_VERSION"] = self.version + self._cmake.definitions["MVK_WITH_SPIRV_TOOLS"] = self.options.with_spirv_tools + self._cmake.definitions["MVK_BUILD_SHADERCONVERTER_TOOL"] = self.options.tools + self._cmake.configure() + return self._cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["MoltenVK"] + self.cpp_info.frameworks = ["Metal", "Foundation", "QuartzCore", "AppKit", "IOSurface"] + if self.settings.os == "Macos": + self.cpp_info.frameworks.append("IOKit") + elif self.settings.os in ["iOS", "tvOS"]: + self.cpp_info.frameworks.append("UIKit") + + if self.options.tools: + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/moltenvk/all/patches/0001-fix-spirv-cross-includes-1.1.x.patch b/recipes/moltenvk/all/patches/0001-fix-spirv-cross-includes-1.1.x.patch new file mode 100644 index 0000000000000..2233cef64f39e --- /dev/null +++ b/recipes/moltenvk/all/patches/0001-fix-spirv-cross-includes-1.1.x.patch @@ -0,0 +1,52 @@ +--- a/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.h ++++ b/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.h +@@ -22,7 +22,7 @@ + #include "MVKEnvironment.h" + #include "MVKOSExtensions.h" + #include "MVKBaseObject.h" +-#include ++#include + #include + + #import +--- a/MoltenVKShaderConverter/Common/SPIRVSupport.cpp ++++ b/MoltenVKShaderConverter/Common/SPIRVSupport.cpp +@@ -18,7 +18,7 @@ + + #include "SPIRVSupport.h" + #include "MVKStrings.h" +-#include ++#include + #include + + #import +--- a/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVReflection.h ++++ b/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVReflection.h +@@ -19,10 +19,10 @@ + #ifndef __SPIRVReflection_h_ + #define __SPIRVReflection_h_ 1 + +-#include +-#include +-#include +-#include ++#include ++#include ++#include ++#include + #include + #include + +--- a/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVToMSLConverter.h ++++ b/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVToMSLConverter.h +@@ -19,8 +19,8 @@ + #ifndef __SPIRVToMSLConverter_h_ + #define __SPIRVToMSLConverter_h_ 1 + +-#include +-#include ++#include ++#include + #include + #include + #include diff --git a/recipes/moltenvk/all/test_package/CMakeLists.txt b/recipes/moltenvk/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..33ae887aa6aea --- /dev/null +++ b/recipes/moltenvk/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/moltenvk/all/test_package/conanfile.py b/recipes/moltenvk/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5216332f39f5c --- /dev/null +++ b/recipes/moltenvk/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/moltenvk/all/test_package/test_package.cpp b/recipes/moltenvk/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..62c6f9b310736 --- /dev/null +++ b/recipes/moltenvk/all/test_package/test_package.cpp @@ -0,0 +1,37 @@ +#include + +#include + +int main() +{ + vk::ApplicationInfo appInfo; + appInfo.pApplicationName = "ConanTestApp"; + appInfo.pEngineName = "ConanTestEngine"; + appInfo.apiVersion = VK_API_VERSION_1_0; + + vk::InstanceCreateInfo instanceCreateInfo; + instanceCreateInfo.pApplicationInfo = &appInfo; + + try + { + vk::Instance instance = vk::createInstance(instanceCreateInfo); + + auto physicalDevices = instance.enumeratePhysicalDevices(); + auto physicalDevice = physicalDevices[0]; + auto deviceProperties = physicalDevice.getProperties(); + auto deviceMemoryProperties = physicalDevice.getMemoryProperties(); + + std::cout << "Vulkan device created" << std::endl; + std::cout << "API Version: " << deviceProperties.apiVersion << std::endl; + std::cout << "Driver Version: " << deviceProperties.driverVersion << std::endl; + std::cout << "Device Name: " << deviceProperties.deviceName << std::endl; + std::cout << "Device Type: " << vk::to_string(deviceProperties.deviceType) << std::endl; + std::cout << "Memory Heaps: " << deviceMemoryProperties.memoryHeapCount << std::endl; + } + catch(const vk::SystemError& e) + { + std::cerr << e.what() << '\n'; + } + + return 0; +} diff --git a/recipes/moltenvk/config.yml b/recipes/moltenvk/config.yml new file mode 100644 index 0000000000000..60d31991f5141 --- /dev/null +++ b/recipes/moltenvk/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1.1": + folder: all