🔧 Added support for building MyGUI with conan v2

This commit is contained in:
2022-10-30 14:38:15 +01:00
parent 9761196edf
commit cab77497c1
4 changed files with 43 additions and 55 deletions

View File

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