-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
VulkanSceneGraph 1.0.0 ,1.0.3, 1.0.5 #16528
Changes from 23 commits
dc5f853
244e106
2d42472
c0a15dc
f9e643d
be2737e
31c96dc
eea9aff
1f2d199
c4d7c8d
7921829
f79735f
09fa2ec
d3dcd35
7ac286f
5027079
6695c65
6884d78
ef06c8c
a6ae2e0
7229658
2ebb28c
70166b3
f1201de
2e01a2f
53be649
0c36e01
2de2925
466aa4f
8388323
de29696
588bf3b
5b7a976
22dc1f9
80ac048
09dd853
32fa2f8
5b384d1
c099edb
499cfde
bb8f7a3
35aa9e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
sources: | ||
"1.0.0": | ||
url: "https://github.com/vsg-dev/VulkanSceneGraph/archive/refs/tags/VulkanSceneGraph-1.0.0.tar.gz" | ||
sha256: "5611284f4256893ea97a33f9e99f5ecc8bdda110cc9fb7770b291fb45e8f9cf6" | ||
"1.0.3": | ||
url: "https://github.com/vsg-dev/VulkanSceneGraph/archive/refs/tags/VulkanSceneGraph-1.0.3.tar.gz" | ||
sha256: "84aa1d445ecdd2702843f8f01e760d4db32c2ab3fe8c5d6122f8a83b67a50e36" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.microsoft import check_min_vs, is_msvc_static_runtime, is_msvc | ||
from conan.tools.files import get, copy, rm, rmdir, collect_libs | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.scm import Version | ||
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake | ||
import os | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
class VsgConan(ConanFile): | ||
name = "vsg" | ||
description = "VulkanSceneGraph" | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://www.vulkanscenegraph.org" | ||
topics = ("vulkan", "scenegraph", "graphics", "3d") | ||
package_type = "library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
psyinf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"shared": [True, False], | ||
"shader_compiler": [True, False], | ||
"max_devices": [1,2,3,4], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"shader_compiler": True, | ||
"max_devices" : 1, | ||
"fPIC": True, | ||
} | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 17 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"gcc": "7", | ||
"clang": "7", | ||
"apple-clang": "10", | ||
} | ||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
|
||
def requirements(self): | ||
self.requires("vulkan-loader/1.3.204.0", transitive_headers=True) | ||
AbrilRBS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def validate(self): | ||
if self.info.settings.compiler.cppstd: | ||
check_min_cppstd(self, self._min_cppstd) | ||
check_min_vs(self, 191) | ||
|
||
if is_msvc_static_runtime(self): | ||
raise ConanInvalidConfiguration(f"{self.name} does not support MSVC static runtime (MT/MTd) configurations, only dynamic runtime (MD/MDd) is supported") | ||
|
||
if not is_msvc(self): | ||
minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) | ||
if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: | ||
raise ConanInvalidConfiguration( | ||
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." | ||
) | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) | ||
#Working around submodules | ||
#TODO: semantic versioning | ||
if self.version == "1.0.3": | ||
self.run("git clone https://github.com/vsg-dev/glslang.git src/glslang") | ||
psyinf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.run("cd src/glslang && git reset --hard e4075496f6895ce6b747a6690ba13fa3836a93e5") | ||
|
||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
if is_msvc(self): | ||
tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = False | ||
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared | ||
tc.variables["VSG_SUPPORTS_ShaderCompiler"] = 1 if self.options.shader_compiler else 0 | ||
tc.variables["VSG_MAX_DEVICES"] = self.options.max_devices | ||
|
||
tc.generate() | ||
|
||
deps = CMakeDeps(self) | ||
|
||
deps.generate() | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
copy(self, pattern="LICENSE.md", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
|
||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
rmdir(self, os.path.join(self.package_folder, "share")) | ||
|
||
rm(self, "*.la", os.path.join(self.package_folder, "lib")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it's a copy/paste from another recipe. Why would there be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, refactored in this PR |
||
rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) | ||
rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) | ||
rm(self, "Find*.cmake", os.path.join(self.package_folder, "lib/cmake/vsg")) | ||
rm(self, "*Config.cmake", os.path.join(self.package_folder, "lib/cmake/vsg")) | ||
Comment on lines
+102
to
+103
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just remove this cmake folder instead of these 2 lines? It doesn't seem to be used or exposed in package_info, so it's useless. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
AFAIR other VSG packages such as vsgXchange need the vsg cmake package info. Seems I've hacked around this then in this PR. Maybe I need some guidance here on how to use the cmake files generated to be used in subsequent packages. ;-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It depends on their official usage. Are they already included in official upstream CMake config file of just exposed in installation layout? I see these files:
I would say that the only file which would make sense to be kept is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are correct. Can you point me to another recipe that shows how to tackle this correctly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cern-root for example |
||
|
||
def package_info(self): | ||
self.cpp_info.libs = collect_libs(self) | ||
|
||
self.cpp_info.set_property("cmake_file_name", "vsg") | ||
self.cpp_info.set_property("cmake_target_name", "vsg::vsg") | ||
|
||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.append("pthread") | ||
|
||
# TODO: to remove in conan v2 once cmake_find_package_* generators removed | ||
self.cpp_info.filenames["cmake_find_package"] = "vsg" | ||
self.cpp_info.filenames["cmake_find_package_multi"] = "vsg" | ||
self.cpp_info.names["cmake_find_package"] = "VSG" | ||
self.cpp_info.names["cmake_find_package_multi"] = "vsg" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
project(test_package CXX) # if the project uses c++ | ||
|
||
find_package(vsg REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE vsg::vsg) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
# It will become the standard on Conan 2.x | ||
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.bindirs[0], "test_package") | ||
self.run(bin_path, env="conanrun") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
#include <vsg/core/Object.h> | ||
#include <vsg/nodes/Node.h> | ||
#include <vsg/core/ref_ptr.h> | ||
|
||
|
||
#include <vsg/utils/CommandLine.h> | ||
|
||
#include <iostream> | ||
#include <vector> | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
vsg::CommandLine arguments(&argc, argv); | ||
auto numObjects = arguments.value(100u, {"---num-objects", "-n"}); | ||
if (arguments.errors()) return arguments.writeErrorMessages(std::cerr); | ||
|
||
using Objects = std::vector<vsg::ref_ptr<vsg::Object>>; | ||
Objects objects; | ||
objects.reserve(numObjects); | ||
for (unsigned int i = 0; i < numObjects; ++i) | ||
{ | ||
objects.push_back(vsg::Node::create()); | ||
} | ||
|
||
Objects copy_objects(numObjects); | ||
|
||
|
||
copy_objects = objects; | ||
copy_objects.clear(); | ||
|
||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ | ||
${CMAKE_CURRENT_BINARY_DIR}/test_package/) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from conans import ConanFile, CMake | ||
from conan.tools.build import cross_building | ||
import os | ||
|
||
|
||
# legacy validation with Conan 1.x | ||
class TestPackageV1Conan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not cross_building(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
versions: | ||
"1.0.3": | ||
folder: all | ||
"1.0.0": | ||
folder: all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to provide a more meaningful description please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've modified the PR here