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

OpenVR: move to conan2, new version 2.2.3 #23021

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion recipes/openvr/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"2.2.3":
url: https://github.com/ValveSoftware/openvr/archive/v2.2.3.tar.gz
sha256: 4da20c2c33e7488703802eafd7f2e6c92dd0f324e887711e1e11e9b9d3dd3daa
"1.12.5":
url: https://github.com/ValveSoftware/openvr/archive/v1.12.5.tar.gz
sha256: f3cdbaa946688553638e6d65978f156311c9b08825316198d925f5eade6cfeb7
Expand All @@ -9,6 +12,5 @@
url: https://github.com/ValveSoftware/openvr/archive/refs/tags/v1.16.8.tar.gz
sha256: 387c98c0540f66595c4594e5f3340a1095dd90e954ff14fd5d89cc849ba32d1b
patches:
"1.16.8":
- patch_file: "patches/fix-includes-and-assert-1.16.8.patch"

Check warning on line 16 in recipes/openvr/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/fix-incl ... ^ (line: 16)
base_path: "source_subfolder"
100 changes: 43 additions & 57 deletions recipes/openvr/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
from conans import ConanFile, tools, CMake
from conans.errors import ConanInvalidConfiguration
from conan import ConanFile
from conan.tools.files import copy, get, rm, apply_conandata_patches, replace_in_file
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout


class OpenvrConan(ConanFile):
name = "openvr"
Expand All @@ -21,82 +23,66 @@ class OpenvrConan(ConanFile):
}

exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake"
_cmake = None

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

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

def configure(self):
if self.options.shared:
del self.options.fPIC
if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, "11")

if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5":
raise ConanInvalidConfiguration("OpenVR can't be compiled by {0} {1}".format(self.settings.compiler,
self.settings.compiler.version))
self.options.rm_safe("fPIC")

def requirements(self):
self.requires("jsoncpp/1.9.4")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = "{}-{}".format(self.name, self.version)
os.rename(extracted_dir, self._source_subfolder)
def layout(self):
cmake_layout(self, src_folder="src")

def _patch_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
apply_conandata_patches(self)

# Honor fPIC=False
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
"-fPIC", "")
# Unvendor jsoncpp (we rely on our CMake wrapper for jsoncpp injection)
tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"),
"jsoncpp.cpp", "")
tools.rmdir(os.path.join(self._source_subfolder, "src", "json"))
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
"-fPIC", "")

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

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["BUILD_SHARED"] = self.options.shared
self._cmake.definitions["BUILD_UNIVERSAL"] = False
self._cmake.definitions["USE_LIBCXX"] = False
self._cmake.configure()
def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_UNIVERSAL"] = False

return self._cmake
runtime = self.settings.get_safe("compiler.libcxx")
if runtime != None and runtime != "libc++":
tc.variables["USE_LIBCXX"] = False

def build(self):
self._patch_sources()
cmake = self._configure_cmake()
if self.options.shared:
tc.variables["BUILD_SHARED"] = True
else:
tc.variables["BUILD_SHARED"] = False
tc.generate()

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

def package(self):
self.copy("LICENSE", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses")
cmake = self._configure_cmake()
copy(self, "LICENSE", self.source_folder,
os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
self.copy(pattern="openvr_api*.dll", dst="bin", src="bin", keep_path=False)
tools.rmdir(os.path.join(self.package_folder, "share"))
copy(self, "openvr_*.dll", src=os.path.join(self.package_folder,
"lib"), dst=os.path.join(self.package_folder, "bin"))
rm(self, "openvr_*.dll", folder=os.path.join(self.package_folder, "lib"))

def package_info(self):
self.cpp_info.names["pkg_config"] = "openvr"
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.set_property("pkg_config_name", "openvr")
if self.settings.os == "Windows":
self.cpp_info.libs = ["openvr_api64"]
else:
self.cpp_info.libs = ["openvr_api"]
self.cpp_info.includedirs.append(os.path.join("include", "openvr"))

if not self.options.shared:
self.cpp_info.defines.append("OPENVR_BUILD_STATIC")
libcxx = tools.stdcpp_library(self)
if libcxx:
self.cpp_info.system_libs.append(libcxx)

if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("dl")

if tools.is_apple_os(self.settings.os):
self.cpp_info.defines.append("OPENVR_API_NODLL")
if self.settings.os == "Macos":
self.cpp_info.frameworks.append("Foundation")
8 changes: 3 additions & 5 deletions recipes/openvr/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(openvr REQUIRED CONFIG)

add_executable(${CMAKE_PROJECT_NAME} test_package.cpp)
target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS})
set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 11)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE openvr::openvr)
21 changes: 15 additions & 6 deletions recipes/openvr/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
from conans import ConanFile, CMake, tools
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", "compiler", "build_type", "arch"
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps"

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 not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
2 changes: 2 additions & 0 deletions recipes/openvr/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"2.2.3":
folder: "all"
"1.12.5":
folder: "all"
"1.14.15":
Expand Down
Loading