From a73311d08ca81cdd29db2d8fc5ac13ef2d743f37 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Tue, 28 Sep 2021 04:01:46 +0200 Subject: [PATCH] (#7272) [magnum-plugins] Add recipe * [magnum-plugins] Add recipes * rename options to snake_case * disable gcc5, use '-d' suffix * gcc5 is covered by magnum itself * use short_paths * add test: load STL file * use forward slashes * handle use-case when shared_plugins=False * parameterize plugins components * update comment * add endline * DLLs in Windows are located in 'bin' folder * auto import only if not shared plugins * follow suggestions by @sse4 * Works with Emscripten --- recipes/magnum-plugins/all/CMakeLists.txt | 41 +++ .../cmake/conan-bugfix-global-target.cmake | 24 ++ recipes/magnum-plugins/all/conandata.yml | 11 + recipes/magnum-plugins/all/conanfile.py | 322 ++++++++++++++++++ .../2020.06/0001-emscripten-toolchain.patch | 15 + .../all/test_package/CMakeLists.txt | 36 ++ .../magnum-plugins/all/test_package/conan.stl | Bin 0 -> 9084 bytes .../all/test_package/conanfile.py | 25 ++ .../all/test_package/configure.h.in | 4 + .../all/test_package/test_package.cpp | 17 + recipes/magnum-plugins/config.yml | 3 + 11 files changed, 498 insertions(+) create mode 100644 recipes/magnum-plugins/all/CMakeLists.txt create mode 100644 recipes/magnum-plugins/all/cmake/conan-bugfix-global-target.cmake create mode 100644 recipes/magnum-plugins/all/conandata.yml create mode 100644 recipes/magnum-plugins/all/conanfile.py create mode 100644 recipes/magnum-plugins/all/patches/2020.06/0001-emscripten-toolchain.patch create mode 100644 recipes/magnum-plugins/all/test_package/CMakeLists.txt create mode 100644 recipes/magnum-plugins/all/test_package/conan.stl create mode 100644 recipes/magnum-plugins/all/test_package/conanfile.py create mode 100644 recipes/magnum-plugins/all/test_package/configure.h.in create mode 100644 recipes/magnum-plugins/all/test_package/test_package.cpp create mode 100644 recipes/magnum-plugins/config.yml diff --git a/recipes/magnum-plugins/all/CMakeLists.txt b/recipes/magnum-plugins/all/CMakeLists.txt new file mode 100644 index 0000000000000..315c0afaf5005 --- /dev/null +++ b/recipes/magnum-plugins/all/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +set(CONAN_CMAKE_SILENT_OUTPUT 1) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +# The original project uses the path to the 'magnum' package, in Conan we cannot modify existing package +set(MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/magnum-d) +set(MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/magnum-d) +set(MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/magnum) +set(MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/magnum) +set(MAGNUM_PLUGINS_FONT_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/fonts) +set(MAGNUM_PLUGINS_FONT_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/fonts) +set(MAGNUM_PLUGINS_FONT_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/fonts) +set(MAGNUM_PLUGINS_FONT_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/fonts) +set(MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/fontconverters) +set(MAGNUM_PLUGINS_FONTCONVERTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/fontconverters) +set(MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/imageconverters) +set(MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/imageconverters) +set(MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/imageconverters) +set(MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/imageconverters) +set(MAGNUM_PLUGINS_IMPORTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/importers) +set(MAGNUM_PLUGINS_IMPORTER_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/importers) +set(MAGNUM_PLUGINS_IMPORTER_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/importers) +set(MAGNUM_PLUGINS_IMPORTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/importers) +set(MAGNUM_PLUGINS_SCENECONVERTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/sceneconverters) +set(MAGNUM_PLUGINS_SCENECONVERTER_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/sceneconverters) +set(MAGNUM_PLUGINS_SCENECONVERTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/sceneconverters) +set(MAGNUM_PLUGINS_SCENECONVERTER_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/sceneconverters) +set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR}/audioimporters) +set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/audioimporters) +set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/audioimporters) +set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/audioimporters) + +set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/Magnum) +set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/MagnumExternal) +set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/MagnumPlugins) + +add_subdirectory("source_subfolder") diff --git a/recipes/magnum-plugins/all/cmake/conan-bugfix-global-target.cmake b/recipes/magnum-plugins/all/cmake/conan-bugfix-global-target.cmake new file mode 100644 index 0000000000000..c0510f74c3f8b --- /dev/null +++ b/recipes/magnum-plugins/all/cmake/conan-bugfix-global-target.cmake @@ -0,0 +1,24 @@ +# If using 'cmake_find_package', all the components are being added to the global +# target unconditionally. See generated FindMagnumPlugins.cmake file: +# +# if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0") +# if(NOT TARGET MagnumPlugins::MagnumPlugins) +# add_library(MagnumPlugins::MagnumPlugins INTERFACE IMPORTED) +# endif() +# set_property(TARGET MagnumPlugins::MagnumPlugins APPEND PROPERTY +# INTERFACE_LINK_LIBRARIES "${MagnumPlugins_COMPONENTS}") +# endif() +# +# but it doesn't add the library directories and the linker will fail. +# +# Here we fix this bug (breaking change) for this recipe, we just override +# the list of targets again. +# + + +if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0") + if(TARGET MagnumPlugins::MagnumPlugins) + set_target_properties(MagnumPlugins::MagnumPlugins PROPERTIES INTERFACE_LINK_LIBRARIES + "${MagnumPlugins_MagnumPlugins_LINK_LIBS};${MagnumPlugins_MagnumPlugins_LINKER_FLAGS_LIST}") + endif() +endif() diff --git a/recipes/magnum-plugins/all/conandata.yml b/recipes/magnum-plugins/all/conandata.yml new file mode 100644 index 0000000000000..1d75399fc10a4 --- /dev/null +++ b/recipes/magnum-plugins/all/conandata.yml @@ -0,0 +1,11 @@ +sources: + "2020.06": + url: "https://github.com/mosra/magnum-plugins/archive/refs/tags/v2020.06.tar.gz" + sha256: "8650cab43570c826d2557d5b42459150d253316f7f734af8b3e7d0883510b40a" +patches: + "2020.06": + - base_path: "source_subfolder" + patch_file: "patches/2020.06/0001-emscripten-toolchain.patch" + # patch_type: "portability" + # description: "Remove unnecessary dependency on UseEmscripten" + # source: "https://github.com/mosra/magnum/issues/490" diff --git a/recipes/magnum-plugins/all/conanfile.py b/recipes/magnum-plugins/all/conanfile.py new file mode 100644 index 0000000000000..4166f74284b52 --- /dev/null +++ b/recipes/magnum-plugins/all/conanfile.py @@ -0,0 +1,322 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os +import textwrap + +required_conan_version = ">=1.33.0" + + +class MagnumConan(ConanFile): + name = "magnum-plugins" + description = "Plugins for the Magnum C++11/C++14 graphics engine" + license = "MIT" + topics = ("magnum", "graphics", "rendering", "3d", "2d", "opengl") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://magnum.graphics" + + settings = "os", "compiler", "build_type", "arch" + + options = { + "shared": [True, False], + "fPIC": [True, False], + "shared_plugins": [True, False], + + "assimp_importer": [True, False], + "basis_imageconverter": [True, False], + "basis_importer": [True, False], + "dds_importer": [True, False], + "devil_imageimporter": [True, False], + "drflac_audioimporter": [True, False], + "drmp3_audioimporter": [True, False], + "drwav_audioimporter": [True, False], + "faad2_audioimporter": [True, False], + "freetype_font": [True, False], + "harfbuzz_font": [True, False], + "ico_importer": [True, False], + "jpeg_imageconverter": [True, False], + "jpeg_importer": [True, False], + "meshoptimizer_sceneconverter": [True, False], + "miniexr_imageconverter": [True, False], + "opengex_importer": [True, False], + "png_imageconverter": [True, False], + "png_importer": [True, False], + "primitive_importer": [True, False], + "stanford_importer": [True, False], + "stanford_sceneconverter": [True, False], + "stb_imageconverter": [True, False], + "stb_imageimporter": [True, False], + "stbtruetype_font": [True, False], + "stbvorbis_audioimporter": [True, False], + "stl_importer": [True, False], + "tinygltf_importer": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "shared_plugins": True, + + "assimp_importer": True, + "basis_imageconverter": False, + "basis_importer": False, + "dds_importer": True, + "devil_imageimporter": False, + "drflac_audioimporter": True, + "drmp3_audioimporter": True, + "drwav_audioimporter": True, + "faad2_audioimporter": False, + "freetype_font": True, + "harfbuzz_font": True, + "ico_importer": True, + "jpeg_imageconverter": True, + "jpeg_importer": True, + "meshoptimizer_sceneconverter": True, + "miniexr_imageconverter": True, + "opengex_importer": True, + "png_imageconverter": True, + "png_importer": True, + "primitive_importer": True, + "stanford_importer": True, + "stanford_sceneconverter": True, + "stb_imageconverter": True, + "stb_imageimporter": True, + "stbtruetype_font": True, + "stbvorbis_audioimporter": True, + "stl_importer": True, + "tinygltf_importer": True, + } + generators = "cmake", "cmake_find_package", "cmake_find_package_multi" + exports_sources = ["CMakeLists.txt", "cmake/*", "patches/*"] + + _cmake = None + short_paths = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + 'set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})', + "") + assimp_importer_cmake_file = os.path.join(self._source_subfolder, "src", "MagnumPlugins", "AssimpImporter", "CMakeLists.txt") + tools.replace_in_file(assimp_importer_cmake_file, + "find_package(Assimp REQUIRED)", + "find_package(assimp REQUIRED)") + tools.replace_in_file(assimp_importer_cmake_file, + "Assimp::Assimp", + "assimp::assimp") + + harfbuzz_cmake_file = os.path.join(self._source_subfolder, "src", "MagnumPlugins", "HarfBuzzFont", "CMakeLists.txt") + tools.replace_in_file(harfbuzz_cmake_file, + "find_package(HarfBuzz REQUIRED)", + "find_package(harfbuzz REQUIRED)") + tools.replace_in_file(harfbuzz_cmake_file, + "HarfBuzz::HarfBuzz", + "harfbuzz::harfbuzz") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + if self.settings.os == "Emscripten": + self.options.shared_plugins = False + # FIXME: Transitive dep 'glib' is not prepared for Emscripten (https://github.com/emscripten-core/emscripten/issues/11066) + self.options.harfbuzz_font = False + # Audio is not provided by Magnum + self.options.drflac_audioimporter = False + self.options.drmp3_audioimporter = False + self.options.drwav_audioimporter = False + self.options.faad2_audioimporter = False + self.options.stbvorbis_audioimporter = False + # FIXME: Conan package fails for 'brotli' + self.options.freetype_font = False + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def requirements(self): + self.requires("magnum/{}".format(self.version)) + if self.options.assimp_importer: + self.requires("assimp/5.0.1") + if self.options.harfbuzz_font: + self.requires("harfbuzz/2.8.2") + if self.options.freetype_font: + self.requires("freetype/2.11.0") + if self.options.jpeg_importer or self.options.jpeg_imageconverter: + self.requires("libjpeg/9d") + if self.options.meshoptimizer_sceneconverter: + self.requires("meshoptimizer/0.15") + if self.options.png_imageconverter: + self.requires("libpng/1.6.37") + if self.options.basis_imageconverter or self.options.basis_importer: + raise ConanInvalidConfiguration("Requires 'basisuniversal', not available in ConanCenter yet") + if self.options.devil_imageimporter: + raise ConanInvalidConfiguration("Requires 'DevIL', not available in ConanCenter yet") + if self.options.faad2_audioimporter: + raise ConanInvalidConfiguration("Requires 'faad2', not available in ConanCenter yet") + + def build_requirements(self): + self.build_requires("corrade/{}".format(self.version)) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, 11) + + if not self.options["magnum"].trade: + raise ConanInvalidConfiguration("Magnum Trade is required") + + # TODO: There are lot of things to check here: 'magnum::audio' required for audio plugins... + + def _configure_cmake(self): + if self._cmake: + return self._cmake + + self._cmake = CMake(self) + self._cmake.definitions["BUILD_STATIC"] = not self.options.shared + self._cmake.definitions["BUILD_STATIC_PIC"] = self.options.get_safe("fPIC", False) + self._cmake.definitions["BUILD_PLUGINS_STATIC"] = not self.options.shared_plugins + self._cmake.definitions["LIB_SUFFIX"] = "" + self._cmake.definitions["BUILD_TESTS"] = False + + self._cmake.definitions["WITH_ASSIMPIMPORTER"] = self.options.assimp_importer + self._cmake.definitions["WITH_BASISIMAGECONVERTER"] = self.options.basis_imageconverter + self._cmake.definitions["WITH_BASISIMPORTER"] = self.options.basis_importer + self._cmake.definitions["WITH_DDSIMPORTER"] = self.options.dds_importer + self._cmake.definitions["WITH_DEVILIMAGEIMPORTER"] = self.options.devil_imageimporter + self._cmake.definitions["WITH_DRFLACAUDIOIMPORTER"] = self.options.drflac_audioimporter + self._cmake.definitions["WITH_DRMP3AUDIOIMPORTER"] = self.options.drmp3_audioimporter + self._cmake.definitions["WITH_DRWAVAUDIOIMPORTER"] = self.options.drwav_audioimporter + self._cmake.definitions["WITH_FAAD2AUDIOIMPORTER"] = self.options.faad2_audioimporter + self._cmake.definitions["WITH_FREETYPEFONT"] = self.options.freetype_font + self._cmake.definitions["WITH_HARFBUZZFONT"] = self.options.harfbuzz_font + self._cmake.definitions["WITH_ICOIMPORTER"] = self.options.ico_importer + self._cmake.definitions["WITH_JPEGIMAGECONVERTER"] = self.options.jpeg_imageconverter + self._cmake.definitions["WITH_JPEGIMPORTER"] = self.options.jpeg_importer + self._cmake.definitions["WITH_MESHOPTIMIZERSCENECONVERTER"] = self.options.meshoptimizer_sceneconverter + self._cmake.definitions["WITH_MINIEXRIMAGECONVERTER"] = self.options.miniexr_imageconverter + self._cmake.definitions["WITH_OPENGEXIMPORTER"] = self.options.opengex_importer + self._cmake.definitions["WITH_PNGIMAGECONVERTER"] = self.options.png_imageconverter + self._cmake.definitions["WITH_PNGIMPORTER"] = self.options.png_importer + self._cmake.definitions["WITH_PRIMITIVEIMPORTER"] = self.options.primitive_importer + self._cmake.definitions["WITH_STANFORDIMPORTER"] = self.options.stanford_importer + self._cmake.definitions["WITH_STANFORDSCENECONVERTER"] = self.options.stanford_sceneconverter + self._cmake.definitions["WITH_STBIMAGECONVERTER"] = self.options.stb_imageconverter + self._cmake.definitions["WITH_STBIMAGEIMPORTER"] = self.options.stb_imageimporter + self._cmake.definitions["WITH_STBTRUETYPEFONT"] = self.options.stbtruetype_font + self._cmake.definitions["WITH_STBVORBISAUDIOIMPORTER"] = self.options.stbvorbis_audioimporter + self._cmake.definitions["WITH_STLIMPORTER"] = self.options.stl_importer + self._cmake.definitions["WITH_TINYGLTFIMPORTER"] = self.options.tinygltf_importer + + self._cmake.configure() + return self._cmake + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + + def build(self): + self._patch_sources() + + cm = self._configure_cmake() + cm.build() + + def package(self): + cm = self._configure_cmake() + cm.install() + + if not self.options.shared_plugins: + build_modules_folder = os.path.join(self.package_folder, "lib", "cmake") + os.makedirs(build_modules_folder) + for component, target, library, folder, deps in self._plugins: + build_module_path = os.path.join(build_modules_folder, "conan-magnum-plugins-{}.cmake".format(component)) + with open(build_module_path, "w+") as f: + f.write(textwrap.dedent("""\ + if(NOT ${{CMAKE_VERSION}} VERSION_LESS "3.0") + if(TARGET MagnumPlugins::{target}) + set_target_properties(MagnumPlugins::{target} PROPERTIES INTERFACE_SOURCES + "${{CMAKE_CURRENT_LIST_DIR}}/../../include/MagnumPlugins/{library}/importStaticPlugin.cpp") + endif() + endif() + """.format(target=target, library=library))) + + tools.rmdir(os.path.join(self.package_folder, "share")) + self.copy("*.cmake", src=os.path.join(self.source_folder, "cmake"), dst=os.path.join("lib", "cmake")) + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "MagnumPlugins" + self.cpp_info.names["cmake_find_package_multi"] = "MagnumPlugins" + + magnum_plugin_libdir = "magnum-d" if self.settings.build_type == "Debug" else "magnum" + lib_suffix = "-d" if self.settings.build_type == "Debug" else "" + + self.cpp_info.components["magnumopenddl"].names["cmake_find_package"] = "MagnumOpenDdl" + self.cpp_info.components["magnumopenddl"].names["cmake_find_package_multi"] = "MagnumOpenDdl" + self.cpp_info.components["magnumopenddl"].libs = ["MagnumOpenDdl{}".format(lib_suffix)] + self.cpp_info.components["magnumopenddl"].requires = ["magnum::magnum"] + + # Plugins + if self.options.basis_imageconverter: + raise ConanException("Component not defined, please contribute it to the Conan recipe") + + if self.options.basis_importer: + raise ConanException("Component not defined, please contribute it to the Conan recipe") + + if self.options.devil_imageimporter: + raise ConanException("Component not defined, please contribute it to the Conan recipe") + + if self.options.faad2_audioimporter: + raise ConanException("Component not defined, please contribute it to the Conan recipe") + + # The global target doesn't provide anything in this package. Null it. + self.cpp_info.components["_global_target"].names["cmake_find_package"] = "MagnumPlugins" + self.cpp_info.components["_global_target"].names["cmake_find_package_multi"] = "MagnumPlugins" + self.cpp_info.components["_global_target"].build_modules["cmake_find_package"].append(os.path.join("lib", "cmake", "conan-bugfix-global-target.cmake")) + + # Add all the plugins + for component, target, library, folder, deps in self._plugins: + self.cpp_info.components[component].names["cmake_find_package"] = target + self.cpp_info.components[component].names["cmake_find_package_multi"] = target + self.cpp_info.components[component].libs = [library] + self.cpp_info.components[component].libdirs = [os.path.join(self.package_folder, "lib", magnum_plugin_libdir, folder)] + self.cpp_info.components[component].requires = deps + if not self.options.shared_plugins: + self.cpp_info.components[component].build_modules.append(os.path.join("lib", "cmake", "conan-magnum-plugins-{}.cmake".format(component))) + plugin_dir = "bin" if self.settings.os == "Windows" else "lib" + self.user_info.plugins_basepath = os.path.join(self.package_folder, plugin_dir, magnum_plugin_libdir) + + @property + def _plugins(self): + # (opt_name, (component, target, library, folder, deps)) + all_plugins = ( + ("assimp_importer", ("assimp_importer", "AssimpImporter", "AssimpImporter", "importers", ["magnum::trade", "assimp::assimp"])), + ("basis_imageconverter", ("basis_imageconverter", "--", "--", "--", [])), + ("basis_importer", ("basis_importer", "--", "--", "--", [])), + ("dds_importer", ("dds_importer", "DdsImporter", "DdsImporter", "importers", ["magnum::trade"])), + ("devil_imageimporter", ("devil_imageimporter", "--", "--", "--", [])), + ("drflac_audioimporter", ("drflac_audioimporter", "DrFlacAudioImporter", "DrFlacAudioImporter", "audioimporters", ["magnum::audio"])), + ("drmp3_audioimporter", ("drmp3_audioimporter", "DrMp3AudioImporter", "DrMp3AudioImporter", "audioimporters", ["magnum::audio"])), + ("drwav_audioimporter", ("drwav_audioimporter", "DrWavAudioImporter", "DrWavAudioImporter", "audioimporters", ["magnum::audio"])), + ("faad2_audioimporter", ("faad2_audioimporter", "--", "--", "--", [])), + ("freetype_font", ("freetype_font", "FreeTypeFont", "FreeTypeFont", "fonts", ["magnum::text", "freetype::freetype"])), + ("harfbuzz_font", ("harfbuzz_font", "HarfBuzzFont", "HarfBuzzFont", "fonts", ["magnum::text", "harfbuzz::harfbuzz"])), + ("jpeg_imageconverter", ("jpeg_imageconverter", "JpegImageConverter", "JpegImageConverter", "imageconverters", ["magnum::trade", "libjpeg::libjpeg"])), + ("jpeg_importer", ("jpeg_importer", "JpegImporter", "JpegImporter", "importers", ["magnum::trade", "libjpeg::libjpeg"])), + ("meshoptimizer_sceneconverter", ("meshoptimizer_sceneconverter", "MeshOptimizerSceneConverter", "MeshOptimizerSceneConverter", "sceneconverters", ["magnum::trade", "magnum::mesh_tools", "meshoptimizer::meshoptimizer"])), + ("miniexr_imageconverter", ("miniexr_imageconverter", "MiniExrImageConverter", "MiniExrImageConverter", "imageconverters", ["magnum::trade"])), + ("opengex_importer", ("opengex_importer", "OpenGexImporter", "OpenGexImporter", "importers", ["magnum::trade", "magnumopenddl", "magnum::any_image_importer"])), + ("png_importer", ("png_importer", "PngImporter", "PngImporter", "importers", ["magnum::trade", "libpng::libpng"])), + ("png_imageconverter", ("png_imageconverter", "PngImageConverter", "PngImageConverter", "imageconverters", ["magnum::trade"])), + ("primitive_importer", ("primitive_importer", "PrimitiveImporter", "PrimitiveImporter", "importers", ["magnum::primitives", "magnum::trade"])), + ("stanford_importer", ("stanford_importer", "StanfordImporter", "StanfordImporter", "importers", ["magnum::mesh_tools", "magnum::trade"])), + ("stanford_sceneconverter", ("stanford_sceneconverter", "StanfordSceneConverter", "StanfordSceneConverter", "sceneconverters", ["magnum::mesh_tools", "magnum::trade"])), + ("stb_imageconverter", ("stb_imageconverter", "StbImageConverter", "StbImageConverter", "imageconverters", ["magnum::trade"])), + ("stb_imageimporter", ("stb_imageimporter", "StbImageImporter", "StbImageImporter", "importers", ["magnum::trade"])), + ("stbtruetype_font", ("stbtruetype_font", "StbTrueTypeFont", "StbTrueTypeFont", "fonts", ["magnum::text"])), + ("stbvorbis_audioimporter", ("stbvorbis_audioimporter", "StbVorbisAudioImporter", "StbVorbisAudioImporter", "audioimporters", ["magnum::audio"])), + ("tinygltf_importer", ("tinygltf_importer", "TinyGltfImporter", "TinyGltfImporter", "importers", ["magnum::trade", "magnum::any_image_importer"])), + ("stl_importer", ("stl_importer", "StlImporter", "StlImporter", "importers", ["magnum::mesh_tools", "magnum::trade"])), + ) + return [plugin for opt_name, plugin in all_plugins if self.options.get_safe(opt_name)] diff --git a/recipes/magnum-plugins/all/patches/2020.06/0001-emscripten-toolchain.patch b/recipes/magnum-plugins/all/patches/2020.06/0001-emscripten-toolchain.patch new file mode 100644 index 0000000000000..8f3c18b38cd2e --- /dev/null +++ b/recipes/magnum-plugins/all/patches/2020.06/0001-emscripten-toolchain.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c85f70c..217427f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -91,10 +91,6 @@ elseif(CORRADE_TARGET_IOS OR CORRADE_TARGET_WINDOWS_RT) + set(BUILD_PLUGINS_STATIC ON) + endif() + +-if(CORRADE_TARGET_EMSCRIPTEN) +- include(UseEmscripten) +-endif() +- + if(BUILD_TESTS) + find_package(Corrade REQUIRED TestSuite) + if(CORRADE_TARGET_IOS) diff --git a/recipes/magnum-plugins/all/test_package/CMakeLists.txt b/recipes/magnum-plugins/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3ae91f1bb266f --- /dev/null +++ b/recipes/magnum-plugins/all/test_package/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.11) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +if(SHARED_PLUGINS) + find_package(MagnumPlugins REQUIRED) +else() + find_package(MagnumPlugins REQUIRED StlImporter) +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.in + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + +add_executable(${PROJECT_NAME} test_package.cpp) +# Intentionally linking with the global 'MagnumPlugins::MagnumPlugins' target, I want to check it is a valid target (although it might be empty) +target_link_libraries(${PROJECT_NAME} PRIVATE Magnum::Trade MagnumPlugins::MagnumPlugins) +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +if(NOT SHARED_PLUGINS) + target_link_libraries(${PROJECT_NAME} PRIVATE MagnumPlugins::StlImporter) +endif() +set_target_properties(${PROJECT_NAME} + PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) + +if(TARGET_EMSCRIPTEN) + message("Embed OBJ file") + set_target_properties(${PROJECT_NAME} + PROPERTIES + LINK_FLAGS "--embed-file ${CONAN_STL_FILE}@${CONAN_STL_FILE}" + ) +endif() diff --git a/recipes/magnum-plugins/all/test_package/conan.stl b/recipes/magnum-plugins/all/test_package/conan.stl new file mode 100644 index 0000000000000000000000000000000000000000..2c3b057418d79884ef44ecd39d8770f48a38462a GIT binary patch literal 9084 zcmb_hO=w+36ds}$7Z0gYkr0XjaqYS)x$iy&rCo|rx~STnS|qqo5UbBhu@J$98>wlC zpl*axq*!#3_d+7*LR<)fwn2&&MZt8@E<}pnZ_fSh`R2~OZ)FzkN9KHUe&@`Yn-Kor zp9^ujapAizjzYM$8Nzb)KQUG#F75XrWQ=;Hi(z|@C$3|?+W%V3AjWFM)tddxWYkh* zz}jDbSSYT}ABuV&*!igZ?s@Zx zOiI}<-)5-PsXw>M&(6-rokFN0TT~H_(N!J9uw5hF&rm61^W&$>w=J!Hdm=`+s<`se zm3?&-4MPWGl{2`KOF27)O2-Cuyt1)1WTuEM2dY~cw5lzYva1T2RF$%UIPW|6?i5i3 zgBZ5|^;$7yo&EM4Z52*%#H-tHmEXMlUj2L2Ev?er5`(ST zj8=6rREjvS#AACGr*0L``SR%Kmp7)PXNuY?P}6pmcYfnk6-y?0`0_z0@=X*43#1_KhSg88MH=;A@$403lsL^*cmz* zDn)EoVSn~^u3+D%_pdCmpY!*|K&7)&>**v0du{jLAv(DE(Z^6JV$<=^cPA$2KegIr zWne`shB)yfb~xROn6bL@>gq7j5i_W{C02d28EOf!d2W@(`<8e3^621TSe??YX`q`C zf-)SNH2)nJ@4vWHq61hCE|!N6T#YB{@PV5p&Zb%g*0^AFv7%DwK4f!$W3VTJp|`W@ zP8sZ$ZHDfYGE_TH6xeEQ%1|jiMg5F7oh-)s0F=#e=J{A~yD7dG4_@b#HeqHkU9{ngdJ#sP^0{T~UT+ zGla_P4R{Y-nkiyfm0H-xP$}Zvs&vJ?H7T7L)N{-XhzX?byY%c3H}Y(TdZ_w1;pA57 ziZVE_7^8|)0qcZaB+kA48>xO~)6P7bY*5QJ>nF5A6WN(4jsx=R9Mm z6tU?*jO=Gzpd3boO{l0i4~o~+2L{qdm>g;>e$}(DW}0Yu<<`c*SaVeDwUp(dXlNm zR|uF`c++=H0A^J^x5wVDHx4nP%X z&rm61^TXpiE>yebL$leuqoU`!7cs0-|EfONbE~myns$FXg`uufQznx>O z^j0H=4$WrscFq_oMXVX*cNxBAU@b8!gI{sn3p?xH8T8C+XJ|9DXE;vT&Oxj+KAhEA zB_1nGF}%;Ue-MMgThwx+46d}LlufG`E5@W9AB`LACr`a~Y_albc@~3GU>nBXRV6NQ zzM>y__33=o#jtAddQEq#teVgdpU-X5=MA8>(0o-(DiKz(cA-z_m41dw5u1PYlo3y@ zo^4`Cv3h1RREpRlVqRMobwyv0#Kx#{Q6R!#swKpb(w-keA48>x%@2Los&-;X=~-d! z@V|8*c53Z#u#jIVQik3#dcSJdP8m9}s19YP41Hm<`VcGCoicPUl}b--9o-FZ)k9*$ zDvfR*L#2qdN}yp}XiU^XjRGY3GcGh%v4C5-rmPhDPpw>etXVs#lIS;wUFe` zxZpep1}6(()^4stSCqkT=^>ca}V z#B7H8q5CS^ZGz{lYSZqs2v0$7l}~q=WSjw?y1&WrRgJy)`n7#^CUU#R1>cr!sg$jZ z)DN{pEmVfiRB63>9lJbYrB?9`*tRfbXsndMm!+|tgR|~2Nu}cN>+f^Q(D|xnM=77L zkSG6v4)@S!L!H9g4Bj$kuSb-(T9+R#rTTgq)x1d0b-EA1^W;7NVZwAqDn;FGhI@+@ zMq#!Nm-1?#&0wbV`$g)L+ST|`Wvwmc{*hsGwff<>IgfECGVs6kUH*Mgy97EaUPXBZ z(K+$A6s)L}vQr)W(hP=5q32U~%FtV1^(i}L=>4Hmsyk)q*;akZP8pn7+J1o19V^wL z`|3`q4!u)#UuCBZ-r=xH*}$02@%xmad#RMN$>4j9)t=T;T4Us(uCzz#%&48n<-y?e zYWDJ^w!a8F$NnnQo<)t#lh*b;?R_q#`F9PliW4OEO{JWjGBoFi58t&Z+c~kfH#a1| Ko{Jx);r{@8)glf6 literal 0 HcmV?d00001 diff --git a/recipes/magnum-plugins/all/test_package/conanfile.py b/recipes/magnum-plugins/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0f32ed1a04aad --- /dev/null +++ b/recipes/magnum-plugins/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +import os +from conans import ConanFile, CMake, tools + +class TestPackage(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.definitions["IMPORTER_PLUGINS_FOLDER"] = os.path.join(self.deps_user_info["magnum-plugins"].plugins_basepath, "importers").replace("\\", "/") + # STL file taken from https://www.thingiverse.com/thing:2798332 + cmake.definitions["CONAN_STL_FILE"] = os.path.join(self.source_folder, "conan.stl").replace("\\", "/") + cmake.definitions["SHARED_PLUGINS"] = self.options["magnum-plugins"].shared_plugins + cmake.definitions["TARGET_EMSCRIPTEN"] = bool(self.settings.os == "Emscripten") + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + + if self.settings.os == "Emscripten": + bin_path = os.path.join("bin", "test_package.js") + self.run("node {}".format(bin_path), run_environment=True) diff --git a/recipes/magnum-plugins/all/test_package/configure.h.in b/recipes/magnum-plugins/all/test_package/configure.h.in new file mode 100644 index 0000000000000..b1e33dc1f4f4c --- /dev/null +++ b/recipes/magnum-plugins/all/test_package/configure.h.in @@ -0,0 +1,4 @@ + + +#cmakedefine IMPORTER_PLUGINS_FOLDER "${IMPORTER_PLUGINS_FOLDER}" +#cmakedefine CONAN_STL_FILE "${CONAN_STL_FILE}" diff --git a/recipes/magnum-plugins/all/test_package/test_package.cpp b/recipes/magnum-plugins/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..65c01dcb6da3c --- /dev/null +++ b/recipes/magnum-plugins/all/test_package/test_package.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +#include "configure.h" + +int main() { + Corrade::PluginManager::Manager manager{IMPORTER_PLUGINS_FOLDER}; + manager.load("StlImporter"); + auto importer = manager.instantiate("StlImporter"); + + if(!importer) Magnum::Fatal{} << "Cannot load the StlImporter plugin"; + + importer->openFile(CONAN_STL_FILE); + std::cout << "Mesh count: " << importer->meshCount() << "\n"; + return 0; +} diff --git a/recipes/magnum-plugins/config.yml b/recipes/magnum-plugins/config.yml new file mode 100644 index 0000000000000..93230781a72ea --- /dev/null +++ b/recipes/magnum-plugins/config.yml @@ -0,0 +1,3 @@ +versions: + "2020.06": + folder: all