🔧 Added support for building ogre3d with conan v2

This commit is contained in:
Edgar 2022-10-21 12:09:37 +00:00
parent 7e4f63f99e
commit 46e4195d1a
5 changed files with 76 additions and 111 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ upload.*
.idea/
build_tmp.py
__pycache__
conanfile-old.py

View File

@ -25,41 +25,26 @@ sources:
sha256: "7cf05dbb3acbfc9326daecb60429a8ae9ce7625fb425e6a29de00cf77454596f"
patches:
"13.2.4":
- patch_file: "patches/13.2.4/CMakeLists.txt.patch"
- patch_file: "patches/13.2.4/pugixml-fix.patch"
- patch_file: "patches/13.2.4/FindPkgMacros.cmake.patch"
"13.3.1":
- patch_file: "patches/13.3.1/CMakeLists.txt.patch"
- patch_file: "patches/13.3.1/pugixml-fix.patch"
- patch_file: "patches/13.3.1/FindPkgMacros.cmake.patch"
"13.3.2":
- patch_file: "patches/13.3.1/CMakeLists.txt.patch"
- patch_file: "patches/13.3.1/pugixml-fix.patch"
- patch_file: "patches/13.3.1/FindPkgMacros.cmake.patch"
"13.3.3":
- patch_file: "patches/13.3.1/CMakeLists.txt.patch"
- patch_file: "patches/13.3.1/pugixml-fix.patch"
- patch_file: "patches/13.3.1/FindPkgMacros.cmake.patch"
"13.4.1":
- patch_file: "patches/13.3.1/CMakeLists.txt.patch"
- patch_file: "patches/13.3.1/pugixml-fix.patch"
- patch_file: "patches/13.3.1/FindPkgMacros.cmake.patch"
"13.4.2":
- patch_file: "patches/13.3.1/CMakeLists.txt.patch"
- patch_file: "patches/13.3.1/pugixml-fix.patch"
- patch_file: "patches/13.3.1/FindPkgMacros.cmake.patch"
"13.4.3":
- patch_file: "patches/13.3.1/CMakeLists.txt.patch"
- patch_file: "patches/13.3.1/pugixml-fix.patch"
- patch_file: "patches/13.3.1/FindPkgMacros.cmake.patch"
"13.4.4":
- patch_file: "patches/13.3.1/CMakeLists.txt.patch"
- patch_file: "patches/13.3.1/pugixml-fix.patch"
- patch_file: "patches/13.3.1/FindPkgMacros.cmake.patch"
requirements:
- "zlib/[1.x]"
- "zziplib/[0.13.x]"
- "freetype/[2.x]"
- "freeimage/[3.x]"
- "cg-toolkit/3.1@anotherfoxguy/stable"
- "pugixml/[1.x]"

View File

