🔧 Added support for building MyGUI with conan v2

This commit is contained in:
Edgar 2022-10-30 14:38:15 +01:00
parent 9761196edf
commit cab77497c1
No known key found for this signature in database
GPG Key ID: 17D930BB616061A5
4 changed files with 43 additions and 55 deletions

View File

@ -4,13 +4,4 @@ sources:
sha256: "d1d5f294670ae71f7200ed4b30859018281d8cfd45d6a38d18b97a4aba604c42" sha256: "d1d5f294670ae71f7200ed4b30859018281d8cfd45d6a38d18b97a4aba604c42"
"3.4.1": "3.4.1":
url: "https://github.com/MyGUI/mygui/archive/refs/tags/MyGUI3.4.1.tar.gz" url: "https://github.com/MyGUI/mygui/archive/refs/tags/MyGUI3.4.1.tar.gz"
sha256: "bdf730bdeb4ad89e6b8223967db01aa5274d2b93adc2c0d6aa4842faeed4de1a" 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]"

View File

@ -1,5 +1,7 @@
from conans import ConanFile, CMake, tools from conan import ConanFile
from conans.tools import os_info, SystemPackageTool 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): class MyGUIConan(ConanFile):
@ -8,30 +10,49 @@ class MyGUIConan(ConanFile):
url = "https://github.com/AnotherFoxGuy/conan-MyGUI" url = "https://github.com/AnotherFoxGuy/conan-MyGUI"
description = "Fast, flexible and simple GUI." description = "Fast, flexible and simple GUI."
settings = "os", "compiler", "build_type", "arch" settings = "os", "compiler", "build_type", "arch"
generators = "cmake_paths", "cmake_find_package"
exports_sources = "patches/**"
options = {"system_ogre": [True, False]} options = {"system_ogre": [True, False]}
default_options = {"system_ogre": False} default_options = {"system_ogre": False}
def layout(self):
cmake_layout(self)
def requirements(self): def requirements(self):
if not self.options.system_ogre: if not self.options.system_ogre:
for req in self.conan_data["requirements"]: self.requires("ogre3d/[13.x]@anotherfoxguy/stable")
self.requires(req)
def source(self): def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True) get(self, **self.conan_data["sources"][self.version], strip_root=True)
if not self.options.system_ogre:
for patch in self.conan_data["patches"][self.version]: def generate(self):
tools.patch(**patch) 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): def build(self):
self._patch_sources()
cmake = CMake(self) 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.configure()
cmake.build() cmake.build()
@ -40,10 +61,14 @@ class MyGUIConan(ConanFile):
cmake.install() cmake.install()
def package_info(self): 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'] self.cpp_info.includedirs = ['include/MYGUI']
# Directories where libraries can be found # Directories where libraries can be found
self.cpp_info.libdirs = ['lib', f'lib/{self.settings.build_type}'] 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): def package_id(self):
if not self.options.system_ogre: if not self.options.system_ogre:

View File

@ -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"

View File

@ -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"