diff --git a/recipes/innoextract/all/CMakeLists.txt b/recipes/innoextract/all/CMakeLists.txt deleted file mode 100644 index 70869870556c6..0000000000000 --- a/recipes/innoextract/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATH) - -add_subdirectory("source_subfolder") diff --git a/recipes/innoextract/all/conandata.yml b/recipes/innoextract/all/conandata.yml index 93262a96d6979..a280c970476d1 100644 --- a/recipes/innoextract/all/conandata.yml +++ b/recipes/innoextract/all/conandata.yml @@ -7,6 +7,4 @@ sources: patches: "1.9.0": - patch_file: "patches/0001-cmake-fix-module.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-remove-custom-cmake-find-modules.patch" - base_path: "source_subfolder" diff --git a/recipes/innoextract/all/conanfile.py b/recipes/innoextract/all/conanfile.py index da4e26f393ea0..c21ccf578684a 100644 --- a/recipes/innoextract/all/conanfile.py +++ b/recipes/innoextract/all/conanfile.py @@ -1,71 +1,71 @@ +from conan import ConanFile +from conan.tools.files import get, rmdir, copy, apply_conandata_patches, export_conandata_patches +from conan.tools.cmake import cmake_layout, CMake, CMakeDeps, CMakeToolchain +from conan.tools.env import VirtualBuildEnv import os -import functools -from conans import ConanFile, CMake, tools -required_conan_version = ">=1.33.0" + +required_conan_version = ">=1.52.0" class InnoextractConan(ConanFile): name = "innoextract" description = "Extract contents of Inno Setup installers" - license = "innoextract License" + license = "LicenseRef-LICENSE" topics = ("inno-setup", "decompression") - homepage = "https://constexpr.org/innoextract/" + homepage = "https://constexpr.org/innoextract" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt", "patches/*"] - requires = ( - "boost/1.80.0", - "xz_utils/5.2.5", - "libiconv/1.17" - ) - generators = "cmake", "cmake_find_package" settings = "os", "arch", "compiler", "build_type" - @property - def _source_subfolder(self): - return "source_subfolder" + def export_sources(self): + export_conandata_patches(self) - @property - def _build_subfolder(self): - return "build_subfolder" + def layout(self): + cmake_layout(self, src_folder="src") - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, - destination=self._source_subfolder) + def requirements(self): + self.requires("boost/1.80.0") + self.requires("xz_utils/5.2.5") + self.requires("libiconv/1.17") - def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - os.remove(os.path.join(self._source_subfolder, 'cmake', 'FindLZMA.cmake')) - os.remove(os.path.join(self._source_subfolder, 'cmake', 'Findiconv.cmake')) - cmake = self._configure_cmake() - cmake.build() + def package_id(self): + del self.info.settings.compiler + self.info.requires.clear() - @functools.lru_cache(1) - def _configure_cmake(self): - cmake = CMake(self) + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, + destination=self.source_folder) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = CMakeToolchain(self) # Turn off static library detection, which is on by default on Windows. # This keeps the CMakeLists.txt from trying to detect static Boost # libraries and use Boost components for zlib and BZip2. Getting the # libraries via Conan does the correct thing without other assistance. - cmake.definitions["USE_STATIC_LIBS"] = False - cmake.configure(build_folder=self._build_subfolder) - return cmake + tc.variables["USE_STATIC_LIBS"] = False + tc.generate() + tc = CMakeDeps(self) + tc.generate() + + def build(self): + apply_conandata_patches(self) + os.remove(os.path.join(self.source_folder, 'cmake', 'FindLZMA.cmake')) + os.remove(os.path.join(self.source_folder, 'cmake', 'Findiconv.cmake')) + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - - def package_id(self): - del self.info.settings.compiler - self.info.requires.clear() + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): self.cpp_info.includedirs = [] self.cpp_info.libdirs = [] bindir = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}" - .format(bindir)) + self.output.info(f"Appending PATH environment variable: {bindir}") self.env_info.PATH.append(bindir) diff --git a/recipes/innoextract/all/patches/0001-cmake-fix-module.patch b/recipes/innoextract/all/patches/0001-cmake-fix-module.patch index 6c34cbad3eda2..2997e1cb0a3a5 100644 --- a/recipes/innoextract/all/patches/0001-cmake-fix-module.patch +++ b/recipes/innoextract/all/patches/0001-cmake-fix-module.patch @@ -3,11 +3,11 @@ index dbb64f1..a8a67e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,7 @@ endif() - + include(CheckSymbolExists) - + -set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # For custom cmake modules -+list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # For custom cmake modules ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") # For custom cmake modules include(BuildType) include(CompileCheck) include(CreateSourceGroups) diff --git a/recipes/innoextract/all/test_package/conanfile.py b/recipes/innoextract/all/test_package/conanfile.py index dc77b21f20519..6a4e652eac543 100644 --- a/recipes/innoextract/all/test_package/conanfile.py +++ b/recipes/innoextract/all/test_package/conanfile.py @@ -1,19 +1,14 @@ -from six import StringIO -from conans import ConanFile, tools - +from conan import ConanFile +from conan.tools.build import can_run class TestPackageConan(ConanFile): settings = "os", "arch", "build_type", "compiler" + generators = "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) def test(self): - if not tools.cross_building(self): - output = StringIO() - self.run("innoextract --version", output=output, - run_environment=True) - output_str = str(output.getvalue()) - self.output.info("Installed version: {}".format(output_str)) - require_version = str(self.deps_cpp_info["innoextract"].version) - require_version = ".".join(require_version.split(".")[:2]) - self.output.info("Expected version: {}".format(require_version)) - assert_innoextract_version = "innoextract %s" % require_version - assert(assert_innoextract_version in output_str) + if can_run(self): + self.run("innoextract --version", env="conanrun") diff --git a/recipes/innoextract/all/test_v1_package/conanfile.py b/recipes/innoextract/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..dc77b21f20519 --- /dev/null +++ b/recipes/innoextract/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from six import StringIO +from conans import ConanFile, tools + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "build_type", "compiler" + + def test(self): + if not tools.cross_building(self): + output = StringIO() + self.run("innoextract --version", output=output, + run_environment=True) + output_str = str(output.getvalue()) + self.output.info("Installed version: {}".format(output_str)) + require_version = str(self.deps_cpp_info["innoextract"].version) + require_version = ".".join(require_version.split(".")[:2]) + self.output.info("Expected version: {}".format(require_version)) + assert_innoextract_version = "innoextract %s" % require_version + assert(assert_innoextract_version in output_str)