@ -1,7 +1,8 @@
import shutil
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,copy, replace_in_file, apply_conandata_patches, export_conandata_patches
from conan.tools.cmake import CMakeToolchain, CMake, CMakeDeps, cmake_layout
from conan.tools.system.package_manager import Apt
import os
class OGREConan(ConanFile):
name = "ogre3d"
@ -9,8 +10,6 @@ class OGREConan(ConanFile):
url = "https://github.com/AnotherFoxGuy/conan-OGRE"
description = "scene-oriented, flexible 3D engine written in C++"
settings = "os", "compiler", "build_type", "arch"
generators = "cmake_find_package"
exports_sources = "patches/**"
options = {
"resourcemanager_strict": ["off", "pedantic", "strict"],
@ -22,95 +21,95 @@ class OGREConan(ConanFile):
"nodeless_positioning": False,
}
_cmake = None
def export_sources(self):
export_conandata_patches(self)
def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["OGRE_BUILD_COMPONENT_BITES"] = "ON"
self._cmake.definitions["OGRE_BUILD_COMPONENT_CSHARP"] = "OFF"
self._cmake.definitions["OGRE_BUILD_COMPONENT_JAVA"] = "OFF"
self._cmake.definitions["OGRE_BUILD_COMPONENT_OVERLAY_IMGUI"] = "ON"
self._cmake.definitions["OGRE_BUILD_COMPONENT_PYTHON"] = "OFF"
self._cmake.definitions["OGRE_BUILD_DEPENDENCIES"] = "OFF"
self._cmake.definitions["OGRE_BUILD_PLUGIN_DOT_SCENE"] = "OFF"
self._cmake.definitions["OGRE_BUILD_PLUGIN_STBI"] = "ON"
self._cmake.definitions["OGRE_BUILD_PLUGIN_EXRCODEC"] = "OFF"
self._cmake.definitions["OGRE_BUILD_RENDERSYSTEM_D3D11"] = "ON"
self._cmake.definitions["OGRE_BUILD_RENDERSYSTEM_D3D9"] = "ON"
self._cmake.definitions["OGRE_BUILD_RENDERSYSTEM_GL3PLUS"] = "OFF"
self._cmake.definitions["OGRE_BUILD_SAMPLES"] = "OFF"
self._cmake.definitions["OGRE_COPY_DEPENDENCIES"] = "OFF"
self._cmake.definitions["OGRE_INSTALL_DEPENDENCIES"] = "OFF"
self._cmake.definitions["OGRE_INSTALL_SAMPLES"] = "OFF"
self._cmake.definitions[
"OGRE_NODELESS_POSITIONING"
] = self.options.nodeless_positioning
if self.options.resourcemanager_strict == "off":
self._cmake.definitions["OGRE_RESOURCEMANAGER_STRICT"] = 0
elif self.options.resourcemanager_strict == "pedantic":
self._cmake.definitions["OGRE_RESOURCEMANAGER_STRICT"] = 1
else:
self._cmake.definitions["OGRE_RESOURCEMANAGER_STRICT"] = 2
if os_info.is_windows:
self._cmake.definitions[
"CMAKE_CXX_FLAGS"
] = "-D_OGRE_FILESYSTEM_ARCHIVE_UNICODE"
self._cmake.configure()
return self._cmake
def layout(self):
cmake_layout(self)
def requirements(self):
for req in self.conan_data["requirements"]:
self.requires(req)
if os_info.is_windows:
self.requires("zlib/[1.x]")
self.requires("zziplib/[0.13.x]")
self.requires("freetype/[2.x]")
self.requires("freeimage/[3.x]")
self.requires("cg-toolkit/3.1@anotherfoxguy/stable")
self.requires("pugixml/[1.x]")
self.requires("libpng/1.6.38")
if self.settings.os == "Windows":
self.requires("directx-sdk/9.0@anotherfoxguy/stable")
def system_requirements(self):
if os_info.is_linux:
if os_info.with_apt:
installer = SystemPackageTool()
installer.install("libx11-dev")
installer.install("libxaw7-dev")
installer.install("libxrandr-dev")
installer.install("libgles2-mesa-dev")
installer.install("libvulkan-dev")
installer.install("glslang-dev")
Apt(self).install([
"libx11-dev",
"libxaw7-dev",
"libxrandr-dev",
"libgles2-mesa-dev",
"libvulkan-dev",
"glslang-dev"
], check=True)
def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True)
tools.replace_in_file(
"CMake/Dependencies.cmake",
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["OGRE_BUILD_COMPONENT_BITES"] = "ON"
tc.variables["OGRE_BUILD_COMPONENT_CSHARP"] = "OFF"
tc.variables["OGRE_BUILD_COMPONENT_JAVA"] = "OFF"
tc.variables["OGRE_BUILD_COMPONENT_OVERLAY_IMGUI"] = "ON"
tc.variables["OGRE_BUILD_COMPONENT_PYTHON"] = "OFF"
tc.variables["OGRE_BUILD_DEPENDENCIES"] = "OFF"
tc.variables["OGRE_BUILD_PLUGIN_DOT_SCENE"] = "OFF"
tc.variables["OGRE_BUILD_PLUGIN_STBI"] = "ON"
tc.variables["OGRE_BUILD_PLUGIN_EXRCODEC"] = "OFF"
tc.variables["OGRE_BUILD_RENDERSYSTEM_D3D11"] = "ON"
tc.variables["OGRE_BUILD_RENDERSYSTEM_D3D9"] = "ON"
tc.variables["OGRE_BUILD_RENDERSYSTEM_GL3PLUS"] = "OFF"
tc.variables["OGRE_BUILD_SAMPLES"] = "OFF"
tc.variables["OGRE_COPY_DEPENDENCIES"] = "OFF"
tc.variables["OGRE_INSTALL_DEPENDENCIES"] = "OFF"
tc.variables["OGRE_INSTALL_SAMPLES"] = "OFF"
tc.variables["OGRE_NODELESS_POSITIONING"] = self.options.nodeless_positioning
if self.options.resourcemanager_strict == "off":
tc.variables["OGRE_RESOURCEMANAGER_STRICT"] = 0
elif self.options.resourcemanager_strict == "pedantic":
tc.variables["OGRE_RESOURCEMANAGER_STRICT"] = 1
else:
tc.variables["OGRE_RESOURCEMANAGER_STRICT"] = 2
if self.settings.os == "Windows":
tc.variables["CMAKE_CXX_FLAGS"] = "-D_OGRE_FILESYSTEM_ARCHIVE_UNICODE"
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def _patch_sources(self):
apply_conandata_patches(self)
replace_in_file(self,
os.path.join(self.source_folder,"CMake/Dependencies.cmake"),
"find_package(DirectX)",
"find_package(DirectX9)",
)
tools.replace_in_file(
"CMake/Dependencies.cmake",
"find_package(FreeImage)",
"find_package(ConanFreeImage)",
replace_in_file(self,
os.path.join(self.source_folder,"PlugIns/FreeImageCodec/CMakeLists.txt"),
"${FreeImage_LIBRARIES}",
"freeimage::FreeImage",
)
tools.replace_in_file(
"CMake/Packages/FindDirectX11.cmake",
replace_in_file(self,
os.path.join(self.source_folder,"CMake/Packages/FindDirectX11.cmake"),
'find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS "',
'find_path(DirectX11_INCLUDE_DIR NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NAMES d3d11.h HINTS "',
)
shutil.copyfile(
"patches/FindFreeImage.cmake", "CMake/Packages/FindConanFreeImage.cmake"
)
for patch in self.conan_data["patches"][self.version]:
tools.patch(**patch)
def build(self):
cmake = self._configure_cmake()
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = self._configure_cmake()
cmake = CMake(self)
cmake.install()
def package_info(self):
@ -131,4 +130,4 @@ class OGREConan(ConanFile):
"include/OGRE/Threading",
"include/OGRE/Volume",
]
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.libs = collect_libs(self)

View File

@ -1,10 +0,0 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -76,6 +76,7 @@
# Include necessary submodules
set(CMAKE_MODULE_PATH
+ "${CMAKE_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/CMake"
"${PROJECT_SOURCE_DIR}/CMake/Utils"
"${PROJECT_SOURCE_DIR}/CMake/Packages"

View File

@ -1,10 +0,0 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -80,6 +80,7 @@
# Include necessary submodules
set(CMAKE_MODULE_PATH
+ "${CMAKE_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/CMake"
"${PROJECT_SOURCE_DIR}/CMake/Utils"
"${PROJECT_SOURCE_DIR}/CMake/Packages"