Skip to content

Commit

Permalink
ogre: migrate to Conan v2, add latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Mar 23, 2024
1 parent f4b52e8 commit 45101f4
Show file tree
Hide file tree
Showing 9 changed files with 783 additions and 0 deletions.
47 changes: 47 additions & 0 deletions recipes/ogre/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
cmake_minimum_required(VERSION 3.15)
project(OGRE)

macro(custom_find_package name)
find_package(${name} ${ARGN}
# Allow only Conan packages
NO_DEFAULT_PATH
PATHS ${CMAKE_PREFIX_PATH}
)
string(TOUPPER ${name} name_upper)
set(${name_upper}_FOUND TRUE)
set(${name_upper}_VERSION_STRING ${${name}_VERSION_STRING})
set(${name_upper}_INCLUDE_DIRS ${${name}_INCLUDE_DIRS})
set(${name_upper}_INCLUDE_DIR ${${name}_INCLUDE_DIR})
set(${name_upper}_LIBRARIES ${${name}_LIBRARIES})
set(${name_upper}_DEFINITIONS ${${name}_DEFINITIONS})
unset(name_upper)
endmacro()

# Do not allow system Qt to be used by accident
set(CMAKE_DISABLE_FIND_PACKAGE_QT TRUE)
set(CMAKE_DISABLE_FIND_PACKAGE_Qt5 TRUE)
set(CMAKE_DISABLE_FIND_PACKAGE_Qt6 TRUE)

custom_find_package(FreeImage QUIET CONFIG)
custom_find_package(Freetype QUIET CONFIG)
custom_find_package(OpenEXR QUIET CONFIG)
custom_find_package(assimp QUIET CONFIG)
custom_find_package(pugixml REQUIRED CONFIG)

add_subdirectory(src)

if(TARGET Codec_FreeImage)
target_link_libraries(Codec_FreeImage PUBLIC freeimage::freeimage)
endif()
if(TARGET Codec_EXR)
target_link_libraries(Codec_EXR openexr::openexr)
endif()
if(TARGET OgreOverlay)
target_link_libraries(OgreOverlay PUBLIC Freetype::Freetype)
endif()
if(TARGET Plugin_DotScene)
target_link_libraries(Plugin_DotScene PUBLIC pugixml::pugixml)
endif()
if(TARGET OgreXMLConverter)
target_link_libraries(OgreXMLConverter pugixml::pugixml)
endif()
4 changes: 4 additions & 0 deletions recipes/ogre/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"14.1.2":
url: "https://github.com/OGRECave/ogre/archive/refs/tags/v14.1.2.tar.gz"
sha256: "7269d659fa74b61b5df48aa81aa9a517227cb7da9f316f04cb9093f963e6911c"
650 changes: 650 additions & 0 deletions recipes/ogre/all/conanfile.py

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions recipes/ogre/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(OGRE ${OGRE_VERSION} COMPONENTS OgreMain REQUIRED)

add_executable(ogre_main ogre_main.cpp)
target_link_libraries(ogre_main OGRE::OgreMain)
set_target_properties(ogre_main PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS ON
)
26 changes: 26 additions & 0 deletions recipes/ogre/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "ogre_main")
self.run(bin_path, env="conanrun")
15 changes: 15 additions & 0 deletions recipes/ogre/all/test_package/ogre_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <OGRE/Ogre.h>
#include <iostream>

int main() {
Ogre::RenderSystemCapabilities rc;
rc.setNumTextureUnits(10);
std::cout << "Hello from OgreMain component\n";
std::cout << "number of texture units: " << rc.getNumTextureUnits() << "\n";

Ogre::Radian rot{0.618};
Ogre::Particle particle;
particle.setDimensions(0, 0);

return 0;
}
8 changes: 8 additions & 0 deletions recipes/ogre/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
19 changes: 19 additions & 0 deletions recipes/ogre/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from conans import ConanFile, CMake, tools
import os

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.definitions["OGRE_VERSION"] = tools.Version(self.deps_cpp_info["ogre"].version)
cmake.configure()
cmake.build()

def test(self):
if tools.cross_building(self):
return

ogre_main_bin_path = os.path.join("bin", "ogre_main")
self.run(ogre_main_bin_path, run_environment=True)
2 changes: 2 additions & 0 deletions recipes/ogre/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"14.1.2":
folder: all
"1.10.2":
folder: 1.x

0 comments on commit 45101f4

Please sign in to comment.