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

add ms-gltf-sdk/1.9.5.0 #4557

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions recipes/gltf-sdk/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.11)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory(source_subfolder)
10 changes: 10 additions & 0 deletions recipes/gltf-sdk/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sources:
"1.9.5.0":
url: "https://github.com/microsoft/glTF-SDK/archive/r1.9.5.0.tar.gz"
sha256: "02cc345d79f8b017aab2edf5730d93fbe5836350b59f7c20d831396d82309247"
patches:
"1.9.5.0":
- patch_file: "patches/fix-cmake.patch"
base_path: "source_subfolder"
- patch_file: "patches/use-pow.patch"
base_path: "source_subfolder"
85 changes: 85 additions & 0 deletions recipes/gltf-sdk/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os


class GltfSdkConan(ConanFile):
name = "gltf-sdk"
SpaceIm marked this conversation as resolved.
Show resolved Hide resolved
description = "A C++ Deserializer/Serializer for glTF"
license = "MIT"
topics = ("conan", "gltf-sdk", "gltf", "serializer", "deserializer")
homepage = "https://github.com/microsoft/glTF-SDK"
url = "https://github.com/conan-io/conan-center-index"

settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

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

@property
def _minimum_compilers_version(self):
return {
"Visual Studio": "14",
"gcc": "6",
"clang": "5",
"apple-clang": "5.1",
}

def configure(self):
if self.options.shared:
del self.options.fPIC
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 14)
minimum_version = self._minimum_compilers_version.get(str(self.settings.compiler), False)
if not minimum_version:
self.output.warn("{} requires C++14. Your compiler is unknown. Assuming it supports C++14.".format(self.name))
elif tools.Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration("{} requires C++14, which your compiler does not support.".format(self.name))
if self.settings.compiler == "Visual Studio" and self.options.shared:
raise ConanInvalidConfiguration("{} shared in not supported by Visual Studio".format(self.name))

def requirements(self):
self.requires("rapidjson/1.1.0")

def build_requirements(self):
if not (tools.which("pwsh") or tools.which("powershell")):
raise ConanInvalidConfiguration("{} requires powershell at build time.".format(self.name))
self.build_requires("powershell/7.1.2")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("glTF-SDK-r" + self.version, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["ENABLE_UNIT_TESTS"] = False
self._cmake.definitions["ENABLE_SAMPLES"] = False
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 = ["GLTFSDK"]
52 changes: 52 additions & 0 deletions recipes/gltf-sdk/all/patches/fix-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--- a/Build/CMake/Modules/GLTFPlatform.cmake
+++ b/Build/CMake/Modules/GLTFPlatform.cmake
@@ -55,13 +55,12 @@ endfunction(GetGLTFPlatform)
function(CreateGLTFInstallTargets target platform)

install(TARGETS ${target}
- ARCHIVE DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME}
- LIBRARY DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME}
- RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME}
- BUNDLE DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

- if (MSVC)
+ if (0)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${PROJECT_NAME}.pdb DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME})
endif()

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,7 +16,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -D_DEBUG -DFEATURE_ASSERTS_ENABLED")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11)

-if (WIN32)
+if (MSVC)
# Define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to disable the warnings in the current version of Google Test (1.8.0)
# TODO: Newer versions shouldn't have this problem. Re-evaluate this when upgrading.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING")
@@ -28,8 +28,6 @@ endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Build/CMake/Modules")


-add_subdirectory(External/RapidJSON)
-add_subdirectory(External/googletest)
add_subdirectory(GLTFSDK)

if(ENABLE_UNIT_TESTS)
--- a/GLTFSDK/CMakeLists.txt
+++ b/GLTFSDK/CMakeLists.txt
@@ -46,8 +46,6 @@ target_include_directories(GLTFSDK
PRIVATE "${CMAKE_BINARY_DIR}/GeneratedFiles"
)

-target_link_libraries(GLTFSDK
- RapidJSON
-)
+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Inc/GLTFSDK DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

CreateGLTFInstallTargets(GLTFSDK ${Platform})
20 changes: 20 additions & 0 deletions recipes/gltf-sdk/all/patches/use-pow.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/GLTFSDK/Inc/GLTFSDK/Math.h
+++ b/GLTFSDK/Inc/GLTFSDK/Math.h
@@ -85,7 +85,7 @@ namespace Microsoft
return value / 12.92f;
}

- return std::powf((value + 0.055f) / 1.055f, 2.4f);
+ return std::pow((value + 0.055f) / 1.055f, 2.4f);
}

// https://en.wikipedia.org/wiki/SRGB#The_forward_transformation_.28CIE_XYZ_to_sRGB.29
@@ -96,7 +96,7 @@ namespace Microsoft
return value * 12.92f;
}

- return 1.055f * std::powf(value, 1.0f / 2.4f) - 0.055f;
+ return 1.055f * std::pow(value, 1.0f / 2.4f) - 0.055f;
}

inline float ByteToFloat(uint8_t value)
9 changes: 9 additions & 0 deletions recipes/gltf-sdk/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 14)
17 changes: 17 additions & 0 deletions recipes/gltf-sdk/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
31 changes: 31 additions & 0 deletions recipes/gltf-sdk/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <GLTFSDK/GLTF.h>
#include <GLTFSDK/Deserialize.h>
#include <GLTFSDK/Document.h>
#include <GLTFSDK/Math.h>
#include <GLTFSDK/Serialize.h>

#include <iostream>
#include <utility>

int main() {
Microsoft::glTF::Document originalDoc;

{
Microsoft::glTF::Scene sc;
sc.id = "0";
sc.nodes = { "0" };
originalDoc.SetDefaultScene(std::move(sc));
}

{
Microsoft::glTF::Node matrixNode;
matrixNode.id = "0";
matrixNode.name = "matrixNode";
matrixNode.matrix = Microsoft::glTF::Matrix4::IDENTITY;
originalDoc.nodes.Append(std::move(matrixNode));
}

std::cout << Microsoft::glTF::Serialize(originalDoc) << std::endl;

return 0;
}
3 changes: 3 additions & 0 deletions recipes/gltf-sdk/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.9.5.0":
folder: all