diff --git a/recipes/gltf-sdk/all/CMakeLists.txt b/recipes/gltf-sdk/all/CMakeLists.txt new file mode 100644 index 0000000000000..361b35d4c17d9 --- /dev/null +++ b/recipes/gltf-sdk/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.11) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/gltf-sdk/all/conandata.yml b/recipes/gltf-sdk/all/conandata.yml new file mode 100644 index 0000000000000..d6bbef48943d7 --- /dev/null +++ b/recipes/gltf-sdk/all/conandata.yml @@ -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" diff --git a/recipes/gltf-sdk/all/conanfile.py b/recipes/gltf-sdk/all/conanfile.py new file mode 100644 index 0000000000000..e39d08050fb33 --- /dev/null +++ b/recipes/gltf-sdk/all/conanfile.py @@ -0,0 +1,85 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + + +class GltfSdkConan(ConanFile): + name = "gltf-sdk" + 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"] diff --git a/recipes/gltf-sdk/all/patches/fix-cmake.patch b/recipes/gltf-sdk/all/patches/fix-cmake.patch new file mode 100644 index 0000000000000..61cd46b8582c0 --- /dev/null +++ b/recipes/gltf-sdk/all/patches/fix-cmake.patch @@ -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}/$/${PROJECT_NAME} +- LIBRARY DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$/${PROJECT_NAME} +- RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$/${PROJECT_NAME} +- BUNDLE DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$/${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}/$/${PROJECT_NAME}.pdb DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$/${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}) diff --git a/recipes/gltf-sdk/all/patches/use-pow.patch b/recipes/gltf-sdk/all/patches/use-pow.patch new file mode 100644 index 0000000000000..0a53e088291bd --- /dev/null +++ b/recipes/gltf-sdk/all/patches/use-pow.patch @@ -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) diff --git a/recipes/gltf-sdk/all/test_package/CMakeLists.txt b/recipes/gltf-sdk/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3300ff7750277 --- /dev/null +++ b/recipes/gltf-sdk/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 14) diff --git a/recipes/gltf-sdk/all/test_package/conanfile.py b/recipes/gltf-sdk/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5216332f39f5c --- /dev/null +++ b/recipes/gltf-sdk/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/gltf-sdk/all/test_package/test_package.cpp b/recipes/gltf-sdk/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..66eb4f106692d --- /dev/null +++ b/recipes/gltf-sdk/all/test_package/test_package.cpp @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include + +#include +#include + +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; +} diff --git a/recipes/gltf-sdk/config.yml b/recipes/gltf-sdk/config.yml new file mode 100644 index 0000000000000..c2aeb79e4bfaa --- /dev/null +++ b/recipes/gltf-sdk/config.yml @@ -0,0 +1,3 @@ +versions: + "1.9.5.0": + folder: all