From cab77497c1510153c30b8e32708e89b7a4a6a7fe Mon Sep 17 00:00:00 2001 From: Edgar Date: Sun, 30 Oct 2022 14:38:15 +0100 Subject: [PATCH] :wrench: Added support for building MyGUI with conan v2 --- mygui/all/conandata.yml | 11 +--- mygui/all/conanfile.py | 59 ++++++++++++++------ mygui/all/patches/3.4.0/CMakeLists.txt.patch | 14 ----- mygui/all/patches/3.4.1/CMakeLists.txt.patch | 14 ----- 4 files changed, 43 insertions(+), 55 deletions(-) delete mode 100644 mygui/all/patches/3.4.0/CMakeLists.txt.patch delete mode 100644 mygui/all/patches/3.4.1/CMakeLists.txt.patch diff --git a/mygui/all/conandata.yml b/mygui/all/conandata.yml index 5f3ab27..137622c 100644 --- a/mygui/all/conandata.yml +++ b/mygui/all/conandata.yml @@ -4,13 +4,4 @@ sources: sha256: "d1d5f294670ae71f7200ed4b30859018281d8cfd45d6a38d18b97a4aba604c42" "3.4.1": url: "https://github.com/MyGUI/mygui/archive/refs/tags/MyGUI3.4.1.tar.gz" - sha256: "bdf730bdeb4ad89e6b8223967db01aa5274d2b93adc2c0d6aa4842faeed4de1a" -patches: - "3.4.0": - - patch_file: "patches/3.4.0/CMakeLists.txt.patch" - "3.4.1": - - patch_file: "patches/3.4.1/CMakeLists.txt.patch" -requirements: - - "ogre3d/[1.x]@anotherfoxguy/stable" - - "freetype/[2.x]" - - "zlib/[1.x]" \ No newline at end of file + sha256: "bdf730bdeb4ad89e6b8223967db01aa5274d2b93adc2c0d6aa4842faeed4de1a" \ No newline at end of file diff --git a/mygui/all/conanfile.py b/mygui/all/conanfile.py index 1725c89..559a708 100644 --- a/mygui/all/conanfile.py +++ b/mygui/all/conanfile.py @@ -1,5 +1,7 @@ -from conans import ConanFile, CMake, tools -from conans.tools import os_info, SystemPackageTool +from conan import ConanFile +from conan.tools.files import get, collect_libs, replace_in_file +from conan.tools.cmake import CMakeToolchain, CMake, CMakeDeps, cmake_layout +import os class MyGUIConan(ConanFile): @@ -8,30 +10,49 @@ class MyGUIConan(ConanFile): url = "https://github.com/AnotherFoxGuy/conan-MyGUI" description = "Fast, flexible and simple GUI." settings = "os", "compiler", "build_type", "arch" - generators = "cmake_paths", "cmake_find_package" - exports_sources = "patches/**" options = {"system_ogre": [True, False]} default_options = {"system_ogre": False} + def layout(self): + cmake_layout(self) + def requirements(self): if not self.options.system_ogre: - for req in self.conan_data["requirements"]: - self.requires(req) + self.requires("ogre3d/[13.x]@anotherfoxguy/stable") def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True) - if not self.options.system_ogre: - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MYGUI_BUILD_DEMOS"] = "OFF" + tc.variables["MYGUI_BUILD_DOCS"] = "OFF" + tc.variables["MYGUI_BUILD_TEST_APP"] = "OFF" + tc.variables["MYGUI_BUILD_PLUGINS"] = "OFF" + tc.variables["MYGUI_BUILD_TOOLS"] = "OFF" + tc.variables["MYGUI_RENDERSYSTEM"] = "3" + tc.variables["OIS_BUILD_DEMOS"] = "OFF" + tc.variables["OIS_BUILD_DEMOS"] = "OFF" + tc.variables["OIS_BUILD_DEMOS"] = "OFF" + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + replace_in_file(self, + os.path.join(self.source_folder, "MyGUIEngine/CMakeLists.txt"), + "${FREETYPE_LIBRARIES}", + "freetype", + ) + replace_in_file(self, + os.path.join(self.source_folder, "Platforms/Ogre/OgrePlatform/CMakeLists.txt"), + "${OGRE_LIBRARIES}", + "OGRE::OGRE", + ) def build(self): + self._patch_sources() cmake = CMake(self) - cmake.definitions['MYGUI_BUILD_DEMOS'] = 'OFF' - cmake.definitions['MYGUI_BUILD_DOCS'] = 'OFF' - cmake.definitions['MYGUI_BUILD_TEST_APP'] = 'OFF' - cmake.definitions['MYGUI_BUILD_PLUGINS'] = 'OFF' - cmake.definitions['MYGUI_BUILD_TOOLS'] = 'OFF' - cmake.definitions['MYGUI_RENDERSYSTEM'] = '3' cmake.configure() cmake.build() @@ -40,10 +61,14 @@ class MyGUIConan(ConanFile): cmake.install() def package_info(self): + self.cpp_info.set_property("cmake_module_file_name", "MyGUI") + self.cpp_info.set_property("cmake_module_target_name", "MyGUI::MyGUI") + self.cpp_info.set_property("cmake_file_name", "MyGUI") + self.cpp_info.set_property("cmake_target_name", "MyGUI::MyGUI") self.cpp_info.includedirs = ['include/MYGUI'] # Directories where libraries can be found self.cpp_info.libdirs = ['lib', f'lib/{self.settings.build_type}'] - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = collect_libs(self) def package_id(self): if not self.options.system_ogre: diff --git a/mygui/all/patches/3.4.0/CMakeLists.txt.patch b/mygui/all/patches/3.4.0/CMakeLists.txt.patch deleted file mode 100644 index 927c02b..0000000 --- a/mygui/all/patches/3.4.0/CMakeLists.txt.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -11,8 +11,11 @@ - - project(MYGUI) - -+include(${CMAKE_BINARY_DIR}/conan_paths.cmake) -+ - # Include necessary submodules - set(CMAKE_MODULE_PATH -+ "${CMAKE_BINARY_DIR}" - "${MYGUI_SOURCE_DIR}/CMake" - "${MYGUI_SOURCE_DIR}/CMake/Utils" - "${MYGUI_SOURCE_DIR}/CMake/Packages" diff --git a/mygui/all/patches/3.4.1/CMakeLists.txt.patch b/mygui/all/patches/3.4.1/CMakeLists.txt.patch deleted file mode 100644 index ab4106a..0000000 --- a/mygui/all/patches/3.4.1/CMakeLists.txt.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- CMakeLists.txt -+++ CMakeLists.txt -@@ -22,8 +22,11 @@ - - project(MYGUI) - -+include(${CMAKE_BINARY_DIR}/conan_paths.cmake) -+ - # Include necessary submodules - set(CMAKE_MODULE_PATH -+ "${CMAKE_BINARY_DIR}" - "${MYGUI_SOURCE_DIR}/CMake" - "${MYGUI_SOURCE_DIR}/CMake/Utils" - "${MYGUI_SOURCE_DIR}/CMake/Packages"