diff --git a/recipes/magnum-extras/all/CMakeLists.txt b/recipes/magnum-extras/all/CMakeLists.txt index 046d5c62ad057..08c7bbc0b05a4 100644 --- a/recipes/magnum-extras/all/CMakeLists.txt +++ b/recipes/magnum-extras/all/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/Magnum) #set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/MagnumExternal) diff --git a/recipes/magnum-extras/all/conanfile.py b/recipes/magnum-extras/all/conanfile.py index 7c1e179dbdeb4..939aef0b5e69a 100644 --- a/recipes/magnum-extras/all/conanfile.py +++ b/recipes/magnum-extras/all/conanfile.py @@ -1,8 +1,9 @@ from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration +import functools import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.43.0" class MagnumExtrasConan(ConanFile): @@ -13,8 +14,7 @@ class MagnumExtrasConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://magnum.graphics" - settings = "os", "compiler", "build_type", "arch" - + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -31,20 +31,18 @@ class MagnumExtrasConan(ConanFile): "ui_gallery": True, "application": "sdl2", } - generators = "cmake", "cmake_find_package" - exports_sources = ["CMakeLists.txt", "patches/*"] - _cmake = None + short_paths = True + generators = "cmake", "cmake_find_package" @property def _source_subfolder(self): return "source_subfolder" - def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - 'set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})', - "") + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == "Windows": @@ -54,7 +52,7 @@ def config_options(self): self.options.application = "android" if self.settings.os == "Emscripten": self.options.application = "emscripten" - # FIXME: Requires 'magnum:basis_importer=True' + # FIXME: Requires 'magnum:basis_importer=True' self.options.player = False # FIXME: Fails to compile self.options.ui_gallery = False @@ -62,16 +60,13 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - + def requirements(self): self.requires("magnum/{}".format(self.version)) self.requires("corrade/{}".format(self.version)) if self.settings.os in ["iOS", "Emscripten", "Android"] and self.options.ui_gallery: self.requires("magnum-plugins/{}".format(self.version)) - def build_requirements(self): - self.build_requires("corrade/{}".format(self.version)) - def validate(self): opt_name = "{}_application".format(self.options.application) if not getattr(self.options["magnum"], opt_name): @@ -79,28 +74,37 @@ def validate(self): if self.settings.os == "Emscripten" and self.options["magnum"].target_gl == "gles2": raise ConanInvalidConfiguration("OpenGL ES 3 required, use option 'magnum:target_gl=gles3'") + def build_requirements(self): + self.build_requires("corrade/{}".format(self.version)) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @functools.lru_cache(1) def _configure_cmake(self): - if self._cmake: - return self._cmake - - self._cmake = CMake(self) - self._cmake.definitions["BUILD_STATIC"] = not self.options.shared - self._cmake.definitions["BUILD_STATIC_PIC"] = self.options.get_safe("fPIC", False) - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.definitions["BUILD_GL_TESTS"] = False - - self._cmake.definitions["WITH_PLAYER"] = self.options.player - self._cmake.definitions["WITH_UI"] = self.options.ui - self._cmake.definitions["WITH_UI_GALLERY"] = self.options.ui_gallery - - self._cmake.configure() - return self._cmake + cmake = CMake(self) + cmake.definitions["BUILD_STATIC"] = not self.options.shared + cmake.definitions["BUILD_STATIC_PIC"] = self.options.get_safe("fPIC", False) + cmake.definitions["BUILD_TESTS"] = False + cmake.definitions["BUILD_GL_TESTS"] = False + + cmake.definitions["WITH_PLAYER"] = self.options.player + cmake.definitions["WITH_UI"] = self.options.ui + cmake.definitions["WITH_UI_GALLERY"] = self.options.ui_gallery + + cmake.configure() + return cmake def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - cmakelists = [os.path.join("src", "Magnum", "Ui", "CMakeLists.txt"), + tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + 'set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})', + "") + + cmakelists = [os.path.join("src", "Magnum", "Ui", "CMakeLists.txt"), os.path.join("src", "player","CMakeLists.txt")] app_name = "{}Application".format("XEgl" if self.options.application == "xegl" else str(self.options.application).capitalize()) for cmakelist in cmakelists: @@ -122,11 +126,13 @@ def package(self): self.copy("COPYING", src=self._source_subfolder, dst="licenses") def package_info(self): + self.cpp_info.set_property("cmake_file_name", "MagnumExtras") self.cpp_info.names["cmake_find_package"] = "MagnumExtras" self.cpp_info.names["cmake_find_package_multi"] = "MagnumExtras" lib_suffix = "-d" if self.settings.build_type == "Debug" else "" if self.options.ui: + self.cpp_info.components["ui"].set_property("cmake_target_name", "MagnumExtras::Ui") self.cpp_info.components["ui"].names["cmake_find_package"] = "Ui" self.cpp_info.components["ui"].names["cmake_find_package_multi"] = "Ui" self.cpp_info.components["ui"].libs = ["MagnumUi{}".format(lib_suffix)] diff --git a/recipes/magnum-extras/all/test_package/CMakeLists.txt b/recipes/magnum-extras/all/test_package/CMakeLists.txt index fee07aa76c337..976323cbac9ea 100644 --- a/recipes/magnum-extras/all/test_package/CMakeLists.txt +++ b/recipes/magnum-extras/all/test_package/CMakeLists.txt @@ -4,7 +4,7 @@ project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) -find_package(MagnumExtras REQUIRED) +find_package(MagnumExtras REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} PRIVATE MagnumExtras::Ui) diff --git a/recipes/magnum-extras/all/test_package/conanfile.py b/recipes/magnum-extras/all/test_package/conanfile.py index e9216306691b4..b79eb4c726ded 100644 --- a/recipes/magnum-extras/all/test_package/conanfile.py +++ b/recipes/magnum-extras/all/test_package/conanfile.py @@ -1,11 +1,10 @@ from conans import ConanFile, CMake, tools -from conans.errors import ConanException import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): if self.options["magnum-extras"].ui: