diff --git a/.c3i/authorized_users.yml b/.c3i/authorized_users.yml index 8bbc2b9540df6..3c20b5b172cd0 100644 --- a/.c3i/authorized_users.yml +++ b/.c3i/authorized_users.yml @@ -928,3 +928,6 @@ authorized_users: - "BjoernAtBosch" - "dubvulture" - "ZbigniewRA" + - "JorgenPo" + - "AlexRamallo" + - "kissandras" diff --git a/docs/faqs.md b/docs/faqs.md index d69b2aaa245f7..dc593ab6cc44d 100644 --- a/docs/faqs.md +++ b/docs/faqs.md @@ -177,6 +177,17 @@ No. Some projects provide more than a simple library, but also applications. For When a non standard open-source license is used, we have decided to use `LicenseRef-` as a prefix, followed by the name of the file which contains a custom license. See [the reviewing guidlines](reviewing.md#license-attribute) for more details. +## How do I flag a problem to a recipe consumer? + +Regardless of why, if the recipe detects a problem where binaries might not be generated correctly, an exception must be raised. This to prevent the publishing +incorrect packages which do not work as intented. Use `ConanInvalidConfiguration` which is specially support in ConanCenter. + +```py +raise ConanInvalidConfiguration(f"The project {self.ref} requires liba.enable_feature=True.") +``` + +You should not be using the `self.output.warn` and it is not enough to alter consumers or stop the build service. + ## Why is a `build.check_min_cppstd` call not enough? Very often C++ projects require a minimum standard version, such as 14 or 17, in order to compile. Conan offers tools which enable checking the relevant setting is enabled and above this support for a certain version is present. Otherwise, it uses the compiler's default. diff --git a/docs/package/all/conandata.yml b/docs/package_templates/autotools_package/all/conandata.yml similarity index 100% rename from docs/package/all/conandata.yml rename to docs/package_templates/autotools_package/all/conandata.yml diff --git a/docs/package_templates/autotools_package/all/conanfile.py b/docs/package_templates/autotools_package/all/conanfile.py new file mode 100644 index 0000000000000..27a85160acde1 --- /dev/null +++ b/docs/package_templates/autotools_package/all/conanfile.py @@ -0,0 +1,132 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get, rm, rmdir, apply_conandata_patches +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps +from conan.tools.layout import basic_layout +import os + + +required_conan_version = ">=1.51.3" + + +class PackageConan(ConanFile): + name = "package" + description = "short description" + license = "" # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/project/package" + topics = ("topic1", "topic2", "topic3") # no "conan" and project name in topics + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_foobar": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_foobar": True, + } + + # no exports_sources attribute, but export_sources(self) method instead + # this allows finer grain exportation of patches per version + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC # once removed by config_options, need try..except for a second del + except Exception: + pass + try: + del self.settings.compiler.libcxx # for plain C projects only + except Exception: + pass + try: + del self.settings.compiler.cppstd # for plain C projects only + except Exception: + pass + + def layout(self): + basic_layout(self, src_folder="src") # src_folder must use the same source folder name the project + + def requirements(self): + self.requires("dependency/0.8.1") # prefer self.requires method instead of requires attribute + if self.options.with_foobar: + self.requires("foobar/0.1.0") + + def validate(self): + # validate the minimum cpp standard supported. Only for C++ projects + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + if self.info.settings.os not in ["Linux", "FreeBSD", "MacOS"]: + raise ConanInvalidConfiguration(f"{self.ref} is not supported on {self.info.settings.os}.") + + # if another tool than the compiler or autotools is required to build the project (pkgconf, bison, flex etc) + def build_requirements(self): + self.tool_requires("libtool/x.y.z") + self.tool_requires("pkgconf/x.y.z") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + # autotools usually uses 'yes' and 'no' to enable/disable options + yes_no = lambda v: "yes" if v else "no" + # --fpic is automatically managed when 'fPIC'option is declared + # --enable/disable-shared is automatically managed when 'shared' option is declared + tc = AutotoolsToolchain(self) + tc.configure_args.append("--with-foobar=%s" % yes_no(self.options.with_foobar)) + tc.configure_args.append("--enable-tools=no") + tc.configure_args.append("--enable-manpages=no") + tc.generate() + # generate dependencies for pkg-config + tc = PkgConfigDeps(self) + tc.generate() + # generate dependencies for autotools + tc = AutotoolsDeps(self) + tc.generate() + # inject tools_require env vars in build context + ms = VirtualBuildEnv(self) + ms.generate(scope="build") + + def build(self): + # apply patches listed in conandata.yml + apply_conandata_patches(self) + autotools = Autotools(self) + # run autoreconf to generate configure file + autotools.autoreconf() + # ./configure + toolchain file + autotools.configure() + autotools.make() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + autotools = Autotools(self) + autotools.install() + + # some files extensions and folders are not allowed. Please, read the FAQs to get informed. + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = ["package_lib"] + + # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) + self.cpp_info.set_property("pkg_config_name", "package") + + # If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + self.cpp_info.system_libs.append("pthread") + self.cpp_info.system_libs.append("dl") diff --git a/docs/package_templates/autotools_package/all/test_package/CMakeLists.txt b/docs/package_templates/autotools_package/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..dcb2919e20597 --- /dev/null +++ b/docs/package_templates/autotools_package/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) # if the project is pure C +# project(test_package CXX) # if the project uses c++ + +find_package(package REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +# don't link to ${CONAN_LIBS} or CONAN_PKG::package +target_link_libraries(${PROJECT_NAME} PRIVATE package::package) +# In case the target project need a specific C++ standard +# target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/docs/package/all/test_package/conanfile.py b/docs/package_templates/autotools_package/all/test_package/conanfile.py similarity index 96% rename from docs/package/all/test_package/conanfile.py rename to docs/package_templates/autotools_package/all/test_package/conanfile.py index fafc26f5d9351..1111583fea732 100644 --- a/docs/package/all/test_package/conanfile.py +++ b/docs/package_templates/autotools_package/all/test_package/conanfile.py @@ -8,6 +8,7 @@ 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) diff --git a/docs/package_templates/autotools_package/all/test_package/test_package.c b/docs/package_templates/autotools_package/all/test_package/test_package.c new file mode 100644 index 0000000000000..f949b7f4a20f4 --- /dev/null +++ b/docs/package_templates/autotools_package/all/test_package/test_package.c @@ -0,0 +1,16 @@ +#include +#include +#include "package/foobar.h" // Make sure includes work as expected + + +int main(void) { + printf("Create a minimal usage for the target project here.\n"); + printf("Avoid big examples, bigger than 100 lines\n"); + printf("Avoid networking connections.\n"); + printf("Avoid background apps or servers.\n"); + printf("The propose is testing the generated artifacts only.\n"); + + foobar_print_version(); // Make sure to call something that will require linkage for compiled libraries + + return EXIT_SUCCESS; +} diff --git a/docs/package_templates/autotools_package/all/test_v1_package/CMakeLists.txt b/docs/package_templates/autotools_package/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6298d7b9a123c --- /dev/null +++ b/docs/package_templates/autotools_package/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) # if the project is pure C +# project(test_package CXX) # if the project uses c++ + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(package REQUIRED CONFIG) + +# Re-use the same source file from test_package folder +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +# don't link to ${CONAN_LIBS} or CONAN_PKG::package +target_link_libraries(${PROJECT_NAME} PRIVATE package::package) +# in case the target project requires a C++ standard +# set_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/docs/package/all/test_v1_package/conanfile.py b/docs/package_templates/autotools_package/all/test_v1_package/conanfile.py similarity index 100% rename from docs/package/all/test_v1_package/conanfile.py rename to docs/package_templates/autotools_package/all/test_v1_package/conanfile.py diff --git a/docs/package/config.yml b/docs/package_templates/autotools_package/config.yml similarity index 100% rename from docs/package/config.yml rename to docs/package_templates/autotools_package/config.yml diff --git a/docs/package_templates/cmake_package/all/conandata.yml b/docs/package_templates/cmake_package/all/conandata.yml new file mode 100644 index 0000000000000..61b769f81b6fa --- /dev/null +++ b/docs/package_templates/cmake_package/all/conandata.yml @@ -0,0 +1,29 @@ +sources: + # Newer versions at the top + "1.2.0": + url: [ + "https://mirror1.net/package-1.2.0.tar.gz", + "https://mirror2.net/package-1.2.0.tar.gz", + ] + sha256: "________________________________________________________________" + "1.1.0": + url: [ + "https://mirror1.net/package-1.1.0.tar.gz", + "https://mirror2.net/package-1.1.0.tar.gz", + ] + sha256: "________________________________________________________________" +patches: + # Newer versions at the top + "1.1.0": + - patch_file: "patches/0001-fix-cmake.patch" + patch_description: "correct the order of cmake min and project" + patch_type: "backport" + patch_source: "https://github.com/owner/package/pulls/42" + sha256: "________________________________________________________________" + base_path: "source_subfolder" + - patch_file: "patches/0002-fix-linux.patch" + patch_description: "add missing header to support linux" + patch_type: "portability" + patch_source: "https://github.com/owner/package/issues/0" + sha256: "________________________________________________________________" + base_path: "source_subfolder" diff --git a/docs/package/all/conanfile.py b/docs/package_templates/cmake_package/all/conanfile.py similarity index 83% rename from docs/package/all/conanfile.py rename to docs/package_templates/cmake_package/all/conanfile.py index 258e28f296c59..ffec34ee46a8d 100644 --- a/docs/package/all/conanfile.py +++ b/docs/package_templates/cmake_package/all/conanfile.py @@ -1,6 +1,6 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.microsoft import msvc_runtime_flag, is_msvc +from conan.tools.microsoft import is_msvc_static_runtime, is_msvc from conan.tools.files import apply_conandata_patches, get, copy, rm, rmdir, replace_in_file from conan.tools.build import check_min_cppstd from conan.tools.scm import Version @@ -18,8 +18,8 @@ class PackageConan(ConanFile): license = "" # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/project/package" - topics = ("topic1", "topic2", "topic3") # no "conan" and project name in topics - settings = "os", "arch", "compiler", "build_type" # even for header only + topics = ("topic1", "topic2", "topic3") # no "conan" and project name in topics + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -29,16 +29,6 @@ class PackageConan(ConanFile): "fPIC": True, } - # don't use self.settings_build - @property - def _settings_build(self): - return getattr(self, "settings_build", self.settings) - - # don't use self.user_info_build - @property - def _user_info_build(self): - return getattr(self, "user_info_build", self.deps_user_info) - @property def _minimum_cpp_standard(self): return 17 @@ -78,34 +68,30 @@ def configure(self): except Exception: pass + def layout(self): + cmake_layout(self, src_folder="src") # src_folder must use the same source folder name the project + def requirements(self): self.requires("dependency/0.8.1") # prefer self.requires method instead of requires attribute - # Only in case the project is header-only - def package_id(self): - self.info.clear() - - # if another tool than the compiler or CMake is required to build the project (pkgconf, bison, flex etc) - def build_requirements(self): - self.tool_requires("tool/x.y.z") - - def source(self): - get(**self.conan_data["sources"][self.version], - destination=self.source_subfolder, strip_root=True) - def validate(self): - # validate the minimum cpp standard supported + # validate the minimum cpp standard supported. For C++ projects only if self.info.settings.compiler.cppstd: check_min_cppstd(self, self._minimum_cpp_standard) minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration(f"{self.name} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") + raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") # in case it does not work in another configuration, it should validated here too if is_msvc(self) and self.info.options.shared: - raise ConanInvalidConfiguration(f"{self.name} can not be built as shared on Visual Studio and msvc.") + raise ConanInvalidConfiguration(f"{self.ref} can not be built as shared on Visual Studio and msvc.") - def layout(self): - cmake_layout(self, src_folder="src") # src_folder must use the same source folder name the project + # if another tool than the compiler or CMake is required to build the project (pkgconf, bison, flex etc) + def build_requirements(self): + self.tool_requires("tool/x.y.z") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) def generate(self): # BUILD_SHARED_LIBS and POSITION_INDEPENDENT_CODE are automatically parsed when self.options.shared or self.options.fPIC exist @@ -114,7 +100,10 @@ def generate(self): tc.cache_variables["PACKAGE_CUSTOM_DEFINITION"] = True if is_msvc(self): # don't use self.settings.compiler.runtime - tc.cache_variables.definitions["USE_MSVC_RUNTIME_LIBRARY_DLL"] = "MD" in msvc_runtime_flag(self) + tc.cache_variables.definitions["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) + # deps_cpp_info, deps_env_info and deps_user_info are no longer used + if self.dependencies["dependency"].options.foobar: + tc.cache_variables["DEPENDENCY_LIBPATH"] = self.dependencies["dependency"].cpp_info.libdirs tc.generate() # In case there are dependencies listed on requirements, CMakeDeps should be used tc = CMakeDeps(self) @@ -126,10 +115,10 @@ def generate(self): def _patch_sources(self): apply_conandata_patches(self) # remove bundled xxhash - rm(self, "whateer.*", os.path.join(self._source_subfolder, "lib")) + rm(self, "whateer.*", os.path.join(self.source_folder, "lib")) replace_in_file( self, - os.path.join(self._cmakelists_subfolder, "CMakeLists.txt"), + os.path.join(self.source_folder, "CMakeLists.txt"), "...", "", ) @@ -140,7 +129,7 @@ def build(self): cmake.build() def package(self): - copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_subfolder) + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) cmake = CMake(self) cmake.install() diff --git a/docs/package/all/test_package/CMakeLists.txt b/docs/package_templates/cmake_package/all/test_package/CMakeLists.txt similarity index 100% rename from docs/package/all/test_package/CMakeLists.txt rename to docs/package_templates/cmake_package/all/test_package/CMakeLists.txt diff --git a/docs/package_templates/cmake_package/all/test_package/conanfile.py b/docs/package_templates/cmake_package/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1111583fea732 --- /dev/null +++ b/docs/package_templates/cmake_package/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +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.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/docs/package/all/test_package/test_package.cpp b/docs/package_templates/cmake_package/all/test_package/test_package.cpp similarity index 100% rename from docs/package/all/test_package/test_package.cpp rename to docs/package_templates/cmake_package/all/test_package/test_package.cpp diff --git a/docs/package/all/test_v1_package/CMakeLists.txt b/docs/package_templates/cmake_package/all/test_v1_package/CMakeLists.txt similarity index 100% rename from docs/package/all/test_v1_package/CMakeLists.txt rename to docs/package_templates/cmake_package/all/test_v1_package/CMakeLists.txt diff --git a/docs/package_templates/cmake_package/all/test_v1_package/conanfile.py b/docs/package_templates/cmake_package/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/docs/package_templates/cmake_package/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/cmake_package/config.yml b/docs/package_templates/cmake_package/config.yml new file mode 100644 index 0000000000000..a885cbf942a74 --- /dev/null +++ b/docs/package_templates/cmake_package/config.yml @@ -0,0 +1,6 @@ +versions: + # Newer versions at the top + "1.2.0": + folder: all + "1.1.0": + folder: all diff --git a/docs/package_templates/header_only/all/conandata.yml b/docs/package_templates/header_only/all/conandata.yml new file mode 100644 index 0000000000000..61b769f81b6fa --- /dev/null +++ b/docs/package_templates/header_only/all/conandata.yml @@ -0,0 +1,29 @@ +sources: + # Newer versions at the top + "1.2.0": + url: [ + "https://mirror1.net/package-1.2.0.tar.gz", + "https://mirror2.net/package-1.2.0.tar.gz", + ] + sha256: "________________________________________________________________" + "1.1.0": + url: [ + "https://mirror1.net/package-1.1.0.tar.gz", + "https://mirror2.net/package-1.1.0.tar.gz", + ] + sha256: "________________________________________________________________" +patches: + # Newer versions at the top + "1.1.0": + - patch_file: "patches/0001-fix-cmake.patch" + patch_description: "correct the order of cmake min and project" + patch_type: "backport" + patch_source: "https://github.com/owner/package/pulls/42" + sha256: "________________________________________________________________" + base_path: "source_subfolder" + - patch_file: "patches/0002-fix-linux.patch" + patch_description: "add missing header to support linux" + patch_type: "portability" + patch_source: "https://github.com/owner/package/issues/0" + sha256: "________________________________________________________________" + base_path: "source_subfolder" diff --git a/docs/package_templates/header_only/all/conanfile.py b/docs/package_templates/header_only/all/conanfile.py new file mode 100644 index 0000000000000..4d9370bad1f91 --- /dev/null +++ b/docs/package_templates/header_only/all/conanfile.py @@ -0,0 +1,114 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, get, copy +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.tools.layout import basic_layout +import os + + +required_conan_version = ">=1.51.3" + + +class PackageConan(ConanFile): + name = "package" + description = "short description" + license = "" # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/project/package" + topics = ("topic1", "topic2", "topic3", "header-only") # no "conan" and project name in topics, keep 'header-only' + settings = "os", "arch", "compiler", "build_type" # even for header only + no_copy_source = True # do not copy sources to build folder for header only projects, unless, need to apply patches + + @property + def _minimum_cpp_standard(self): + return 14 + + # in case the project requires C++14/17/20/... the minimum compiler version should be listed + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "15", + "msvc": "14.1", + "gcc": "5", + "clang": "5", + "apple-clang": "5.1", + } + + # no exports_sources attribute, but export_sources(self) method instead + # this allows finer grain exportation of patches per version + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def layout(self): + # src_folder must use the same source folder name the project + basic_layout(self, src_folder="src") + + def requirements(self): + # prefer self.requires method instead of requires attribute + self.requires("dependency/0.8.1") + + # same package ID for any package + def package_id(self): + self.info.clear() + + def validate(self): + # compiler subsettings are not available when building with self.info.clear() + if self.info.settings.get_safe("compiler.cppstd"): + # validate the minimum cpp standard supported when installing the package. For C++ projects only + check_min_cppstd(self, self._minimum_cpp_standard) + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.get_safe("compiler.version")) < minimum_version: + raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support.") + # in case it does not work in another configuration, it should validated here too + if self.info.settings.os == "Windows": + raise ConanInvalidConfiguration(f"{self.ref} can not be used on Windows.") + + # if another tool than the compiler or CMake is required to build the project (pkgconf, bison, flex etc) + def build_requirements(self): + self.tool_requires("tool/x.y.z") + + def source(self): + # download source package and extract to source folder + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + # not mandatory when there is no patch, but will suppress warning message about missing build() method + def build(self): + # The attribute no_copy_source should not be used when applying patches in build + apply_conandata_patches(self) + + # copy all files to the package folder + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) + + def package_info(self): + # folders not used for header-only + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # if package has an official FindPACKAGE.cmake listed in https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html#find-modules + # examples: bzip2, freetype, gdal, icu, libcurl, libjpeg, libpng, libtiff, openssl, sqlite3, zlib... + self.cpp_info.set_property("cmake_module_file_name", "PACKAGE") + self.cpp_info.set_property("cmake_module_target_name", "PACKAGE::PACKAGE") + # if package provides a CMake config file (package-config.cmake or packageConfig.cmake, with package::package target, usually installed in /lib/cmake//) + self.cpp_info.set_property("cmake_file_name", "package") + self.cpp_info.set_property("cmake_target_name", "package::package") + # if package provides a pkgconfig file (package.pc, usually installed in /lib/pkgconfig/) + self.cpp_info.set_property("pkg_config_name", "package") + + # If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") + self.cpp_info.system_libs.append("pthread") + self.cpp_info.system_libs.append("dl") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "PACKAGE" + self.cpp_info.filenames["cmake_find_package_multi"] = "package" + self.cpp_info.names["cmake_find_package"] = "PACKAGE" + self.cpp_info.names["cmake_find_package_multi"] = "package" diff --git a/docs/package_templates/header_only/all/test_package/CMakeLists.txt b/docs/package_templates/header_only/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..d36b7fedf54ae --- /dev/null +++ b/docs/package_templates/header_only/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) # if the project is pure C +project(test_package CXX) # if the project uses c++ + +find_package(package REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +# don't link to ${CONAN_LIBS} or CONAN_PKG::package +target_link_libraries(${PROJECT_NAME} PRIVATE package::package) +# In case the target project need a specific C++ standard +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/docs/package_templates/header_only/all/test_package/conanfile.py b/docs/package_templates/header_only/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1111583fea732 --- /dev/null +++ b/docs/package_templates/header_only/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +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.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/docs/package_templates/header_only/all/test_package/test_package.cpp b/docs/package_templates/header_only/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..8e653f30a5476 --- /dev/null +++ b/docs/package_templates/header_only/all/test_package/test_package.cpp @@ -0,0 +1,16 @@ +#include +#include +#include "package/foobar.hpp" + + +int main(void) { + std::cout << "Create a minimal usage for the target project here." << std::endl; + std::cout << "Avoid big examples, bigger than 100 lines" << std::endl; + std::cout << "Avoid networking connections." << std::endl; + std::cout << "Avoid background apps or servers." << std::endl; + std::cout << "The propose is testing the generated artifacts only." << std::endl; + + foobar.print_version(); + + return EXIT_SUCCESS; +} diff --git a/docs/package_templates/header_only/all/test_v1_package/CMakeLists.txt b/docs/package_templates/header_only/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..40b3d97d7ddb2 --- /dev/null +++ b/docs/package_templates/header_only/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) # if the project is pure C +project(test_package CXX) # if the project uses c++ + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(package REQUIRED CONFIG) + +# Re-use the same source file from test_package folder +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +# don't link to ${CONAN_LIBS} or CONAN_PKG::package +target_link_libraries(${PROJECT_NAME} PRIVATE package::package) +# in case the target project requires a C++ standard +set_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/docs/package_templates/header_only/all/test_v1_package/conanfile.py b/docs/package_templates/header_only/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/docs/package_templates/header_only/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/header_only/config.yml b/docs/package_templates/header_only/config.yml new file mode 100644 index 0000000000000..a885cbf942a74 --- /dev/null +++ b/docs/package_templates/header_only/config.yml @@ -0,0 +1,6 @@ +versions: + # Newer versions at the top + "1.2.0": + folder: all + "1.1.0": + folder: all diff --git a/docs/package_templates/msbuild_package/all/conandata.yml b/docs/package_templates/msbuild_package/all/conandata.yml new file mode 100644 index 0000000000000..61b769f81b6fa --- /dev/null +++ b/docs/package_templates/msbuild_package/all/conandata.yml @@ -0,0 +1,29 @@ +sources: + # Newer versions at the top + "1.2.0": + url: [ + "https://mirror1.net/package-1.2.0.tar.gz", + "https://mirror2.net/package-1.2.0.tar.gz", + ] + sha256: "________________________________________________________________" + "1.1.0": + url: [ + "https://mirror1.net/package-1.1.0.tar.gz", + "https://mirror2.net/package-1.1.0.tar.gz", + ] + sha256: "________________________________________________________________" +patches: + # Newer versions at the top + "1.1.0": + - patch_file: "patches/0001-fix-cmake.patch" + patch_description: "correct the order of cmake min and project" + patch_type: "backport" + patch_source: "https://github.com/owner/package/pulls/42" + sha256: "________________________________________________________________" + base_path: "source_subfolder" + - patch_file: "patches/0002-fix-linux.patch" + patch_description: "add missing header to support linux" + patch_type: "portability" + patch_source: "https://github.com/owner/package/issues/0" + sha256: "________________________________________________________________" + base_path: "source_subfolder" diff --git a/docs/package_templates/msbuild_package/all/conanfile.py b/docs/package_templates/msbuild_package/all/conanfile.py new file mode 100644 index 0000000000000..42c754733c1a9 --- /dev/null +++ b/docs/package_templates/msbuild_package/all/conanfile.py @@ -0,0 +1,109 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc, MSBuildDeps, MSBuildToolchain, MSBuild, VCVars +from conan.tools.layout import vs_layout +from conan.tools.files import apply_conandata_patches, get, copy, rm, replace_in_file +import os + + +required_conan_version = ">=1.51.3" + + +class PackageConan(ConanFile): + name = "package" + description = "short description" + license = "" # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/project/package" + topics = ("topic1", "topic2", "topic3") # no "conan" and project name in topics + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + # no exports_sources attribute, but export_sources(self) method instead + # this allows finer grain exportation of patches per version + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC # once removed by config_options, need try..except for a second del + except Exception: + pass + try: + del self.settings.compiler.libcxx # for plain C projects only + except Exception: + pass + try: + del self.settings.compiler.cppstd # for plain C projects only + except Exception: + pass + + def layout(self): + vs_layout(self, src_folder="src") # src_folder must use the same source folder name the project + + def requirements(self): + self.requires("dependency/0.8.1") # prefer self.requires method instead of requires attribute + + def validate(self): + # in case it does not work in another configuration, it should validated here too + if not is_msvc(self): + raise ConanInvalidConfiguration(f"{self.ref} can be built only by Visual Studio and msvc.") + + # if another tool than the compiler or CMake is required to build the project (pkgconf, bison, flex etc) + def build_requirements(self): + self.tool_requires("tool/x.y.z") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = MSBuildToolchain(self) + tc.generate() + tc = MSBuildDeps(self) + tc.generate() + tc = VCVars(self) + tc.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + # remove bundled xxhash + rm(self, "whateer.*", os.path.join(self.source_folder, "lib")) + replace_in_file( + self, + os.path.join(self.source_folder, "CMakeLists.txt"), + "...", + "", + ) + + def build(self): + self._patch_sources() # It can be apply_conandata_patches(self) only in case no more patches are needed + msbuild = MSBuild(self) + # customize to Release when RelWithDebInfo + msbuild.build_type = "Debug" if self.settings.build_type == "Debug" else "Release" + # use Win32 instead of the default value when building x86 + msbuild.platform = "Win32" if self.settings.arch == "x86" else msbuild.platform + # customize according the solution file and compiler version + msbuild.build(sln="project_2017.sln") + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="*.lib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False) + copy(self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=self.build_folder, keep_path=False) + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include")) + + def package_info(self): + self.cpp_info.libs = ["package_lib"] diff --git a/docs/package_templates/msbuild_package/all/test_package/CMakeLists.txt b/docs/package_templates/msbuild_package/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b8db27ff53d5e --- /dev/null +++ b/docs/package_templates/msbuild_package/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) # if the project is pure C +project(test_package CXX) # if the project uses c++ + +find_package(package REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +# don't link to ${CONAN_LIBS} or CONAN_PKG::package +target_link_libraries(${PROJECT_NAME} PRIVATE package::package) diff --git a/docs/package_templates/msbuild_package/all/test_package/conanfile.py b/docs/package_templates/msbuild_package/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1111583fea732 --- /dev/null +++ b/docs/package_templates/msbuild_package/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +# It will become the standard on Conan 2.x +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.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/docs/package_templates/msbuild_package/all/test_package/test_package.cpp b/docs/package_templates/msbuild_package/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..8e653f30a5476 --- /dev/null +++ b/docs/package_templates/msbuild_package/all/test_package/test_package.cpp @@ -0,0 +1,16 @@ +#include +#include +#include "package/foobar.hpp" + + +int main(void) { + std::cout << "Create a minimal usage for the target project here." << std::endl; + std::cout << "Avoid big examples, bigger than 100 lines" << std::endl; + std::cout << "Avoid networking connections." << std::endl; + std::cout << "Avoid background apps or servers." << std::endl; + std::cout << "The propose is testing the generated artifacts only." << std::endl; + + foobar.print_version(); + + return EXIT_SUCCESS; +} diff --git a/docs/package_templates/msbuild_package/all/test_v1_package/CMakeLists.txt b/docs/package_templates/msbuild_package/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6b0a261eddbcc --- /dev/null +++ b/docs/package_templates/msbuild_package/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package C) # if the project is pure C +project(test_package CXX) # if the project uses c++ + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(package REQUIRED CONFIG) + +# Re-use the same source file from test_package folder +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +# don't link to ${CONAN_LIBS} or CONAN_PKG::package +target_link_libraries(${PROJECT_NAME} PRIVATE package::package) +# in case the target project requires a C++ standard +set_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/docs/package_templates/msbuild_package/all/test_v1_package/conanfile.py b/docs/package_templates/msbuild_package/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/docs/package_templates/msbuild_package/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/docs/package_templates/msbuild_package/config.yml b/docs/package_templates/msbuild_package/config.yml new file mode 100644 index 0000000000000..a885cbf942a74 --- /dev/null +++ b/docs/package_templates/msbuild_package/config.yml @@ -0,0 +1,6 @@ +versions: + # Newer versions at the top + "1.2.0": + folder: all + "1.1.0": + folder: all diff --git a/docs/package_templates/prebuilt_tool_package/all/conandata.yml b/docs/package_templates/prebuilt_tool_package/all/conandata.yml new file mode 100644 index 0000000000000..efcc89654623a --- /dev/null +++ b/docs/package_templates/prebuilt_tool_package/all/conandata.yml @@ -0,0 +1,28 @@ +sources: + # Newer versions at the top + "1.2.0": + "Windows": + "x86_64": + url: "https://example.com/download/windows/amd64/package-1.2.0.tar.gz" + sha256: "________________________________________________________________" + "Linux": + "x86_64": + url: "https://example.com/download/linux/amd64/package-1.2.0.tar.gz" + sha256: "________________________________________________________________" + "Macos": + "x86_64": + url: "https://example.com/download/osx/amd64/package-1.2.0.tar.gz" + sha256: "________________________________________________________________" + "1.1.0": + "Windows": + "x86_64": + url: "https://example.com/download/windows/amd64/package-1.1.0.tar.gz" + sha256: "________________________________________________________________" + "Linux": + "x86_64": + url: "https://example.com/download/linux/amd64/package-1.1.0.tar.gz" + sha256: "________________________________________________________________" + "Macos": + "x86_64": + url: "https://example.com/download/osx/amd64/package-1.1.0.tar.gz" + sha256: "________________________________________________________________" diff --git a/docs/package_templates/prebuilt_tool_package/all/conanfile.py b/docs/package_templates/prebuilt_tool_package/all/conanfile.py new file mode 100644 index 0000000000000..b4b3859fcb0c8 --- /dev/null +++ b/docs/package_templates/prebuilt_tool_package/all/conanfile.py @@ -0,0 +1,63 @@ +from conan import ConanFile +from conan.tools.files import get, copy +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +import os + + +required_conan_version = ">=1.47.0" + + +class PackageConan(ConanFile): + name = "package" + description = "short description" + license = "" # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/project/package" + topics = ("topic1", "topic2", "topic3", "pre-built") # no "conan" and project name in topics. Use "pre-built" for tooling packages + settings = "os", "arch", "compiler", "build_type" # even for pre-built executables + + # not needed but supress warning message from conan commands + def layout(self): + pass + + # specific compiler and build type, usually are not distributed by vendors + def package_id(self): + del self.info.settings.compiler + del self.info.settings.build_type + + # in case some configuration is not supported + def validate(self): + if self.info.settings.os == "Macos" and Version(self.info.settings.os.version) < 11: + raise ConanInvalidConfiguration(f"{self.ref} requires OSX >=11.") + + # do not cache as source, instead, use build folder + def source(self): + pass + + # download the source here, than copy to package folder + def build(self): + get(self, **self.conan_data["sources"][self.version][str(self.settings.os)][str(self.settings.arch)], + destination=self.source_folder, strip_root=True) + + # copy all needed files to the package folder + def package(self): + # a license file is always mandatory + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="*.exe", dst=os.path.join(self.package_folder, "bin"), src=self.source_folder) + copy(self, pattern="foo", dst=os.path.join(self.package_folder, "bin"), src=self.source_folder) + + def package_info(self): + # folders not used for pre-built binaries + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + self.cpp_info.includedirs = [] + + bin_folder = os.path.join(self.package_folder, "bin") + # In case need to find packaged tools when building a package + self.buildenv_info.append("PATH", bin_folder) + # In case need to find packaged tools at runtime + self.runenv_info.append("PATH", bin_folder) + # TODO: Legacy, to be removed on Conan 2.0 + self.env_info.PATH.append(bin_folder) diff --git a/docs/package_templates/prebuilt_tool_package/all/test_package/conanfile.py b/docs/package_templates/prebuilt_tool_package/all/test_package/conanfile.py new file mode 100644 index 0000000000000..b84c922d41cb0 --- /dev/null +++ b/docs/package_templates/prebuilt_tool_package/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run + + +# It will become the standard on Conan 2.x +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualRunEnv" + test_type = "explicit" + + def build_requirements(self): + self.tools_requires(self.tested_reference_str) + + def test(self): + if can_run(self): + # self.run checks the command exit code + # the tool must be available on PATH + self.run("tool --version", env="conanrun") diff --git a/docs/package_templates/prebuilt_tool_package/all/test_v1_package/conanfile.py b/docs/package_templates/prebuilt_tool_package/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..36fd085b2d6b7 --- /dev/null +++ b/docs/package_templates/prebuilt_tool_package/all/test_v1_package/conanfile.py @@ -0,0 +1,13 @@ +from conans import ConanFile +from conan.tools.build import can_run + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def test(self): + if can_run(self): + # self.run checks the command exit code + # the tool must be available on PATH, which is configured by self.env_info.PATH + self.run("tool --version", run_environment=True) diff --git a/docs/package_templates/prebuilt_tool_package/config.yml b/docs/package_templates/prebuilt_tool_package/config.yml new file mode 100644 index 0000000000000..a885cbf942a74 --- /dev/null +++ b/docs/package_templates/prebuilt_tool_package/config.yml @@ -0,0 +1,6 @@ +versions: + # Newer versions at the top + "1.2.0": + folder: all + "1.1.0": + folder: all diff --git a/docs/v2_linter.md b/docs/v2_linter.md index 5d988acb47532..54aa81f9edcc4 100644 --- a/docs/v2_linter.md +++ b/docs/v2_linter.md @@ -1,13 +1,7 @@ # Linter to help migration to Conan v2 -## Contents - -- [Linter to help migration to Conan v2](#linter-to-help-migration-to-conan-v2) - - [Contents](#contents) - - [Import ConanFile from `conan`](#import-conanfile-from-conan) - - [Import tools from `conan`](#import-tools-from-conan) - - [Disable linter for a specific conanfile](#disable-linter-for-a-specific-conanfile) + On our [path to Conan v2](v2_roadmap.md) we are leveraging on custom Pylint rules. This linter will run for every pull-request that is submitted to the repository and will @@ -78,3 +72,33 @@ all the checks of the linter, it can be skipped from `pylint` adding the followi from conans import ConanFile, CMake, tools ... ``` + +--- + +## Running the linter locally + +It is possible to run the linter locally the same way it is being run [using Github actions](../.github/workflows/linter-conan-v2.yml): + + * (Recommended) Use a dedicated Python virtualenv. + * Ensure you have required tools installed: `conan` and `pylint` (better to uses fixed versions) + + ``` + pip install conan~=1.0 pylint==2.14 + ``` + + * Set environment variable `PYTHONPATH` to the root of the repository + + ``` + export PYTHONPATH=your/path/conan-center-index + ``` + + * Now you just need to execute the `pylint` commands: + + ``` + # Lint a recipe: + pylint --rcfile=linter/pylintrc_recipe recipes/boost/all/conanfile.py + + # Lint the test_package + pylint --rcfile=linter/pylintrc_testpackage recipes/boost/all/test_package/conanfile.py + ``` + diff --git a/recipes/access_private/all/conanfile.py b/recipes/access_private/all/conanfile.py index 5cd761d0dd98e..da35dc6ea7e6e 100644 --- a/recipes/access_private/all/conanfile.py +++ b/recipes/access_private/all/conanfile.py @@ -1,40 +1,48 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools +required_conan_version = ">=1.50.0" class AccessPrivateConan(ConanFile): name = "access_private" description = "Access private members and statics of a C++ class" - license = ["MIT"] - topics = ("conan", "access", "private", "header-only") + license = "MIT" + topics = ("access", "private", "header-only") homepage = "https://github.com/martong/access_private" url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - settings = "compiler" - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - url = self.conan_data["sources"][self.version]["url"] - extracted_dir = "access_private-" + \ - os.path.splitext(os.path.basename(url))[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): - self.copy("LICENSE", - dst="licenses", - src=self._source_subfolder) - self.copy("access_private.hpp", - dst=os.path.join("include", "access_private"), - src=os.path.join(self._source_subfolder, "include")) + def build(self): + pass - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "access_private.hpp", + src=os.path.join(self.source_folder, "include"), + dst=os.path.join(self.package_folder, "include", "access_private")) + + def package_info(self): + self.cpp_info.includedirs.append(os.path.join("include", "access_private")) + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/access_private/all/test_package/CMakeLists.txt b/recipes/access_private/all/test_package/CMakeLists.txt index 110ec81bc776d..6d981e9b4484e 100644 --- a/recipes/access_private/all/test_package/CMakeLists.txt +++ b/recipes/access_private/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) -set(CMAKE_CXX_STANDARD 11) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(access_private REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE access_private::access_private) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/access_private/all/test_package/conanfile.py b/recipes/access_private/all/test_package/conanfile.py index 4aebe114eeb59..d120a992c06a6 100644 --- a/recipes/access_private/all/test_package/conanfile.py +++ b/recipes/access_private/all/test_package/conanfile.py @@ -1,11 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools - class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -13,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/access_private/all/test_package/test_package.cpp b/recipes/access_private/all/test_package/test_package.cpp index aaa91ad3e7776..7c4f5cf312459 100644 --- a/recipes/access_private/all/test_package/test_package.cpp +++ b/recipes/access_private/all/test_package/test_package.cpp @@ -1,4 +1,4 @@ -#include +#include class A { int m_i = 3; diff --git a/recipes/access_private/all/test_v1_package/CMakeLists.txt b/recipes/access_private/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..01b3a8050e773 --- /dev/null +++ b/recipes/access_private/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(access_private REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE access_private::access_private) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/access_private/all/test_v1_package/conanfile.py b/recipes/access_private/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/access_private/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/arduinojson/all/conanfile.py b/recipes/arduinojson/all/conanfile.py index bb133b454bb45..65c63794d59f1 100644 --- a/recipes/arduinojson/all/conanfile.py +++ b/recipes/arduinojson/all/conanfile.py @@ -1,8 +1,10 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import copy, get, save +from conan.tools.layout import basic_layout import os import textwrap -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" class ArduinojsonConan(ConanFile): @@ -15,54 +17,55 @@ class ArduinojsonConan(ConanFile): settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + def build(self): + pass - @property - def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + def package(self): + copy(self, "*LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=os.path.join(self.source_folder, "src"), dst=os.path.join(self.package_folder, "include")) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "src"), dst=os.path.join(self.package_folder, "include")) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"ArduinoJson": "ArduinoJson::ArduinoJson"} + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) + """) + save(self, module_file, content) - def package(self): - self.copy("*LICENSE*", dst="licenses", src=self._source_subfolder) - self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "src")) - self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "src")) - # TODO: to remove in conan v2 once cmake_find_package* generators removed - self._create_cmake_module_alias_targets( - os.path.join(self.package_folder, self._module_file_rel_path), - {"ArduinoJson": "ArduinoJson::ArduinoJson"} - ) + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): self.cpp_info.set_property("cmake_file_name", "ArduinoJson") self.cpp_info.set_property("cmake_target_name", "ArduinoJson") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "ArduinoJson" self.cpp_info.names["cmake_find_package_multi"] = "ArduinoJson" - self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/arduinojson/all/test_package/CMakeLists.txt b/recipes/arduinojson/all/test_package/CMakeLists.txt index 70e13ce3659e9..d206236f0971b 100644 --- a/recipes/arduinojson/all/test_package/CMakeLists.txt +++ b/recipes/arduinojson/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(ArduinoJson REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ArduinoJson) +target_link_libraries(${PROJECT_NAME} PRIVATE ArduinoJson) diff --git a/recipes/arduinojson/all/test_package/conanfile.py b/recipes/arduinojson/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/arduinojson/all/test_package/conanfile.py +++ b/recipes/arduinojson/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/arduinojson/all/test_v1_package/CMakeLists.txt b/recipes/arduinojson/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7e433826ed298 --- /dev/null +++ b/recipes/arduinojson/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ArduinoJson REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ArduinoJson) diff --git a/recipes/arduinojson/all/test_v1_package/conanfile.py b/recipes/arduinojson/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/arduinojson/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/args-parser/all/conanfile.py b/recipes/args-parser/all/conanfile.py index 60a33d8d53643..6203a42e03b3a 100644 --- a/recipes/args-parser/all/conanfile.py +++ b/recipes/args-parser/all/conanfile.py @@ -1,7 +1,13 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os +required_conan_version = ">=1.50.0" + class ArgsParserConan(ConanFile): name = "args-parser" @@ -10,46 +16,54 @@ class ArgsParserConan(ConanFile): license = "MIT" description = "Small C++ header-only library for parsing command line arguments." topics = ("args-parser", "argument", "parsing") - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True @property - def _source_subfolder(self): - return "source_subfolder" + def _min_cppstd(self): + return "14" @property def _compilers_minimum_version(self): return { "Visual Studio": "15", + "msvc": "191", "gcc": "5", "clang": "3.5", - "apple-clang": "10" + "apple-clang": "10", } + def package_id(self): + self.info.clear() + def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, "14") - - compiler = str(self.settings.compiler) - if compiler not in self._compilers_minimum_version: - self.output.warn("Unknown compiler, assuming it supports at least C++14") - return + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler does not support.", + ) - version = tools.Version(self.settings.compiler.version) - if version < self._compilers_minimum_version[compiler]: - raise ConanInvalidConfiguration("args-parser requires a compiler that supports at least C++14") + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - self.copy("*.hpp", src=os.path.join(self._source_subfolder, "args-parser"), dst=os.path.join("include", "args-parser")) + def build(self): + pass - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "args-parser"), dst=os.path.join(self.package_folder, "include", "args-parser")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "args-parser" - self.cpp_info.names["cmake_find_package_multi"] = "args-parser" + self.cpp_info.set_property("cmake_file_name", "args-parser") + self.cpp_info.set_property("cmake_target_name", "args-parser::args-parser") self.cpp_info.includedirs.append(os.path.join("include", "args-parser")) + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/args-parser/all/test_package/CMakeLists.txt b/recipes/args-parser/all/test_package/CMakeLists.txt index 69ba7c949c0c1..94b80c9c35998 100644 --- a/recipes/args-parser/all/test_package/CMakeLists.txt +++ b/recipes/args-parser/all/test_package/CMakeLists.txt @@ -1,18 +1,8 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -project(args-parser.test) +find_package(args-parser REQUIRED CONFIG) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - -conan_basic_setup(TARGETS) - -find_package(args-parser REQUIRED) - -add_executable(${PROJECT_NAME} example.cpp) - -target_link_libraries(${PROJECT_NAME} args-parser::args-parser) - -set_target_properties(${PROJECT_NAME} PROPERTIES - CXX_STANDARD 14 - CXX_STANDARD_REQUIRED ON -) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE args-parser::args-parser) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/args-parser/all/test_package/conanfile.py b/recipes/args-parser/all/test_package/conanfile.py index 80ed51789cdbc..d120a992c06a6 100644 --- a/recipes/args-parser/all/test_package/conanfile.py +++ b/recipes/args-parser/all/test_package/conanfile.py @@ -1,8 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -class ArgsParserTestConan(ConanFile): - generators = "cmake", "cmake_find_package" + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -10,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "args-parser.test") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/args-parser/all/test_package/example.cpp b/recipes/args-parser/all/test_package/test_package.cpp similarity index 100% rename from recipes/args-parser/all/test_package/example.cpp rename to recipes/args-parser/all/test_package/test_package.cpp diff --git a/recipes/args-parser/all/test_v1_package/CMakeLists.txt b/recipes/args-parser/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..135995b086884 --- /dev/null +++ b/recipes/args-parser/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(args-parser REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE args-parser::args-parser) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/args-parser/all/test_v1_package/conanfile.py b/recipes/args-parser/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/args-parser/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/avir/all/conanfile.py b/recipes/avir/all/conanfile.py index 3b6d0f2c88431..61093399842d4 100644 --- a/recipes/avir/all/conanfile.py +++ b/recipes/avir/all/conanfile.py @@ -1,9 +1,10 @@ +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans.errors import ConanInvalidConfiguration -from conans import ConanFile, CMake, tools +required_conan_version = ">=1.50.0" -required_conan_version = ">=1.33.0" class AVIRConan(ConanFile): name = "avir" @@ -12,22 +13,28 @@ class AVIRConan(ConanFile): description = "High-quality pro image resizing / scaling C++ library, image resize" topics = ("image-processing", "image-resizer", "lanczos", ) homepage = "https://github.com/avaneev/avir" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*.h", dst="include", src=self._source_subfolder) + def build(self): + pass - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) def package_info(self): - self.cpp_info.filenames["cmake_find_package"] = "avir" - self.cpp_info.filenames["cmake_find_package_multi"] = "avir" + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/avir/all/test_package/CMakeLists.txt b/recipes/avir/all/test_package/CMakeLists.txt index b3def3869d314..51fd0e87ec014 100644 --- a/recipes/avir/all/test_package/CMakeLists.txt +++ b/recipes/avir/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(avir CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} avir::avir) +target_link_libraries(${PROJECT_NAME} PRIVATE avir::avir) diff --git a/recipes/avir/all/test_package/conanfile.py b/recipes/avir/all/test_package/conanfile.py index f60f129dfec88..d120a992c06a6 100644 --- a/recipes/avir/all/test_package/conanfile.py +++ b/recipes/avir/all/test_package/conanfile.py @@ -1,9 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools -class AVIRTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/avir/all/test_v1_package/CMakeLists.txt b/recipes/avir/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b53aff65d290e --- /dev/null +++ b/recipes/avir/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(avir CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE avir::avir) diff --git a/recipes/avir/all/test_v1_package/conanfile.py b/recipes/avir/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/avir/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/backport-cpp/all/conanfile.py b/recipes/backport-cpp/all/conanfile.py index 081c1280e8006..a114a54bf9ff4 100644 --- a/recipes/backport-cpp/all/conanfile.py +++ b/recipes/backport-cpp/all/conanfile.py @@ -1,7 +1,9 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" class BackportCppRecipe(ConanFile): @@ -14,24 +16,30 @@ class BackportCppRecipe(ConanFile): settings = "os", "arch", "compiler", "build_type" no_copy_source=True - @property - def _source_subfolder(self): - return "source_subfolder" - def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(os.path.join("include", "**", "*.hpp"), src=self._source_subfolder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, os.path.join("include", "**", "*.hpp"), src=self.source_folder, dst=self.package_folder) def package_info(self): self.cpp_info.set_property("cmake_file_name", "Backport") self.cpp_info.set_property("cmake_target_name", "Backport::Backport") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "Backport" diff --git a/recipes/backport-cpp/all/test_package/CMakeLists.txt b/recipes/backport-cpp/all/test_package/CMakeLists.txt index c02d367dce1ee..2b33b3fe58289 100644 --- a/recipes/backport-cpp/all/test_package/CMakeLists.txt +++ b/recipes/backport-cpp/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(Backport REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} Backport::Backport) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE Backport::Backport) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/backport-cpp/all/test_package/conanfile.py b/recipes/backport-cpp/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/backport-cpp/all/test_package/conanfile.py +++ b/recipes/backport-cpp/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/backport-cpp/all/test_v1_package/CMakeLists.txt b/recipes/backport-cpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7c4264b0a6d02 --- /dev/null +++ b/recipes/backport-cpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Backport REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Backport::Backport) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/backport-cpp/all/test_v1_package/conanfile.py b/recipes/backport-cpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/backport-cpp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bertrand/all/CMakeLists.txt b/recipes/bertrand/all/CMakeLists.txt deleted file mode 100644 index 6c3ae2de9686d..0000000000000 --- a/recipes/bertrand/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/bertrand/all/conandata.yml b/recipes/bertrand/all/conandata.yml index 7bf2628360394..78b4e7eb868bb 100644 --- a/recipes/bertrand/all/conandata.yml +++ b/recipes/bertrand/all/conandata.yml @@ -1,16 +1,16 @@ sources: - 0.0.12: - url: https://github.com/bernedom/bertrand/archive/0.0.12.tar.gz - sha256: 0648edbb9ea39a918f718a672e14b26c614d8409f146c1550becd45d881cfcf4 - 0.0.14: - url: https://github.com/bernedom/bertrand/archive/0.0.14.tar.gz - sha256: f6ba82e715f9371f06a0d0bd6b7f017c3ff0709e8e5142d8fd4ba00aec1228ba - 0.0.15: - url: https://github.com/bernedom/bertrand/archive/0.0.15.tar.gz - sha256: 5ad481c2fc3d3166d8660ab3013b4513c5b425c9f13c8925b3cfb40f988d8e9b - 0.0.17: - url: https://github.com/bernedom/bertrand/archive/0.0.17.tar.gz - sha256: 72e59971bd8ae48d95da9337ad78004b99ba4e8d0eeb3b613ce17b577ca41012 "0.013": url: "https://github.com/bernedom/bertrand/archive/0.013.tar.gz" sha256: "f2f071006d3a9b31382957b84e81405adba44cbf1a9bb8242ad4d0f44d7af7fb" + "0.0.17": + url: https://github.com/bernedom/bertrand/archive/0.0.17.tar.gz + sha256: 72e59971bd8ae48d95da9337ad78004b99ba4e8d0eeb3b613ce17b577ca41012 + "0.0.15": + url: https://github.com/bernedom/bertrand/archive/0.0.15.tar.gz + sha256: 5ad481c2fc3d3166d8660ab3013b4513c5b425c9f13c8925b3cfb40f988d8e9b + "0.0.14": + url: https://github.com/bernedom/bertrand/archive/0.0.14.tar.gz + sha256: f6ba82e715f9371f06a0d0bd6b7f017c3ff0709e8e5142d8fd4ba00aec1228ba + "0.0.12": + url: https://github.com/bernedom/bertrand/archive/0.0.12.tar.gz + sha256: 0648edbb9ea39a918f718a672e14b26c614d8409f146c1550becd45d881cfcf4 diff --git a/recipes/bertrand/all/conanfile.py b/recipes/bertrand/all/conanfile.py index 1b0502b9ea2fd..3e410daba2d59 100644 --- a/recipes/bertrand/all/conanfile.py +++ b/recipes/bertrand/all/conanfile.py @@ -1,9 +1,12 @@ -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration - - +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir import os +required_conan_version = ">=1.50.0" + class BertrandConan(ConanFile): name = "bertrand" @@ -11,56 +14,70 @@ class BertrandConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/bernedom/bertrand" description = "A C++ header only library providing a trivial implementation for design by contract." - topics = ("design by contract", "dbc", - "cplusplus-library", "cplusplus-17") - exports_sources = "CMakeLists.txt" + topics = ("design by contract", "dbc", "cplusplus-library", "cplusplus-17") settings = "os", "arch", "compiler", "build_type" - no_copy_source = True - generators = "cmake" @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def _min_cppstd(self): + return "17" @property def _compilers_minimum_version(self): return { "gcc": "7", "Visual Studio": "15.7", + "msvc": "191", "clang": "5", "apple-clang": "10", } - def configure(self): + def package_id(self): + self.info.clear() + + def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, "17") - minimum_version = self._compilers_minimum_version.get( - str(self.settings.compiler), False) - if minimum_version: - if tools.Version(self.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration("bertrand requires C++17, which your compiler ({} {}) does not support.".format( - self.settings.compiler, self.settings.compiler.version)) - else: - self.output.warn( - "bertrand requires C++17. Your compiler is unknown. Assuming it supports C++17.") + check_min_cppstd(self, self._min_cppstd) - def package_id(self): - self.info.header_only() + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler does not support.", + ) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = "bertrand-{}".format(self.version) - os.rename(extracted_folder, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BERTRAND_BUILD_TESTING"] = False + tc.variables["BERTRAND_INSTALL_LIBRARY"] = True + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) cmake = CMake(self) - cmake.definitions["BERTRAND_BUILD_TESTING"] = False - cmake.definitions["BERTRAND_INSTALL_LIBRARY"] = True - cmake.configure(build_folder=self._build_subfolder) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "bertrand") + self.cpp_info.set_property("cmake_target_name", "bertrand::bertrand") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/bertrand/all/test_package/CMakeLists.txt b/recipes/bertrand/all/test_package/CMakeLists.txt index 6d951a20d7497..8d8eab3e4ede9 100644 --- a/recipes/bertrand/all/test_package/CMakeLists.txt +++ b/recipes/bertrand/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ cmake_minimum_required(VERSION 3.8) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(bertrand REQUIRED CONFIG) -add_executable(${PROJECT_NAME} bertrand_package_test.cpp) +add_executable(${PROJECT_NAME} test_package.cpp) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) -target_link_libraries(${PROJECT_NAME} bertrand::bertrand) +target_link_libraries(${PROJECT_NAME} PRIVATE bertrand::bertrand) diff --git a/recipes/bertrand/all/test_package/conanfile.py b/recipes/bertrand/all/test_package/conanfile.py index 7e2dfe859bb27..d120a992c06a6 100644 --- a/recipes/bertrand/all/test_package/conanfile.py +++ b/recipes/bertrand/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bertrand/all/test_package/bertrand_package_test.cpp b/recipes/bertrand/all/test_package/test_package.cpp similarity index 100% rename from recipes/bertrand/all/test_package/bertrand_package_test.cpp rename to recipes/bertrand/all/test_package/test_package.cpp diff --git a/recipes/bertrand/all/test_v1_package/CMakeLists.txt b/recipes/bertrand/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4b58a4f48ada0 --- /dev/null +++ b/recipes/bertrand/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bertrand REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +target_link_libraries(${PROJECT_NAME} PRIVATE bertrand::bertrand) diff --git a/recipes/bertrand/all/test_v1_package/conanfile.py b/recipes/bertrand/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/bertrand/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bertrand/config.yml b/recipes/bertrand/config.yml index 6317c45fb5e19..f342735d8a8f8 100644 --- a/recipes/bertrand/config.yml +++ b/recipes/bertrand/config.yml @@ -1,11 +1,11 @@ versions: - 0.0.12: + "0.013": folder: all - 0.0.14: + "0.0.17": folder: all - 0.0.15: + "0.0.15": folder: all - 0.0.17: + "0.0.14": folder: all - "0.013": + "0.0.12": folder: all diff --git a/recipes/blaze/all/conandata.yml b/recipes/blaze/all/conandata.yml index d481439d0eb6a..a6e5a6aa09753 100644 --- a/recipes/blaze/all/conandata.yml +++ b/recipes/blaze/all/conandata.yml @@ -1,7 +1,7 @@ sources: - "3.7": - sha256: 4dfd6bf518c983e8785e217262813d44cdd2842955792417eb0b3736586168fa - url: https://bitbucket.org/blaze-lib/blaze/downloads/blaze-3.7.tar.gz "3.8": - sha256: dfaae1a3a9fea0b3cc92e78c9858dcc6c93301d59f67de5d388a3a41c8a629ae - url: https://bitbucket.org/blaze-lib/blaze/downloads/blaze-3.8.tar.gz + url: "https://bitbucket.org/blaze-lib/blaze/downloads/blaze-3.8.tar.gz" + sha256: "dfaae1a3a9fea0b3cc92e78c9858dcc6c93301d59f67de5d388a3a41c8a629ae" + "3.7": + url: "https://bitbucket.org/blaze-lib/blaze/downloads/blaze-3.7.tar.gz" + sha256: "ef3cbc5db7d62dcdde0af88d3c951051254afd750d26773406fddb6afc5ad890" diff --git a/recipes/blaze/all/conanfile.py b/recipes/blaze/all/conanfile.py index 8d62468e456df..a5d62edf842a5 100644 --- a/recipes/blaze/all/conanfile.py +++ b/recipes/blaze/all/conanfile.py @@ -1,5 +1,10 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import chdir, copy, get, rename, rmdir +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools + +required_conan_version = ">=1.50.0" class BlazeConan(ConanFile): @@ -7,22 +12,40 @@ class BlazeConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://bitbucket.org/blaze-lib/blaze" description = "open-source, high-performance C++ math library for dense and sparse arithmetic" - topics = ("conan", "blaze", "math", "algebra", "linear algebra", "high-performance") + topics = ("blaze", "math", "algebra", "linear algebra", "high-performance") license = "BSD-3-Clause" - + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 14) + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("blaze-{}".format(self.version), self._source_subfolder) + base_source_dir = os.path.join(self.source_folder, os.pardir) + get(self, **self.conan_data["sources"][self.version], + destination=base_source_dir, strip_root=True) + with chdir(self, base_source_dir): + rmdir(self, self.source_folder) + rename(self, src=f"blaze-{self.version}", dst=self.source_folder) - def package_id(self): - self.info.header_only() + def build(self): + pass def package(self): - self.copy("LICENSE", src=os.path.join(self.source_folder, self._source_subfolder), dst="licenses") - self.copy(pattern="blaze/*.h", src=os.path.join(self.source_folder, self._source_subfolder), dst="include") + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "blaze/*.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "blaze") + self.cpp_info.set_property("cmake_target_name", "blaze::blaze") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/blaze/all/test_package/CMakeLists.txt b/recipes/blaze/all/test_package/CMakeLists.txt index c92478a554d8b..1b0a92218a093 100755 --- a/recipes/blaze/all/test_package/CMakeLists.txt +++ b/recipes/blaze/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.5) -project(test_package) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(blaze REQUIRED CONFIG) -add_executable(example example.cpp) -target_link_libraries(example ${CONAN_LIBS}) -set_target_properties(example PROPERTIES - CXX_STANDARD 14 - CXX_STANDARD_REQUIRED ON) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE blaze::blaze) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/blaze/all/test_package/conanfile.py b/recipes/blaze/all/test_package/conanfile.py index 7b99c9826a2c7..d120a992c06a6 100755 --- a/recipes/blaze/all/test_package/conanfile.py +++ b/recipes/blaze/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -class BlazeTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/blaze/all/test_package/example.cpp b/recipes/blaze/all/test_package/test_package.cpp similarity index 100% rename from recipes/blaze/all/test_package/example.cpp rename to recipes/blaze/all/test_package/test_package.cpp diff --git a/recipes/blaze/all/test_v1_package/CMakeLists.txt b/recipes/blaze/all/test_v1_package/CMakeLists.txt new file mode 100755 index 0000000000000..ec8caed27fa90 --- /dev/null +++ b/recipes/blaze/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(blaze REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE blaze::blaze) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/blaze/all/test_v1_package/conanfile.py b/recipes/blaze/all/test_v1_package/conanfile.py new file mode 100755 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/blaze/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/blaze/config.yml b/recipes/blaze/config.yml index 8bc78d87a1dd0..df754600895a3 100644 --- a/recipes/blaze/config.yml +++ b/recipes/blaze/config.yml @@ -1,5 +1,5 @@ versions: - "3.7": - folder: all "3.8": folder: all + "3.7": + folder: all diff --git a/recipes/boost/all/conanfile.py b/recipes/boost/all/conanfile.py index b9c2f4023740d..0342414637931 100644 --- a/recipes/boost/all/conanfile.py +++ b/recipes/boost/all/conanfile.py @@ -1,7 +1,6 @@ from conan.tools.apple import is_apple_os from conan.tools.build import build_jobs, check_min_cppstd, cross_building -from conan.tools.files import chdir, get, mkdir, rename, replace_in_file, rm, rmdir, save -from conan.tools.files.patches import apply_conandata_patches +from conan.tools.files import apply_conandata_patches, chdir, get, mkdir, rename, replace_in_file, rm, rmdir, save from conan.tools.microsoft import msvc_runtime_flag from conan import ConanFile from conan.errors import ConanException, ConanInvalidConfiguration @@ -1286,11 +1285,19 @@ def create_library_config(deps_name, name): @property def _toolset_version(self): - if self._is_msvc: + if self.settings.get_safe("compiler") == "Visual Studio": toolset = tools.msvs_toolset(self) match = re.match(r"v(\d+)(\d)$", toolset) if match: return f"{match.group(1)}.{match.group(2)}" + elif self.settings.get_safe("compiler") == "msvc": + toolsets = {'170': '11.0', + '180': '12.0', + '190': '14.0', + '191': '14.1', + '192': '14.2', + "193": '14.3'} + return toolsets[self.settings.get_safe("compiler.version")] return "" @property diff --git a/recipes/brigand/all/conandata.yml b/recipes/brigand/all/conandata.yml index a0d9557501e79..9a62d14168e32 100644 --- a/recipes/brigand/all/conandata.yml +++ b/recipes/brigand/all/conandata.yml @@ -1,4 +1,4 @@ sources: "cpp11-1.3.0": - url: https://github.com/edouarda/brigand/archive/refs/tags/cpp11-1.3.0.tar.gz - sha256: 33c8fc780d2f2c9c0d21cbea909429ae9a64765496f66f6ab2f1e978502aa295 + url: "https://github.com/edouarda/brigand/archive/refs/tags/cpp11-1.3.0.tar.gz" + sha256: "33c8fc780d2f2c9c0d21cbea909429ae9a64765496f66f6ab2f1e978502aa295" diff --git a/recipes/brigand/all/conanfile.py b/recipes/brigand/all/conanfile.py index 7975d98b3dc53..d205988b4830f 100644 --- a/recipes/brigand/all/conanfile.py +++ b/recipes/brigand/all/conanfile.py @@ -1,9 +1,10 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools - - -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.50.0" class BrigandConan(ConanFile): @@ -13,29 +14,51 @@ class BrigandConan(ConanFile): topics = ("meta-programming", "boost", "runtime", "header-only") homepage = "https://github.com/edouarda/brigand" license = "BSL-1.0" - settings = "compiler" - requires = "boost/1.75.0" - no_copy_sources = True - @property - def _source_subfolder(self): - return "source_subfolder" + settings = "os", "arch", "compiler", "build_type" + options = { + "with_boost": [True, False], + } + default_options = { + "with_boost": True, + } + + no_copy_source = True + + def requirements(self): + if self.options.with_boost: + # TODO: add transitive_headers=True & bump required_conan_version to >=1.52.0 + self.requires("boost/1.79.0") + + def package_id(self): + self.info.clear() def validate(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename("{}-{}".format(self.name, self.version), self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) include_path = os.path.join("include", "brigand") - self.copy("*.hpp", dst=include_path, src=os.path.join(self._source_subfolder, include_path)) - - def package_id(self): - self.info.header_only() + copy(self, "*.hpp", src=os.path.join(self.source_folder, include_path), dst=os.path.join(self.package_folder, include_path)) def package_info(self): - self.cpp_info.names["pkg_config"] = "libbrigand" + self.cpp_info.set_property("pkg_config_name", "libbrigand") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + if self.options.with_boost: + self.cpp_info.requires = ["boost::headers"] + else: + self.cpp_info.defines.append("BRIGAND_NO_BOOST_SUPPORT") diff --git a/recipes/brigand/all/test_package/CMakeLists.txt b/recipes/brigand/all/test_package/CMakeLists.txt index 8e185891d822d..edca2f720d504 100644 --- a/recipes/brigand/all/test_package/CMakeLists.txt +++ b/recipes/brigand/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(brigand REQUIRED) +find_package(brigand REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} brigand::brigand) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE brigand::brigand) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/brigand/all/test_package/conanfile.py b/recipes/brigand/all/test_package/conanfile.py index 55bf6d0ec4634..d120a992c06a6 100644 --- a/recipes/brigand/all/test_package/conanfile.py +++ b/recipes/brigand/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi", "pkg_config" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/brigand/all/test_v1_package/CMakeLists.txt b/recipes/brigand/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..c08f269548f6a --- /dev/null +++ b/recipes/brigand/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(brigand REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE brigand::brigand) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/brigand/all/test_v1_package/conanfile.py b/recipes/brigand/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/brigand/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bvdberg-ctest/all/conanfile.py b/recipes/bvdberg-ctest/all/conanfile.py index 96b95b7505043..ac8c63a98f38c 100644 --- a/recipes/bvdberg-ctest/all/conanfile.py +++ b/recipes/bvdberg-ctest/all/conanfile.py @@ -1,5 +1,10 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools + +required_conan_version = ">=1.50.0" class BvdbergCtestConan(ConanFile): @@ -8,21 +13,33 @@ class BvdbergCtestConan(ConanFile): homepage = "https://github.com/bvdberg/ctest" url = "https://github.com/conan-io/conan-center-index" description = "ctest is a unit test framework for software written in C." - topics = ("conan", "testing", "testing-framework", "unit-testing") + topics = ("testing", "testing-framework", "unit-testing") + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.os == "Windows": + raise ConanInvalidConfiguration("Windows not supported") + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = "ctest" + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*.h", dst="include", src=self._source_subfolder) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) - def package_id(self): - self.info.header_only() + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/bvdberg-ctest/all/test_package/CMakeLists.txt b/recipes/bvdberg-ctest/all/test_package/CMakeLists.txt index 7b9b613cbb24a..85fca601d8ec2 100644 --- a/recipes/bvdberg-ctest/all/test_package/CMakeLists.txt +++ b/recipes/bvdberg-ctest/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(bvdberg-ctest REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE bvdberg-ctest::bvdberg-ctest) diff --git a/recipes/bvdberg-ctest/all/test_package/conanfile.py b/recipes/bvdberg-ctest/all/test_package/conanfile.py index 6c0a50e0f7678..d120a992c06a6 100644 --- a/recipes/bvdberg-ctest/all/test_package/conanfile.py +++ b/recipes/bvdberg-ctest/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools -class TestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - bin_path = self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bvdberg-ctest/all/test_v1_package/CMakeLists.txt b/recipes/bvdberg-ctest/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..fd0d83ce8ad41 --- /dev/null +++ b/recipes/bvdberg-ctest/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bvdberg-ctest REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE bvdberg-ctest::bvdberg-ctest) diff --git a/recipes/bvdberg-ctest/all/test_v1_package/conanfile.py b/recipes/bvdberg-ctest/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..f2243371b7f1d --- /dev/null +++ b/recipes/bvdberg-ctest/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + bin_path = self.run(bin_path, run_environment=True) diff --git a/recipes/bvdberg-ctest/config.yml b/recipes/bvdberg-ctest/config.yml index 8f50af2b049ed..c7f13630776fb 100644 --- a/recipes/bvdberg-ctest/config.yml +++ b/recipes/bvdberg-ctest/config.yml @@ -1,4 +1,3 @@ ---- versions: "1.0.0": folder: "all" diff --git a/recipes/bzip2/all/conanfile.py b/recipes/bzip2/all/conanfile.py index 21bbc20a17907..1c4db485095a2 100644 --- a/recipes/bzip2/all/conanfile.py +++ b/recipes/bzip2/all/conanfile.py @@ -80,9 +80,7 @@ def package(self): def _create_cmake_module_variables(self, module_file): content = textwrap.dedent("""\ set(BZIP2_NEED_PREFIX TRUE) - if(NOT DEFINED BZIP2_FOUND AND DEFINED BZip2_FOUND) - set(BZIP2_FOUND ${BZip2_FOUND}) - endif() + set(BZIP2_FOUND TRUE) if(NOT DEFINED BZIP2_INCLUDE_DIRS AND DEFINED BZip2_INCLUDE_DIRS) set(BZIP2_INCLUDE_DIRS ${BZip2_INCLUDE_DIRS}) endif() diff --git a/recipes/bzip3/all/CMakeLists.txt b/recipes/bzip3/all/CMakeLists.txt index aa405e82d4e6b..783a1988b3c10 100644 --- a/recipes/bzip3/all/CMakeLists.txt +++ b/recipes/bzip3/all/CMakeLists.txt @@ -1,37 +1,36 @@ cmake_minimum_required(VERSION 3.4) project(bzip3 LANGUAGES C) -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -option(WITH_THREAD "enable thread" OFF) -option(WITH_UTIL "build and install utility" OFF) +option(BZIP3_WITH_THREAD "enable thread" OFF) +option(BZIP3_WITH_UTIL "build and install utility" OFF) set(BZIP3_INC - source_subfolder/include/libbz3.h + ${BZIP3_SRC_DIR}/include/libbz3.h ) add_library(bzip3) target_sources(bzip3 PRIVATE - source_subfolder/src/cm.c - source_subfolder/src/crc32.c - source_subfolder/src/libbz3.c - source_subfolder/src/libsais.c - source_subfolder/src/lzp.c - source_subfolder/src/rle.c + ${BZIP3_SRC_DIR}/src/cm.c + ${BZIP3_SRC_DIR}/src/crc32.c + ${BZIP3_SRC_DIR}/src/libbz3.c + ${BZIP3_SRC_DIR}/src/libsais.c + ${BZIP3_SRC_DIR}/src/lzp.c + ${BZIP3_SRC_DIR}/src/rle.c ) -target_include_directories(bzip3 PUBLIC source_subfolder/include) +target_include_directories(bzip3 PUBLIC ${BZIP3_SRC_DIR}/include) set_target_properties(bzip3 PROPERTIES PUBLIC_HEADER "${BZIP3_INC}" - WINDOWS_EXPORT_ALL_SYMBOLS ON + C_VISIBILITY_PRESET hidden C_EXTENSIONS OFF ) -if (with_thread) +if (BZIP3_WITH_THREAD) + find_package(Threads REQUIRED) + target_link_libraries(bzip3 PRIVATE Threads::Threads) target_compile_definitions(bzip3 PRIVATE "PTHREAD") endif() -if (WITH_UTIL) - add_executable(bzip3_cmd source_subfolder/src/main.c) +if (BZIP3_WITH_UTIL) + add_executable(bzip3_cmd ${BZIP3_SRC_DIR}/src/main.c) target_link_libraries(bzip3_cmd bzip3) target_compile_definitions(bzip3_cmd PRIVATE "VERSION=\"${VERSION}\"") set_target_properties(bzip3_cmd PROPERTIES OUTPUT_NAME "bzip3") @@ -49,9 +48,6 @@ install( PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -if (WITH_UTIL) - install( - TARGETS bzip3_cmd - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - ) +if (BZIP3_WITH_UTIL) + install(TARGETS bzip3_cmd DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/recipes/bzip3/all/conandata.yml b/recipes/bzip3/all/conandata.yml index fa5971eacb084..a3a9020f9818f 100644 --- a/recipes/bzip3/all/conandata.yml +++ b/recipes/bzip3/all/conandata.yml @@ -2,8 +2,7 @@ sources: "1.1.4": url: "https://github.com/kspalaiologos/bzip3/releases/download/1.1.4/bzip3-1.1.4.tar.bz2" sha256: "e23a06ae17fc36192e79d0151950b3bbd4e26381af50ba4b4fd7a2d9797e498f" - patches: "1.1.4": - patch_file: "patches/0001-make-restrict-alias.patch" - base_path: "source_subfolder" + - patch_file: "patches/0002-export-symbols.patch" diff --git a/recipes/bzip3/all/conanfile.py b/recipes/bzip3/all/conanfile.py index 1af51c8f3738c..196224b72dc65 100644 --- a/recipes/bzip3/all/conanfile.py +++ b/recipes/bzip3/all/conanfile.py @@ -1,7 +1,10 @@ -import functools -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get +import os + +required_conan_version = ">=1.46.0" -required_conan_version = ">=1.33.0" class BZip3Conan(ConanFile): name = "bzip3" @@ -23,53 +26,61 @@ class BZip3Conan(ConanFile): "with_thread": True, "with_util": False, } - generators = "cmake" - - @property - def _source_subfolder(self): - return "source_subfolder" def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): - if self.settings.os == 'Windows': + if self.settings.os == "Windows": del self.options.fPIC + # FIXME: could be supported on Windows: + # - MinGW with posix thread supports it out of the box + # - otherwise, add pthreads4w to requirements and link it in CMakeLists + if self.settings.os == "Windows": + del self.options.with_thread def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.cppstd - del self.settings.compiler.libcxx - if self.settings.os not in ["Linux", "FreeBSD"]: - del self.options.with_thread + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - @functools.lru_cache(1) - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["WITH_PTHREAD"] = self.options.get_safe("with_thread", False) - cmake.definitions["WITH_UTIL"] = self.options.with_util - cmake.definitions["VERSION"] = self.version - cmake.configure() - return cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BZIP3_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["BZIP3_WITH_PTHREAD"] = self.options.get_safe("with_thread", False) + tc.variables["BZIP3_WITH_UTIL"] = self.options.with_util + tc.variables["VERSION"] = self.version + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): + self.cpp_info.set_property("pkg_config_name", "bzip3") self.cpp_info.libs = ["bzip3"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") diff --git a/recipes/bzip3/all/patches/0002-export-symbols.patch b/recipes/bzip3/all/patches/0002-export-symbols.patch new file mode 100644 index 0000000000000..3bdf13582cc59 --- /dev/null +++ b/recipes/bzip3/all/patches/0002-export-symbols.patch @@ -0,0 +1,95 @@ +--- a/include/common.h ++++ b/include/common.h +@@ -46,10 +46,6 @@ static void write_neutral_s32(u8 * data, s32 value) { + data[3] = (value >> 24) & 0xFF; + } + +-#ifdef __MINGW32__ +- #define PUBLIC_API __declspec(dllexport) +-#else +- #define PUBLIC_API +-#endif ++#define PUBLIC_API + + #endif +--- a/include/libbz3.h ++++ b/include/libbz3.h +@@ -22,6 +22,16 @@ + + #include + ++#ifdef bzip3_EXPORTS ++#ifdef _WIN32 ++ #define BZIP3_API __declspec(dllexport) ++#else ++ #define BZIP3_API __attribute__((visibility("default"))) ++#endif ++#else ++ #define BZIP3_API ++#endif ++ + #define BZ3_OK 0 + #define BZ3_ERR_OUT_OF_BOUNDS -1 + #define BZ3_ERR_BWT -2 +@@ -35,31 +45,31 @@ struct bz3_state; + /** + * @brief Get the last error number associated with a given state. + */ +-int8_t bz3_last_error(struct bz3_state * state); ++BZIP3_API int8_t bz3_last_error(struct bz3_state * state); + + /** + * @brief Return a user-readable message explaining the cause of the last error. + */ +-const char * bz3_strerror(struct bz3_state * state); ++BZIP3_API const char * bz3_strerror(struct bz3_state * state); + + /** + * @brief Construct a new block encoder state, which will encode blocks as big as the given block size. + * The decoder will be able to decode blocks at most as big as the given block size. + * Returns NULL in case allocation fails or the block size is not between 65K and 511M + */ +-struct bz3_state * bz3_new(int32_t block_size); ++BZIP3_API struct bz3_state * bz3_new(int32_t block_size); + + /** + * @brief Free the memory occupied by a block encoder state. + */ +-void bz3_free(struct bz3_state * state); ++BZIP3_API void bz3_free(struct bz3_state * state); + + /** + * @brief Encode a single block. Returns the amount of bytes written to `buffer'. + * `buffer' must be able to hold at least `size + size / 50 + 32' bytes. The size must not + * exceed the block size associated with the state. + */ +-int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t size); ++BZIP3_API int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t size); + + /** + * @brief Decode a single block. +@@ -68,7 +78,7 @@ int32_t bz3_encode_block(struct bz3_state * state, uint8_t * buffer, int32_t siz + * @param size The size of the compressed data in `buffer' + * @param orig_size The original size of the data before compression. + */ +-int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t size, int32_t orig_size); ++BZIP3_API int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t size, int32_t orig_size); + + /** + * @brief Encode `n' blocks, all in parallel. +@@ -80,13 +90,13 @@ int32_t bz3_decode_block(struct bz3_state * state, uint8_t * buffer, int32_t siz + * + * Present in the shared library only if -lpthread was present during building. + */ +-void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t n); ++BZIP3_API void bz3_encode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t n); + + /** + * @brief Decode `n' blocks, all in parallel. + * Same specifics as `bz3_encode_blocks', but doesn't overwrite `sizes'. + */ +-void bz3_decode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t orig_sizes[], ++BZIP3_API void bz3_decode_blocks(struct bz3_state * states[], uint8_t * buffers[], int32_t sizes[], int32_t orig_sizes[], + int32_t n); + + #endif diff --git a/recipes/bzip3/all/test_package/CMakeLists.txt b/recipes/bzip3/all/test_package/CMakeLists.txt index b2ec9ca5de82a..e47e03f4174fe 100644 --- a/recipes/bzip3/all/test_package/CMakeLists.txt +++ b/recipes/bzip3/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(bzip3 REQUIRED CONFIG) -add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c) -target_link_libraries(${PROJECT_NAME} bzip3::bzip3) +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE bzip3::bzip3) diff --git a/recipes/bzip3/all/test_package/conanfile.py b/recipes/bzip3/all/test_package/conanfile.py index e556cc050d509..d120a992c06a6 100644 --- a/recipes/bzip3/all/test_package/conanfile.py +++ b/recipes/bzip3/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools -class TestConan(ConanFile): +class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bzip3/all/test_v1_package/CMakeLists.txt b/recipes/bzip3/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..8c1771e7b1081 --- /dev/null +++ b/recipes/bzip3/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(bzip3 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE bzip3::bzip3) diff --git a/recipes/bzip3/all/test_v1_package/conanfile.py b/recipes/bzip3/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/bzip3/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/bzip3/config.yml b/recipes/bzip3/config.yml index a119f2956027b..f7bc2bb892fbd 100644 --- a/recipes/bzip3/config.yml +++ b/recipes/bzip3/config.yml @@ -1,4 +1,3 @@ ---- versions: "1.1.4": folder: all diff --git a/recipes/cminpack/all/conandata.yml b/recipes/cminpack/all/conandata.yml new file mode 100644 index 0000000000000..114fe2eaf9bb8 --- /dev/null +++ b/recipes/cminpack/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.3.8": + sha256: "3ea7257914ad55eabc43a997b323ba0dfee0a9b010d648b6d5b0c96425102d0e" + url: "https://github.com/devernay/cminpack/archive/refs/tags/v1.3.8.tar.gz" diff --git a/recipes/cminpack/all/conanfile.py b/recipes/cminpack/all/conanfile.py new file mode 100644 index 0000000000000..a1da35f69dd6a --- /dev/null +++ b/recipes/cminpack/all/conanfile.py @@ -0,0 +1,116 @@ +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools import files +from conan import ConanFile +import os + +required_conan_version = ">=1.45.0" + + +class CMinpackConan(ConanFile): + name = "cminpack" + url = "https://github.com/conan-io/conan-center-index" + description = "About A C/C++ rewrite of the MINPACK software (originally in FORTRAN)" \ + "for solving nonlinear equations and nonlinear least squares problems" + topics = ("nonlinear", "solver") + homepage = "http://devernay.free.fr/hacks/cminpack/" + license = "LicenseRef-CopyrightMINPACK.txt" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_EXAMPLES"] = "OFF" + tc.variables["CMINPACK_LIB_INSTALL_DIR"] = "lib" + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + def layout(self): + cmake_layout(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + + # cminpack is a c library + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], + strip_root=True, destination=self.source_folder) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + files.copy(self, "CopyrightMINPACK.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + files.rmdir(self, os.path.join(self.package_folder, "share")) # contains cmake config files + + def _library_postfix(self): + postfix = "" + if not self.options.shared: + postfix += "_s" # for static + if self.settings.build_type == "Debug": + postfix += "_d" + + return postfix + + def package_info(self): + minpack_include_dir = os.path.join("include", "cminpack-1") + self.cpp_info.set_property("cmake_target_name", "cminpack") + # the double precision version + self.cpp_info.components['cminpack-double'].libs = ['cminpack' + self._library_postfix()] + self.cpp_info.components['cminpack-double'].includedirs.append(minpack_include_dir) + self.cpp_info.components["cminpack-double"].set_property("cmake_target_name", "cminpack::cminpack") + self.cpp_info.components["cminpack-double"].names["cmake_find_package"] = "cminpack" + self.cpp_info.components["cminpack-double"].names["cmake_find_package_multi"] = "cminpack" + self.cpp_info.components["cminpack-double"].names["pkg_config"] = "cminpack" + + # the single precision version + self.cpp_info.components['cminpack-single'].libs = ['cminpacks' + self._library_postfix()] + self.cpp_info.components['cminpack-single'].includedirs.append(minpack_include_dir) + self.cpp_info.components['cminpack-single'].defines.append("__cminpack_float__") + self.cpp_info.components["cminpack-single"].set_property("cmake_target_name", "cminpack::cminpacks") + self.cpp_info.components["cminpack-single"].names["cmake_find_package"] = "cminpacks" + self.cpp_info.components["cminpack-single"].names["cmake_find_package_multi"] = "cminpacks" + self.cpp_info.components["cminpack-single"].names["pkg_config"] = "cminpacks" + + + if self.settings.os != "Windows": + self.cpp_info.components['cminpack-double'].system_libs.append("m") + self.cpp_info.components['cminpack-single'].system_libs.append("m") + + # required apple frameworks + self.cpp_info.components['cminpack-double'].frameworks.append("Accelerate") + self.cpp_info.components['cminpack-single'].frameworks.append("Accelerate") + + if not self.options.shared and self.settings.os == "Windows": + self.cpp_info.components['cminpack-double'].defines.append("CMINPACK_NO_DLL") + self.cpp_info.components['cminpack-single'].defines.append("CMINPACK_NO_DLL") diff --git a/recipes/cminpack/all/test_package/CMakeLists.txt b/recipes/cminpack/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fa33c20512fe4 --- /dev/null +++ b/recipes/cminpack/all/test_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.12) +project(CMinPack-Conan-TestPackage C) + +find_package(CMinpack REQUIRED) + +# This builds one of the original cminpack examples against +# both types of the library + +add_executable(cminpack_test_double tchkderc.c) +target_link_libraries(cminpack_test_double PRIVATE cminpack::cminpack) + +add_executable(cminpack_test_float tchkderc.c) +target_link_libraries(cminpack_test_float PRIVATE cminpack::cminpacks) diff --git a/recipes/cminpack/all/test_package/conanfile.py b/recipes/cminpack/all/test_package/conanfile.py new file mode 100644 index 0000000000000..db7d5f7ac5bc3 --- /dev/null +++ b/recipes/cminpack/all/test_package/conanfile.py @@ -0,0 +1,25 @@ + +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + + 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.bindirs[0], "cminpack_test_double") + self.run(bin_path, env="conanrun") + bin_path = os.path.join(self.cpp.build.bindirs[0], "cminpack_test_float") + self.run(bin_path, env="conanrun") diff --git a/recipes/cminpack/all/test_package/tchkderc.c b/recipes/cminpack/all/test_package/tchkderc.c new file mode 100644 index 0000000000000..8f6a3f0f741b8 --- /dev/null +++ b/recipes/cminpack/all/test_package/tchkderc.c @@ -0,0 +1,159 @@ +/* driver for chkder example. */ + +#include +#include +#include +#include +#define real __cminpack_real__ + +/* the following struct defines the data points */ +typedef struct { + int m; + real *y; +#ifdef BOX_CONSTRAINTS + real *xmin; + real *xmax; +#endif +} fcndata_t; + +int fcn(void *p, int m, int n, const real *x, real *fvec, + real *fjac, int ldfjac, int iflag); + +int main() +{ +#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER < 1900)) + _set_output_format(_TWO_DIGIT_EXPONENT); +#endif + int i, ldfjac; + real x[3], fvec[15], fjac[15*3], xp[3], fvecp[15], + err[15]; + const int m = 15; + const int n = 3; + /* auxiliary data (e.g. measurements) */ + real y[15] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1, + 3.9e-1, 3.7e-1, 5.8e-1, 7.3e-1, 9.6e-1, 1.34, 2.1, 4.39}; +#ifdef BOX_CONSTRAINTS + real xmin[3] = {0., 0.1, 0.5}; + real xmax[3] = {2., 1.5, 2.3}; +#endif + fcndata_t data; + data.m = m; + data.y = y; +#ifdef BOX_CONSTRAINTS + data.xmin = xmin; + data.xmax = xmax; +#endif + + /* the following values should be suitable for */ + /* checking the jacobian matrix. */ + + x[0] = 9.2e-1; + x[1] = 1.3e-1; + x[2] = 5.4e-1; + + ldfjac = 15; + + /* compute xp from x */ + __cminpack_func__(chkder)(m, n, x, NULL, NULL, ldfjac, xp, NULL, 1, NULL); + /* compute fvec at x (all components of fvec should be != 0).*/ + fcn(&data, m, n, x, fvec, NULL, ldfjac, 1); + /* compute fjac at x */ + fcn(&data, m, n, x, NULL, fjac, ldfjac, 2); + /* compute fvecp at xp (all components of fvecp should be != 0)*/ + fcn(&data, m, n, xp, fvecp, NULL, ldfjac, 1); + /* check Jacobian, put the result in err */ + __cminpack_func__(chkder)(m, n, x, fvec, fjac, ldfjac, NULL, fvecp, 2, err); + /* Output values: + err[i] = 1.: i-th gradient is correct + err[i] = 0.: i-th gradient is incorrect + err[I] > 0.5: i-th gradient is probably correct + */ + + for (i=0; iy; +#ifdef BOX_CONSTRAINTS + const real *xmin = ((fcndata_t*)p)->xmin; + const real *xmax = ((fcndata_t*)p)->xmax; + int j; + real xb[3]; + real jacfac[3]; + + for (j = 0; j < 3; ++j) { + real xmiddle = (xmin[j]+xmax[j])/2.; + real xwidth = (xmax[j]-xmin[j])/2.; + real th = tanh((x[j]-xmiddle)/xwidth); + xb[j] = xmiddle + th * xwidth; + jacfac[j] = 1. - th * th; + } + x = xb; +#endif + + if (iflag == 0) { + /* insert print statements here when nprint is positive. */ + /* if the nprint parameter to lmder is positive, the function is + called every nprint iterations with iflag=0, so that the + function may perform special operations, such as printing + residuals. */ + return 0; + } + + if (iflag != 2) { + /* compute residuals */ + for (i=0; i < 15; ++i) { + tmp1 = i + 1; + tmp2 = 15 - i; + tmp3 = (i > 7) ? tmp2 : tmp1; + fvec[i] = y[i] - (x[0] + tmp1/(x[1]*tmp2 + x[2]*tmp3)); + } + } else { + /* compute Jacobian */ + for (i=0; i < 15; ++i) { + tmp1 = i + 1; + tmp2 = 15 - i; +# ifdef TCHKDER_FIXED + tmp3 = (i > 7) ? tmp2 : tmp1; +# else + /* error introduced into next statement for illustration. */ + /* corrected statement should read tmp3 = (i > 7) ? tmp2 : tmp1 . */ + tmp3 = (i > 7) ? tmp2 : tmp2; +# endif + tmp4 = (x[1]*tmp2 + x[2]*tmp3); tmp4 = tmp4*tmp4; + fjac[i + ldfjac*0] = -1.; + fjac[i + ldfjac*1] = tmp1*tmp2/tmp4; + fjac[i + ldfjac*2] = tmp1*tmp3/tmp4; + } +# ifdef BOX_CONSTRAINTS + for (j = 0; j < 3; ++j) { + for (i=0; i < 15; ++i) { + fjac[i + ldfjac*j] *= jacfac[j]; + } + } +# endif + } + return 0; +} diff --git a/recipes/cminpack/all/test_v1_package/CMakeLists.txt b/recipes/cminpack/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..124290cb0ab4b --- /dev/null +++ b/recipes/cminpack/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.1.2) +project(CMinPack-ConanV1-TestPackage C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(CMinpack REQUIRED CONFIG) + +# This builds one of the original cminpack examples against +# both types of the library + +add_executable(cminpack_test_double ../test_package/tchkderc.c) +target_link_libraries(cminpack_test_double PRIVATE cminpack::cminpack) + +add_executable(cminpack_test_float ../test_package/tchkderc.c) +target_link_libraries(cminpack_test_float PRIVATE cminpack::cminpacks) diff --git a/recipes/cminpack/all/test_v1_package/conanfile.py b/recipes/cminpack/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..0cdc195d14862 --- /dev/null +++ b/recipes/cminpack/all/test_v1_package/conanfile.py @@ -0,0 +1,21 @@ +import os + +from conan.tools.build import cross_building +from conans import ConanFile, CMake + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "cminpack_test_double") + self.run(bin_path, run_environment=True) + bin_path = os.path.join("bin", "cminpack_test_float") + self.run(bin_path, run_environment=True) diff --git a/recipes/cminpack/config.yml b/recipes/cminpack/config.yml new file mode 100644 index 0000000000000..859ab74128907 --- /dev/null +++ b/recipes/cminpack/config.yml @@ -0,0 +1,3 @@ +versions: + "1.3.8": + folder: all diff --git a/recipes/coin-clp/all/conanfile.py b/recipes/coin-clp/all/conanfile.py index 30d83281b8471..39939b551d54c 100644 --- a/recipes/coin-clp/all/conanfile.py +++ b/recipes/coin-clp/all/conanfile.py @@ -1,10 +1,14 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import get, apply_conandata_patches, mkdir, rm, rmdir, rename +from conan.tools.build import cross_building +from conan.tools.scm import Version +from conans import AutoToolsBuildEnvironment, tools from contextlib import contextmanager import os import shutil -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" class CoinClpConan(ConanFile): @@ -60,7 +64,7 @@ def validate(self): if self.settings.os == "Windows" and self.options.shared: raise ConanInvalidConfiguration("coin-clp does not support shared builds on Windows") # FIXME: This issue likely comes from very old autotools versions used to produce configure. - if hasattr(self, "settings_build") and tools.cross_building(self) and self.options.shared: + if hasattr(self, "settings_build") and cross_building(self) and self.options.shared: raise ConanInvalidConfiguration("coin-clp shared not supported yet when cross-building") def build_requirements(self): @@ -69,25 +73,27 @@ def build_requirements(self): self.build_requires("msys2/cci.latest") if self.settings.compiler == "Visual Studio": self.build_requires("automake/1.16.4") + self.build_requires("pkgconf/1.7.4") def source(self): - tools.get(**self.conan_data["sources"][self.version], + get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) @contextmanager def _build_context(self): - if self.settings.compiler == "Visual Studio": - with tools.vcvars(self.settings): - env = { - "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), - "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), - "LD": "{} link -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), - "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), - } - with tools.environment_append(env): - yield - else: - yield + with tools.environment_append({"PKG_CONFIG_PATH": self.install_folder}): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self.settings): + env = { + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "LD": "{} link -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "AR": "{} lib".format(tools.unix_path(self._user_info_build["automake"].ar_lib)), + } + with tools.environment_append(env): + yield + else: + yield def _configure_autotools(self): if self._autotools: @@ -98,14 +104,13 @@ def _configure_autotools(self): configure_args = [ "--enable-shared={}".format(yes_no(self.options.shared)), ] - if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) >= 12: + if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= 12: self._autotools.flags.append("-FS") self._autotools.configure(self._source_subfolder, args=configure_args) return self._autotools def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, os.path.join(self._source_subfolder, "config.sub")) shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, @@ -117,18 +122,18 @@ def build(self): def package(self): self.copy("LICENSE", src=self._source_subfolder, dst="licenses") # Installation script expects include/coin to already exist - tools.mkdir(os.path.join(self.package_folder, "include", "coin")) + mkdir(self, os.path.join(self.package_folder, "include", "coin")) with self._build_context(): autotools = self._configure_autotools() autotools.install(args=["-j1"]) # due to configure generated with old autotools version - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) if self.settings.compiler == "Visual Studio": for l in ("Clp", "ClpSolver", "OsiClp"): - tools.rename(os.path.join(self.package_folder, "lib", "lib{}.a").format(l), - os.path.join(self.package_folder, "lib", "{}.lib").format(l)) + rename(self, os.path.join(self.package_folder, "lib", f"lib{l}.a"), + os.path.join(self.package_folder, "lib", f"{l}.lib")) def package_info(self): self.cpp_info.components["clp"].libs = ["ClpSolver", "Clp"] diff --git a/recipes/coin-utils/all/conanfile.py b/recipes/coin-utils/all/conanfile.py index 5e59a759ee054..43fc93be8d655 100644 --- a/recipes/coin-utils/all/conanfile.py +++ b/recipes/coin-utils/all/conanfile.py @@ -1,10 +1,14 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.files import get, apply_conandata_patches, rm, rmdir, rename +from conan.tools.scm import Version +from conan.tools.microsoft import is_msvc +from conans import AutoToolsBuildEnvironment, tools import contextlib -import os import shutil -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" class CoinUtilsConan(ConanFile): @@ -62,25 +66,25 @@ def validate(self): # FIXME: This issue likely comes from very old autotools versions used to produce configure. # It might be fixed by calling autoreconf, but https://github.com/coin-or-tools/BuildTools # should be packaged and added to build requirements. - if hasattr(self, "settings_build") and tools.cross_building(self) and self.options.shared: + if hasattr(self, "settings_build") and cross_building(self) and self.options.shared: raise ConanInvalidConfiguration("coin-utils shared not supported yet when cross-building") def build_requirements(self): - if self.settings.compiler != "Visual Studio": + if not is_msvc(self): self.build_requires("gnu-config/cci.20201022") if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): self.build_requires("msys2/cci.latest") - if self.settings.compiler == "Visual Studio": + if is_msvc(self): self.build_requires("automake/1.16.4") def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) @contextlib.contextmanager def _build_context(self): - if self.settings.compiler == "Visual Studio": + if is_msvc(self): with tools.vcvars(self): env = { "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), @@ -98,28 +102,27 @@ def _configure_autotools(self): return self._autotools self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) self._autotools.libs = [] - if self.settings.compiler == "Visual Studio": + if is_msvc(self): self._autotools.cxx_flags.append("-EHsc") - if tools.Version(self.settings.compiler.version) >= "12": + if Version(self.settings.compiler.version) >= "12": self._autotools.flags.append("-FS") yes_no = lambda v: "yes" if v else "no" configure_args = [ "--enable-shared={}".format(yes_no(self.options.shared)), "--enable-static={}".format(yes_no(not self.options.shared)), ] - if self.settings.compiler == "Visual Studio": - configure_args.append("--enable-msvc={}".format(self.settings.compiler.runtime)) + if is_msvc(self): + configure_args.append(f"--enable-msvc={self.settings.compiler.runtime}") self._autotools.configure(configure_dir=self._source_subfolder, args=configure_args) return self._autotools def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - if self.settings.compiler != "Visual Studio": + apply_conandata_patches(self) + if not is_msvc(self): shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, - os.path.join(self._source_subfolder, "config.sub")) + f"{self._source_subfolder}/config.sub") shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, - os.path.join(self._source_subfolder, "config.guess")) + f"{self._source_subfolder}/config.guess") with self._build_context(): autotools = self._configure_autotools() autotools.make() @@ -130,17 +133,17 @@ def package(self): autotools = self._configure_autotools() autotools.install(args=["-j1"]) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rm(self, "*.la", f"{self.package_folder}/lib") + rmdir(self, f"{self.package_folder}/lib/pkgconfig") + rmdir(self, f"{self.package_folder}/share") - if self.settings.compiler == "Visual Studio": - os.rename(os.path.join(self.package_folder, "lib", "libCoinUtils.a"), - os.path.join(self.package_folder, "lib", "CoinUtils.lib")) + if is_msvc(self): + rename(self, f"{self.package_folder}/lib/libCoinUtils.a", + f"{self.package_folder}/lib/CoinUtils.lib") def package_info(self): self.cpp_info.libs = ["CoinUtils"] if self.settings.os in ("FreeBSD", "Linux"): self.cpp_info.system_libs = ["m"] - self.cpp_info.includedirs.append(os.path.join("include", "coin")) + self.cpp_info.includedirs.append("include/coin") self.cpp_info.names["pkg_config"] = "coinutils" diff --git a/recipes/daw_json_link/all/conandata.yml b/recipes/daw_json_link/all/conandata.yml index 04b8fabccd439..8866827f93aee 100644 --- a/recipes/daw_json_link/all/conandata.yml +++ b/recipes/daw_json_link/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.0.5": + url: "https://github.com/beached/daw_json_link/archive/v3.0.5.tar.gz" + sha256: "77abe2ca525083d59a1e4e8e9aa1d2633e5382d98a0d5d838cd2379eaf8d7edf" "3.0.4": url: "https://github.com/beached/daw_json_link/archive/v3.0.4.tar.gz" sha256: "bf45d116d96337b37b31daa4031ba05beb2579693dd1115bf70b15420e1905a7" diff --git a/recipes/daw_json_link/config.yml b/recipes/daw_json_link/config.yml index 58c380f6dfc1c..5a6f25ed87d19 100644 --- a/recipes/daw_json_link/config.yml +++ b/recipes/daw_json_link/config.yml @@ -1,4 +1,6 @@ versions: + "3.0.5": + folder: "all" "3.0.4": folder: "all" "3.0.1": diff --git a/recipes/inja/all/conandata.yml b/recipes/inja/all/conandata.yml index 8990c2d0c03a7..31e508b43a016 100644 --- a/recipes/inja/all/conandata.yml +++ b/recipes/inja/all/conandata.yml @@ -1,13 +1,13 @@ sources: - 3.0.0: - sha256: 99cdb0d90ab1adff9ec63b40a867ec14e1b217fe2d7ac07a6124de201de4ffd0 - url: https://github.com/pantor/inja/archive/v3.0.0.tar.gz - 3.1.0: - sha256: f4210493e7e3c62d3050ca6e5e9dd72823ec4125a469fa9b28519d7f32fc9731 - url: https://github.com/pantor/inja/archive/v3.1.0.tar.gz - 3.2.0: - sha256: 825e1f0076504b5aac99cc9ad8c4cbfdc33e57c06c40353f2d7b93a33caae17d - url: https://github.com/pantor/inja/archive/v3.2.0.tar.gz "3.3.0": url: "https://github.com/pantor/inja/archive/v3.3.0.tar.gz" sha256: "e628d994762dcdaa9a97f63a9b8b73d9af51af0ffa5acea6bdbba0aceaf8ee25" + "3.2.0": + url: "https://github.com/pantor/inja/archive/v3.2.0.tar.gz" + sha256: "825e1f0076504b5aac99cc9ad8c4cbfdc33e57c06c40353f2d7b93a33caae17d" + "3.1.0": + url: "https://github.com/pantor/inja/archive/v3.1.0.tar.gz" + sha256: "f4210493e7e3c62d3050ca6e5e9dd72823ec4125a469fa9b28519d7f32fc9731" + "3.0.0": + url: "https://github.com/pantor/inja/archive/v3.0.0.tar.gz" + sha256: "99cdb0d90ab1adff9ec63b40a867ec14e1b217fe2d7ac07a6124de201de4ffd0" diff --git a/recipes/inja/all/conanfile.py b/recipes/inja/all/conanfile.py index bdf98d5eac8c1..ef0c873020773 100644 --- a/recipes/inja/all/conanfile.py +++ b/recipes/inja/all/conanfile.py @@ -1,7 +1,11 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -from conans import ConanFile, tools -required_conan_version = ">=1.28.0" +required_conan_version = ">=1.50.0" + class InjaConan(ConanFile): name = "inja" @@ -9,33 +13,52 @@ class InjaConan(ConanFile): homepage = "https://github.com/pantor/inja" url = "https://github.com/conan-io/conan-center-index" description = "Inja is a template engine for modern C++, loosely inspired by jinja for python" - topics = ("conan", "jinja2", "string templates", "templates engine") + topics = ("jinja2", "string templates", "templates engine") + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def requirements(self): - self.requires("nlohmann_json/3.9.1") + self.requires("nlohmann_json/3.11.2") def package_id(self): - self.info.header_only() + self.info.clear() + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 11) + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*.hpp", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "inja") + self.cpp_info.set_property("cmake_target_name", "pantor::inja") + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + + # TODO: to remove in conan v2 once legacy generators removed self.cpp_info.filenames["cmake_find_package"] = "inja" self.cpp_info.filenames["cmake_find_package_multi"] = "inja" self.cpp_info.names["cmake_find_package"] = "pantor" self.cpp_info.names["cmake_find_package_multi"] = "pantor" self.cpp_info.components["libinja"].names["cmake_find_package"] = "inja" self.cpp_info.components["libinja"].names["cmake_find_package_multi"] = "inja" + self.cpp_info.components["libinja"].set_property("cmake_target_name", "pantor::inja") self.cpp_info.components["libinja"].requires = ["nlohmann_json::nlohmann_json"] + self.cpp_info.components["libinja"].bindirs = [] + self.cpp_info.components["libinja"].frameworkdirs = [] + self.cpp_info.components["libinja"].libdirs = [] + self.cpp_info.components["libinja"].resdirs = [] diff --git a/recipes/inja/all/test_package/CMakeLists.txt b/recipes/inja/all/test_package/CMakeLists.txt index a260e6888ede7..e938e7d47ed20 100644 --- a/recipes/inja/all/test_package/CMakeLists.txt +++ b/recipes/inja/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(inja REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} pantor::inja) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE pantor::inja) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/inja/all/test_package/conanfile.py b/recipes/inja/all/test_package/conanfile.py index 6c9d5dba712c7..d120a992c06a6 100644 --- a/recipes/inja/all/test_package/conanfile.py +++ b/recipes/inja/all/test_package/conanfile.py @@ -1,9 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -11,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/inja/all/test_v1_package/CMakeLists.txt b/recipes/inja/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..91d516c3ec515 --- /dev/null +++ b/recipes/inja/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(inja REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE pantor::inja) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/inja/all/test_v1_package/conanfile.py b/recipes/inja/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/inja/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/inja/config.yml b/recipes/inja/config.yml index e2518687da83f..8b57847852970 100644 --- a/recipes/inja/config.yml +++ b/recipes/inja/config.yml @@ -1,9 +1,9 @@ versions: - 3.0.0: + "3.3.0": folder: all - 3.1.0: + "3.2.0": folder: all - 3.2.0: + "3.1.0": folder: all - "3.3.0": + "3.0.0": folder: all diff --git a/recipes/ittapi/all/conandata.yml b/recipes/ittapi/all/conandata.yml new file mode 100644 index 0000000000000..fe25f2187adf4 --- /dev/null +++ b/recipes/ittapi/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.23.0": + url: "https://github.com/intel/ittapi/archive/v3.23.0.tar.gz" + sha256: "9af1231808c602c2f7a66924c8798b1741d3aa4b15f3874d82ca7a89b5dbb1b1" diff --git a/recipes/ittapi/all/conanfile.py b/recipes/ittapi/all/conanfile.py new file mode 100644 index 0000000000000..dc49d467bcae0 --- /dev/null +++ b/recipes/ittapi/all/conanfile.py @@ -0,0 +1,85 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, replace_in_file +import os + +required_conan_version = ">=1.47.0" + + +class IttApiConan(ConanFile): + name = "ittapi" + license = ("BSD-3-Clause", "GPL-2.0-only") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/intel/ittapi" + description = ( + "The Instrumentation and Tracing Technology (ITT) API enables your application" + " to generate and control the collection of trace data during its execution" + " across different Intel tools." + ) + topics = ("itt", "ittapi", "vtune", "profiler", "profiling") + + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + "ptmark": [True, False], + } + default_options = { + "fPIC": True, + "ptmark": False, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + # We have no C++ files, so we delete unused options. + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def _patch_sources(self): + # Don't force PIC + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -fPIC\")", + "" + ) + + def generate(self): + self._patch_sources() + toolchain = CMakeToolchain(self) + toolchain.variables["ITT_API_IPT_SUPPORT"] = self.options.ptmark + toolchain.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + if self.settings.os == "Windows": + copy(self, "libittnotify.lib", src=f"bin/{self.settings.build_type}", dst=os.path.join(self.package_folder, "lib")) + else: + copy(self, "libittnotify.a", src="bin", dst=os.path.join(self.package_folder, "lib")) + copy(self, "*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "BSD-3-Clause.txt", src=os.path.join(self.source_folder, "LICENSES"), dst=os.path.join(self.package_folder, "licenses")) + copy(self, "GPL-2.0-only.txt", src=os.path.join(self.source_folder, "LICENSES"), dst=os.path.join(self.package_folder, "licenses")) + + def package_info(self): + if self.settings.os == "Windows": + self.cpp_info.libs = ['libittnotify'] + else: + self.cpp_info.libs = ['ittnotify'] + self.cpp_info.system_libs = ['dl'] diff --git a/recipes/ittapi/all/test_package/CMakeLists.txt b/recipes/ittapi/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ac9d09057495e --- /dev/null +++ b/recipes/ittapi/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +find_package(ittapi REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ittapi::ittapi) diff --git a/recipes/ittapi/all/test_package/conanfile.py b/recipes/ittapi/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/ittapi/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + 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.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/ittapi/all/test_package/test_package.cpp b/recipes/ittapi/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..630124964c151 --- /dev/null +++ b/recipes/ittapi/all/test_package/test_package.cpp @@ -0,0 +1,14 @@ +#include +#include + +// @note Domains cannot be destroyed. +__itt_domain* itt_domain = __itt_domain_create("Global Domain"); + +int main(){ + __itt_string_handle* nameHandle = __itt_string_handle_create("My name"); + __itt_task_begin(itt_domain, __itt_null, __itt_null, nameHandle); + std::cout << "Inside ITT range." << std::endl; + __itt_task_end(itt_domain); + + return 0; +} diff --git a/recipes/ittapi/all/test_v1_package/CMakeLists.txt b/recipes/ittapi/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..bb7640b6417bb --- /dev/null +++ b/recipes/ittapi/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ittapi REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ittapi::ittapi) diff --git a/recipes/ittapi/all/test_v1_package/conanfile.py b/recipes/ittapi/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/recipes/ittapi/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/ittapi/config.yml b/recipes/ittapi/config.yml new file mode 100644 index 0000000000000..c34864bd34f7f --- /dev/null +++ b/recipes/ittapi/config.yml @@ -0,0 +1,3 @@ +versions: + "3.23.0": + folder: all diff --git a/recipes/jungle/all/CMakeLists.txt b/recipes/jungle/all/CMakeLists.txt new file mode 100644 index 0000000000000..d2b01e47d9d63 --- /dev/null +++ b/recipes/jungle/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.11) +project(jungle) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory("source_subfolder") diff --git a/recipes/jungle/all/conandata.yml b/recipes/jungle/all/conandata.yml new file mode 100644 index 0000000000000..66bd8466456e1 --- /dev/null +++ b/recipes/jungle/all/conandata.yml @@ -0,0 +1,21 @@ +sources: + "cci.20220801": + url: "https://github.com/eBay/Jungle/archive/f41b7123489f1bc942a6b76dc54485391485cd27.tar.gz" + sha256: 8667a114bcef661b2a93e627a68b0584931f182dc8b96693ce6901d903584ab8 +patches: + "cci.20220801": + - patch_file: "patches/0001-cmake-alterations.patch" + patch_description: "CMake dependency discovery outside subtree." + patch_type: "conan" + base_path: "source_subfolder" + sha256: "a7111a290e145717ae0cbdace9866db69c70782731c8568a806f8579e30759eb" + - patch_file: "patches/0002-forestdb-path.patch" + patch_description: "Update include macros for ForestDB headers." + patch_type: "conan" + base_path: "source_subfolder" + sha256: "84ec45a312c52e2fa8cb7ab615aaa11088f24dcb4e4b880340b46c2763900d6b" + - patch_file: "patches/0003-stdatomic.patch" + patch_description: "Include std::atomic from all compilers." + patch_type: "portability" + base_path: "source_subfolder" + sha256: "3ca66676f89e2425255eeb15bf18a77ae21c4f383124013bd6d1cb660cbc1544" diff --git a/recipes/jungle/all/conanfile.py b/recipes/jungle/all/conanfile.py new file mode 100644 index 0000000000000..5350d8f70668d --- /dev/null +++ b/recipes/jungle/all/conanfile.py @@ -0,0 +1,76 @@ +from os.path import join +from conan import ConanFile +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.build import check_min_cppstd +from conans import CMake + +required_conan_version = ">=1.50.0" + +class JungleConan(ConanFile): + name = "jungle" + homepage = "https://github.com/eBay/Jungle" + description = "Key-value storage library, based on a combined index of LSM-tree and copy-on-write B+tree" + topics = ("kv-store", "cow") + url = "https://github.com/conan-io/conan-center-index" + license = "Apache-2.0" + + settings = "os", "arch", "compiler", "build_type" + + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "cmake", "cmake_find_package" + + @property + def _source_subfolder(self): + return "source_subfolder" + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch_file in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch_file["patch_file"]) + + def requirements(self): + self.requires("forestdb/cci.20220727") + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + src_dir = join(self.source_folder, self._source_subfolder) + copy(self, "LICENSE*", src_dir, join(self.package_folder, "licenses")) + + hdr_src = join(src_dir, "include") + copy(self, "*.h", hdr_src, join(self.package_folder, "include"), keep_path=True) + + lib_dir = join(self.package_folder, "lib") + copy(self, "*.a", self.build_folder, lib_dir, keep_path=False) + copy(self, "*.lib", self.build_folder, lib_dir, keep_path=False) + copy(self, "*.so*", self.build_folder, lib_dir, keep_path=False) + copy(self, "*.dylib*", self.build_folder, lib_dir, keep_path=False) + copy(self, "*.dll*", self.build_folder, join(self.package_folder, "bin"), keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["jungle"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["pthread", "dl"]) diff --git a/recipes/jungle/all/patches/0001-cmake-alterations.patch b/recipes/jungle/all/patches/0001-cmake-alterations.patch new file mode 100644 index 0000000000000..77f5f46560539 --- /dev/null +++ b/recipes/jungle/all/patches/0001-cmake-alterations.patch @@ -0,0 +1,52 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -100,7 +100,8 @@ if (TESTSUITE_NO_COLOR GREATER 0) + add_definitions(-DTESTSUITE_NO_COLOR=1) + endif() + +-file(COPY ${CMAKE_SOURCE_DIR}/scripts/runtests.sh ++find_package(forestdb REQUIRED) ++file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/scripts/runtests.sh + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + + # === CUSTOM LOGGER === +@@ -187,16 +191,16 @@ set(JUNGLE_DEPS + ${LIBDL}) + + add_library(static_lib ${JUNGLE_CORE}) +-target_link_libraries(static_lib ${JUNGLE_DEPS}) ++target_link_libraries(static_lib forestdb::forestdb) + set_target_properties(static_lib PROPERTIES OUTPUT_NAME jungle + CLEAN_DIRECT_OUTPUT 1) + if (DETACH_LOGGER GREATER 0) + add_dependencies(static_lib simplelogger_lib) + endif () + +-add_subdirectory("${PROJECT_SOURCE_DIR}/examples") ++#add_subdirectory("${PROJECT_SOURCE_DIR}/examples") +-add_subdirectory("${PROJECT_SOURCE_DIR}/tests") ++#add_subdirectory("${PROJECT_SOURCE_DIR}/tests") +-add_subdirectory("${PROJECT_SOURCE_DIR}/tools") ++#add_subdirectory("${PROJECT_SOURCE_DIR}/tools") + + if (CODE_COVERAGE GREATER 0) + SETUP_TARGET_FOR_COVERAGE( +--- a/tests/CMakeLists.txt ++++ b/tests/CMakeLists.txt +@@ -1,14 +1,11 @@ + set(TEST_DIR ${PROJECT_SOURCE_DIR}/tests) + set(UNIT_TEST_DIR ${TEST_DIR}/unit) + set(JUNGLE_TEST_DIR ${TEST_DIR}/jungle) + set(STRESS_TEST_DIR ${TEST_DIR}/stress) + + set(JUNGLE_TEST_DEPS +- ${CMAKE_CURRENT_BINARY_DIR}/../libjungle.a +- ${LIBSIMPLELOGGER} +- ${FDB_LIB_DIR}/libforestdb.a +- ${LIBSNAPPY} +- ${LIBDL}) ++ static_lib ++ forestdb::forestdb) + + set(FILEOPS_TEST ${TEST_DIR}/unit/fileops_test.cc) + add_executable(fileops_test ${FILEOPS_TEST}) diff --git a/recipes/jungle/all/patches/0002-forestdb-path.patch b/recipes/jungle/all/patches/0002-forestdb-path.patch new file mode 100644 index 0000000000000..547b2635d3042 --- /dev/null +++ b/recipes/jungle/all/patches/0002-forestdb-path.patch @@ -0,0 +1,62 @@ +diff --git a/src/cmd_handler.cc b/src/cmd_handler.cc +index 12cf591..14c42b4 100644 +--- a/src/cmd_handler.cc ++++ b/src/cmd_handler.cc +@@ -22,7 +22,7 @@ limitations under the License. + #include "skiplist.h" + #include "table_mgr.h" + +-#include ++#include + + #include + #include +diff --git a/src/table_file.cc b/src/table_file.cc +index 69ca237..80c7648 100644 +--- a/src/table_file.cc ++++ b/src/table_file.cc +@@ -21,7 +21,7 @@ limitations under the License. + #include "internal_helper.h" + #include "table_mgr.h" + +-#include ++#include + + #include _MACRO_TO_STR(LOGGER_H) + +diff --git a/src/table_file.h b/src/table_file.h +index ab7a29d..fd4bc4c 100644 +--- a/src/table_file.h ++++ b/src/table_file.h +@@ -21,7 +21,7 @@ limitations under the License. + #include "table_lookup_booster.h" + + #include +-#include ++#include + + #include + #include +@@ -450,4 +450,3 @@ private: + + + } // namespace jungle +- +--- a/tests/jungle/builder_test.cc ++++ b/tests/jungle/builder_test.cc +@@ -16,7 +16,7 @@ limitations under the License. + + #include "jungle_test_common.h" + +-#include "jungle_builder.h" ++#include "tools/jungle_builder.h" + #include "libjungle/iterator.h" + #include "libjungle/jungle.h" + #include "libjungle/sized_buf.h" +@@ -275,4 +275,4 @@ int main(int argc, char** argv) { + ts.doTest("build an empty db test", build_an_empty_db_test); + + return 0; +-} +\ No newline at end of file ++} diff --git a/recipes/jungle/all/patches/0003-stdatomic.patch b/recipes/jungle/all/patches/0003-stdatomic.patch new file mode 100644 index 0000000000000..f56b9cb06270b --- /dev/null +++ b/recipes/jungle/all/patches/0003-stdatomic.patch @@ -0,0 +1,13 @@ +diff --git a/src/skiplist.h b/src/skiplist.h +index 15f5fb7..5c24461 100644 +--- a/src/skiplist.h ++++ b/src/skiplist.h +@@ -29,7 +29,7 @@ limitations under the License. + struct _skiplist_node; + + //#define _STL_ATOMIC (1) +-#ifdef __APPLE__ ++#if __has_include() + #define _STL_ATOMIC (1) + #endif + #if defined(_STL_ATOMIC) && defined(__cplusplus) diff --git a/recipes/jungle/all/test_package/CMakeLists.txt b/recipes/jungle/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..354670d11c755 --- /dev/null +++ b/recipes/jungle/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.11) +set(CMAKE_CXX_STANDARD 11) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(jungle CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} jungle::jungle) diff --git a/recipes/jungle/all/test_package/conanfile.py b/recipes/jungle/all/test_package/conanfile.py new file mode 100644 index 0000000000000..9ebf26743f34b --- /dev/null +++ b/recipes/jungle/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile +from conan.tools.build import cross_building +from conans import CMake +import os + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/jungle/all/test_package/test_package.cpp b/recipes/jungle/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..756f927a89ccd --- /dev/null +++ b/recipes/jungle/all/test_package/test_package.cpp @@ -0,0 +1,17 @@ +#include + +#include +#include + +int main(void) { + jungle::DB *dbInst; + jungle::Status s; + jungle::DBConfig db_config; + + s = jungle::DB::open(&dbInst, ".", db_config); + + assert(s.ok()); + + std::cout << "Success\n"; + return 0; +} diff --git a/recipes/jungle/config.yml b/recipes/jungle/config.yml new file mode 100644 index 0000000000000..2499184dd3f4b --- /dev/null +++ b/recipes/jungle/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20220801": + folder: all diff --git a/recipes/libalsa/all/conandata.yml b/recipes/libalsa/all/conandata.yml index 557a8def6ac72..55a14a6d4051e 100644 --- a/recipes/libalsa/all/conandata.yml +++ b/recipes/libalsa/all/conandata.yml @@ -20,4 +20,3 @@ sources: patches: "1.2.5.1": - patch_file: "patches/1.2.5.1-0001-control-empty-fix-the-static-build.patch" - base_path: "source_subfolder" diff --git a/recipes/libalsa/all/conanfile.py b/recipes/libalsa/all/conanfile.py index 90f0a8ce07549..cac0714be412f 100644 --- a/recipes/libalsa/all/conanfile.py +++ b/recipes/libalsa/all/conanfile.py @@ -1,8 +1,13 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, chdir, copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.layout import basic_layout +from conan.tools.microsoft import unix_path import os -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" class LibalsaConan(ConanFile): @@ -14,7 +19,7 @@ class LibalsaConan(ConanFile): description = "Library of ALSA: The Advanced Linux Sound Architecture, that provides audio " \ "and MIDI functionality to the Linux operating system" - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -26,65 +31,63 @@ class LibalsaConan(ConanFile): "disable_python": True, } - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" - def export_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass def validate(self): if self.settings.os != "Linux": raise ConanInvalidConfiguration("Only Linux supported") def build_requirements(self): - self.build_requires("libtool/2.4.6") + self.tool_requires("libtool/2.4.7") - def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + def layout(self): + basic_layout(self, src_folder="src") - def _configure_autotools(self): - if self._autotools: - return self._autotools + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - self._autotools = AutoToolsBuildEnvironment(self) + def generate(self): + tc = AutotoolsToolchain(self) yes_no = lambda v: "yes" if v else "no" - args = [ - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), - "--enable-python={}".format(yes_no(not self.options.disable_python)), - "--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), - ] - self._autotools.configure(args=args) - return self._autotools + tc.configure_args.extend([ + f"--enable-python={yes_no(not self.options.disable_python)}", + "--datarootdir=${prefix}/res", + "--datadir=${prefix}/res", + ]) + tc.generate() + env = VirtualBuildEnv(self) + env.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - with tools.chdir(self._source_subfolder): - self.run("{} -fiv".format(tools.get_env("AUTORECONF")), run_environment=True) - - autotools = self._configure_autotools() + apply_conandata_patches(self) + with chdir(self, self.source_folder): + autotools = Autotools(self) + autotools.autoreconf() + autotools.configure() autotools.make() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - with tools.chdir(self._source_subfolder): - autotools = self._configure_autotools() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + with chdir(self, self.source_folder): + autotools = Autotools(self) autotools.install() - - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") diff --git a/recipes/libalsa/all/test_package/CMakeLists.txt b/recipes/libalsa/all/test_package/CMakeLists.txt index 1e5d2aef6483b..ab0ad880535ac 100644 --- a/recipes/libalsa/all/test_package/CMakeLists.txt +++ b/recipes/libalsa/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(ALSA REQUIRED) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ALSA::ALSA) +target_link_libraries(${PROJECT_NAME} PRIVATE ALSA::ALSA) diff --git a/recipes/libalsa/all/test_package/conanfile.py b/recipes/libalsa/all/test_package/conanfile.py index 19e6a0c06e3d8..d120a992c06a6 100644 --- a/recipes/libalsa/all/test_package/conanfile.py +++ b/recipes/libalsa/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libalsa/all/test_v1_package/CMakeLists.txt b/recipes/libalsa/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..690e8d6667c90 --- /dev/null +++ b/recipes/libalsa/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(ALSA REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE ALSA::ALSA) diff --git a/recipes/libalsa/all/test_v1_package/conanfile.py b/recipes/libalsa/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/libalsa/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libaom-av1/all/CMakeLists.txt b/recipes/libaom-av1/all/CMakeLists.txt deleted file mode 100644 index 7a91e5788197d..0000000000000 --- a/recipes/libaom-av1/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include("conanbuildinfo.cmake") -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory("source_subfolder") diff --git a/recipes/libaom-av1/all/conandata.yml b/recipes/libaom-av1/all/conandata.yml index 3bd6ed7f5ae32..a658972bada52 100644 --- a/recipes/libaom-av1/all/conandata.yml +++ b/recipes/libaom-av1/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.4.0": + url: "https://storage.googleapis.com/aom-releases/libaom-3.4.0.tar.gz" + sha256: "bd754b58c3fa69f3ffd29da77de591bd9c26970e3b18537951336d6c0252e354" "3.3.0": url: "https://storage.googleapis.com/aom-releases/libaom-3.3.0.tar.gz" sha256: "1dafde32bc2237bf0570294661ae61db30e818840f77dc4e90d1ebf5a6286664" @@ -12,15 +15,13 @@ sources: url: "https://storage.googleapis.com/aom-releases/libaom-2.0.1.tar.gz" sha256: "a0cff299621e2ef885aba219c498fa39a7d9a7ddf47585a118fd66c64ad1b312" patches: + "3.4.0": + - patch_file: "patches/0001-3.4.0-fix-install.patch" "3.3.0": - patch_file: "patches/0001-3.3.0-fix-install.patch" - base_path: "source_subfolder" "3.1.2": - patch_file: "patches/0001-3.1.1-fix-install.patch" - base_path: "source_subfolder" "3.1.1": - patch_file: "patches/0001-3.1.1-fix-install.patch" - base_path: "source_subfolder" "2.0.1": - patch_file: "patches/0001-2.0.1-fix-install.patch" - base_path: "source_subfolder" diff --git a/recipes/libaom-av1/all/conanfile.py b/recipes/libaom-av1/all/conanfile.py index 34cbb96c69c33..e7216a0f083aa 100644 --- a/recipes/libaom-av1/all/conanfile.py +++ b/recipes/libaom-av1/all/conanfile.py @@ -1,9 +1,11 @@ -from conans import ConanFile, tools, CMake -from conans.errors import ConanInvalidConfiguration -import functools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version import os -required_conan_version = ">=1.36.0" +required_conan_version = ">=1.47.0" class LibaomAv1Conan(ConanFile): @@ -26,24 +28,13 @@ class LibaomAv1Conan(ConanFile): "assembly": False, } - generators = "cmake" - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - @property def _settings_build(self): return getattr(self, "settings_build", self.settings) def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -54,72 +45,62 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass def build_requirements(self): if self.options.get_safe("assembly", False): - self.build_requires("nasm/2.15.05") + self.tool_requires("nasm/2.15.05") if self._settings_build.os == "Windows": - self.build_requires("strawberryperl/5.30.0.1") - - def validate(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) - # Check compiler version - compiler = str(self.settings.compiler) - compiler_version = tools.Version(self.settings.compiler.version.value) + self.tool_requires("strawberryperl/5.30.0.1") - minimal_version = { - "Visual Studio": "15", - "gcc": "5", - "clang": "5", - "apple-clang": "6" - } - if compiler not in minimal_version: - self.output.warn( - "%s recipe lacks information about the %s compiler standard version support" % (self.name, compiler)) - elif compiler_version < minimal_version[compiler]: - raise ConanInvalidConfiguration("{} requires a {} version >= {}".format(self.name, compiler, compiler_version)) + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, - strip_root=tools.Version(self.version) >= "3.3.0") - - @functools.lru_cache(1) - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["ENABLE_EXAMPLES"] = False - cmake.definitions["ENABLE_TESTS"] = False - cmake.definitions["ENABLE_DOCS"] = False - cmake.definitions["ENABLE_TOOLS"] = False + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=Version(self.version) >= "3.3.0") + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ENABLE_EXAMPLES"] = False + tc.variables["ENABLE_TESTS"] = False + tc.variables["ENABLE_DOCS"] = False + tc.variables["ENABLE_TOOLS"] = False if not self.options.get_safe("assembly", False): # make non-assembly build - cmake.definitions["AOM_TARGET_CPU"] = "generic" + tc.variables["AOM_TARGET_CPU"] = "generic" # libyuv is used for examples, tests and non-essential 'dump_obu' tool so it is disabled # required to be 1/0 instead of False - cmake.definitions["CONFIG_LIBYUV"] = 0 + tc.variables["CONFIG_LIBYUV"] = 0 # webm is not yet packaged - cmake.definitions["CONFIG_WEBM_IO"] = 0 - # required out-of-source build - cmake.configure(build_folder=self._build_subfolder) - return cmake + tc.variables["CONFIG_WEBM_IO"] = 0 + # Requires C99 or higher + tc.variables["CMAKE_C_STANDARD"] = "99" + tc.generate() + env = VirtualBuildEnv(self) + env.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + 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", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): self.cpp_info.set_property("pkg_config_name", "aom") self.cpp_info.libs = ["aom"] if self.settings.os in ("FreeBSD", "Linux"): self.cpp_info.system_libs = ["pthread", "m"] - - self.cpp_info.names["pkg_config"] = "aom" diff --git a/recipes/libaom-av1/all/patches/0001-3.4.0-fix-install.patch b/recipes/libaom-av1/all/patches/0001-3.4.0-fix-install.patch new file mode 100644 index 0000000000000..cdf8395c587c8 --- /dev/null +++ b/recipes/libaom-av1/all/patches/0001-3.4.0-fix-install.patch @@ -0,0 +1,21 @@ +--- a/build/cmake/aom_install.cmake ++++ b/build/cmake/aom_install.cmake +@@ -27,7 +27,7 @@ endif() + # Note: aom.pc generation uses GNUInstallDirs: + # https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html + macro(setup_aom_install_targets) +- if(NOT XCODE) ++ if(1) + include("GNUInstallDirs") + set(AOM_PKG_CONFIG_FILE "${AOM_CONFIG_DIR}/aom.pc") + +@@ -78,7 +78,8 @@ macro(setup_aom_install_targets) + endif() + + if(BUILD_SHARED_LIBS) +- set(AOM_INSTALL_LIBS aom aom_static) ++ set_target_properties(aom_static PROPERTIES OUTPUT_NAME aom_static) ++ set(AOM_INSTALL_LIBS aom) + else() + set(AOM_INSTALL_LIBS aom) + endif() diff --git a/recipes/libaom-av1/all/test_package/CMakeLists.txt b/recipes/libaom-av1/all/test_package/CMakeLists.txt index 23fdbf257623a..f5305ced8fb6c 100644 --- a/recipes/libaom-av1/all/test_package/CMakeLists.txt +++ b/recipes/libaom-av1/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(libaom-av1 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} libaom-av1::libaom-av1) +target_link_libraries(${PROJECT_NAME} PRIVATE libaom-av1::libaom-av1) diff --git a/recipes/libaom-av1/all/test_package/conanfile.py b/recipes/libaom-av1/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/libaom-av1/all/test_package/conanfile.py +++ b/recipes/libaom-av1/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libaom-av1/all/test_v1_package/CMakeLists.txt b/recipes/libaom-av1/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0041c8b205193 --- /dev/null +++ b/recipes/libaom-av1/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libaom-av1 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libaom-av1::libaom-av1) diff --git a/recipes/libaom-av1/all/test_v1_package/conanfile.py b/recipes/libaom-av1/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libaom-av1/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libaom-av1/config.yml b/recipes/libaom-av1/config.yml index f8672e68656da..e66c6b859cddf 100644 --- a/recipes/libaom-av1/config.yml +++ b/recipes/libaom-av1/config.yml @@ -1,4 +1,6 @@ versions: + "3.4.0": + folder: all "3.3.0": folder: all "3.1.2": diff --git a/recipes/libcurl/all/conanfile.py b/recipes/libcurl/all/conanfile.py index b802482b5ae21..5d90d94f7a857 100644 --- a/recipes/libcurl/all/conanfile.py +++ b/recipes/libcurl/all/conanfile.py @@ -3,19 +3,23 @@ import re import functools from conans import ConanFile, AutoToolsBuildEnvironment, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan.errors import ConanInvalidConfiguration from conan.tools.microsoft import is_msvc from conan.tools.build import cross_building +from conan.tools.scm import Version +from conan.tools.files import replace_in_file, rmdir, chdir, get, download, save, load, apply_conandata_patches +from conan.tools.apple import is_apple_os -required_conan_version = ">=1.45.0" + +required_conan_version = ">=1.51.3" class LibcurlConan(ConanFile): name = "libcurl" description = "command line tool and library for transferring data with URLs" - license = "MIT" + license = "curl" url = "https://github.com/conan-io/conan-center-index" - homepage = "https://curl.haxx.se" + homepage = "https://curl.se" topics = ("curl", "data-transfer", "ftp", "gopher", "http", "imap", "ldap", "mqtt", "pop3", "rtmp", "rtsp", "scp", "sftp", "smb", "smtp", "telnet", "tftp") @@ -136,12 +140,12 @@ def _is_using_cmake_build(self): @property def _has_zstd_option(self): - return tools.Version(self.version) >= "7.72.0" + return Version(self.version) >= "7.72.0" @property def _has_metalink_option(self): # Support for metalink was removed in version 7.78.0 https://github.com/curl/curl/pull/7176 - return tools.Version(self.version) < "7.78.0" and not self._is_using_cmake_build + return Version(self.version) < "7.78.0" and not self._is_using_cmake_build def export_sources(self): self.copy("CMakeLists.txt") @@ -150,6 +154,8 @@ def export_sources(self): self.copy(patch["patch_file"]) def config_options(self): + if Version(self.version) < "7.10.4": + self.license = "MIT" if self.settings.os == "Windows": del self.options.fPIC if not self._has_zstd_option: @@ -157,7 +163,7 @@ def config_options(self): if not self._has_metalink_option: del self.options.with_libmetalink # Default options - self.options.with_ssl = "darwinssl" if tools.is_apple_os(self.settings.os) else "openssl" + self.options.with_ssl = "darwinssl" if is_apple_os(self) else "openssl" def configure(self): if self.options.shared: @@ -167,7 +173,7 @@ def configure(self): # These options are not used in CMake build yet if self._is_using_cmake_build: - if tools.Version(self.version) < "7.75.0": + if Version(self.version) < "7.75.0": del self.options.with_libidn del self.options.with_libpsl @@ -192,9 +198,9 @@ def requirements(self): def validate(self): if self.options.with_ssl == "schannel" and self.settings.os != "Windows": raise ConanInvalidConfiguration("schannel only suppported on Windows.") - if self.options.with_ssl == "darwinssl" and not tools.is_apple_os(self.settings.os): + if self.options.with_ssl == "darwinssl" and not is_apple_os(self): raise ConanInvalidConfiguration("darwinssl only suppported on Apple like OS (Macos, iOS, watchOS or tvOS).") - if self.options.with_ssl == "wolfssl" and self._is_using_cmake_build and tools.Version(self.version) < "7.70.0": + if self.options.with_ssl == "wolfssl" and self._is_using_cmake_build and Version(self.version) < "7.70.0": raise ConanInvalidConfiguration("Before 7.70.0, libcurl has no wolfssl support for Visual Studio or \"Windows to Android cross compilation\"") if self.options.with_ssl == "openssl": if self.options.with_ntlm and self.options["openssl"].no_des: @@ -203,17 +209,17 @@ def validate(self): def build_requirements(self): if self._is_using_cmake_build: if self._is_win_x_android: - self.build_requires("ninja/1.11.0") + self.tool_requires("ninja/1.11.0") else: - self.build_requires("libtool/2.4.6") - self.build_requires("pkgconf/1.7.4") + self.tool_requires("libtool/2.4.6") + self.tool_requires("pkgconf/1.7.4") if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") + self.tool_requires("msys2/cci.latest") def source(self): - tools.get(**self.conan_data["sources"][self.version], + get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) - tools.download("https://curl.haxx.se/ca/cacert.pem", "cacert.pem", verify=True) + download(self, "https://curl.haxx.se/ca/cacert.pem", "cacert.pem", verify=True) # TODO: remove imports once rpath of shared libs of libcurl dependencies fixed on macOS def imports(self): @@ -235,15 +241,14 @@ def build(self): self._build_with_autotools() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) self._patch_misc_files() self._patch_autotools() self._patch_cmake() def _patch_misc_files(self): if self.options.with_largemaxwritesize: - tools.replace_in_file(os.path.join(self._source_subfolder, "include", "curl", "curl.h"), + replace_in_file(self, os.path.join(self._source_subfolder, "include", "curl", "curl.h"), "define CURL_MAX_WRITE_SIZE 16384", "define CURL_MAX_WRITE_SIZE 10485760") @@ -251,7 +256,7 @@ def _patch_misc_files(self): # for additional info, see this comment https://github.com/conan-io/conan-center-index/pull/1008#discussion_r386122685 if self.settings.compiler == "apple-clang" and self.settings.compiler.version == "9.1": if self.options.with_ssl == "darwinssl": - tools.replace_in_file(os.path.join(self._source_subfolder, "lib", "vtls", "sectransp.c"), + replace_in_file(self, os.path.join(self._source_subfolder, "lib", "vtls", "sectransp.c"), "#define CURL_BUILD_MAC_10_13 MAC_OS_X_VERSION_MAX_ALLOWED >= 101300", "#define CURL_BUILD_MAC_10_13 0") @@ -263,38 +268,38 @@ def _patch_autotools(self): # - link errors if mingw shared or iOS/tvOS/watchOS # - it makes recipe consistent with CMake build where we don't build curl tool top_makefile = os.path.join(self._source_subfolder, "Makefile.am") - tools.replace_in_file(top_makefile, "SUBDIRS = lib src", "SUBDIRS = lib") - tools.replace_in_file(top_makefile, "include src/Makefile.inc", "") + replace_in_file(self, top_makefile, "SUBDIRS = lib src", "SUBDIRS = lib") + replace_in_file(self, top_makefile, "include src/Makefile.inc", "") if self._is_mingw: # patch for zlib naming in mingw if self.options.with_zlib: configure_ac = os.path.join(self._source_subfolder, "configure.ac") zlib_name = self.deps_cpp_info["zlib"].libs[0] - tools.replace_in_file(configure_ac, + replace_in_file(self, configure_ac, "AC_CHECK_LIB(z,", "AC_CHECK_LIB({},".format(zlib_name)) - tools.replace_in_file(configure_ac, + replace_in_file(self, configure_ac, "-lz ", "-l{} ".format(zlib_name)) if self.options.shared: # patch for shared mingw build lib_makefile = os.path.join(self._source_subfolder, "lib", "Makefile.am") - tools.replace_in_file(lib_makefile, + replace_in_file(self, lib_makefile, "noinst_LTLIBRARIES = libcurlu.la", "") - tools.replace_in_file(lib_makefile, + replace_in_file(self, lib_makefile, "noinst_LTLIBRARIES =", "") - tools.replace_in_file(lib_makefile, + replace_in_file(self, lib_makefile, "lib_LTLIBRARIES = libcurl.la", "noinst_LTLIBRARIES = libcurl.la") # add directives to build dll # used only for native mingw-make if not cross_building(self): - added_content = tools.load("lib_Makefile_add.am") - tools.save(lib_makefile, added_content, append=True) + added_content = load(self, "lib_Makefile_add.am") + save(self, lib_makefile, added_content, append=True) def _patch_cmake(self): if not self._is_using_cmake_build: @@ -302,24 +307,24 @@ def _patch_cmake(self): cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") # Custom findZstd.cmake file relies on pkg-config file, make sure that it's consumed on all platforms if self._has_zstd_option: - tools.replace_in_file(os.path.join(self._source_subfolder, "CMake", "FindZstd.cmake"), + replace_in_file(self, os.path.join(self._source_subfolder, "CMake", "FindZstd.cmake"), "if(UNIX)", "if(TRUE)") # TODO: check this patch, it's suspicious - tools.replace_in_file(cmakelists, + replace_in_file(self, cmakelists, "include(CurlSymbolHiding)", "") # libnghttp2 - tools.replace_in_file( + replace_in_file(self, cmakelists, "find_package(NGHTTP2 REQUIRED)", "find_package(libnghttp2 REQUIRED)", ) - tools.replace_in_file( + replace_in_file(self, cmakelists, "include_directories(${NGHTTP2_INCLUDE_DIRS})", "", ) - tools.replace_in_file( + replace_in_file(self, cmakelists, "list(APPEND CURL_LIBS ${NGHTTP2_LIBRARIES})", "list(APPEND CURL_LIBS libnghttp2::nghttp2)", @@ -327,8 +332,8 @@ def _patch_cmake(self): # INTERFACE_LIBRARY (generated by the cmake_find_package generator) targets doesn't have the LOCATION property. # So skipp the LOCATION check in the CMakeLists.txt - if tools.Version(self.version) >= "7.80.0": - tools.replace_in_file( + if Version(self.version) >= "7.80.0": + replace_in_file(self, cmakelists, 'get_target_property(_lib "${_libname}" LOCATION)', """get_target_property(_type "${_libname}" TYPE) @@ -415,7 +420,7 @@ def _get_configure_command_args(self): # ntlm will default to enabled if any SSL options are enabled if not self.options.with_ntlm: - if tools.Version(self.version) <= "7.77.0": + if Version(self.version) <= "7.77.0": params.append("--disable-crypto-auth") else: params.append("--disable-ntlm") @@ -468,13 +473,13 @@ def _arm_version(self, arch): return version def _build_with_autotools(self): - with tools.chdir(self._source_subfolder): + with chdir(self, self._source_subfolder): # autoreconf self.run("{} -fiv".format(tools.get_env("AUTORECONF") or "autoreconf"), win_bash=tools.os_info.is_windows, run_environment=True) # fix generated autotools files to have relocatable binaries - if tools.is_apple_os(self.settings.os): - tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name @rpath/") + if is_apple_os(self): + replace_in_file(self, "configure", "-install_name \\$rpath/", "-install_name @rpath/") self.run("chmod +x configure") @@ -507,7 +512,7 @@ def _configure_autotools(self): if self._is_mingw: autotools.defines.append("_AMD64_") - if cross_building(self) and tools.is_apple_os(self.settings.os): + if cross_building(self) and is_apple_os(self): autotools.defines.extend(['HAVE_SOCKET', 'HAVE_FCNTL_O_NONBLOCK']) configure_args = self._get_configure_command_args() @@ -532,26 +537,26 @@ def _configure_cmake(self): cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared cmake.definitions["CURL_STATICLIB"] = not self.options.shared cmake.definitions["CMAKE_DEBUG_POSTFIX"] = "" - if tools.Version(self.version) >= "7.81.0": + if Version(self.version) >= "7.81.0": cmake.definitions["CURL_USE_SCHANNEL"] = self.options.with_ssl == "schannel" - elif tools.Version(self.version) >= "7.72.0": + elif Version(self.version) >= "7.72.0": cmake.definitions["CMAKE_USE_SCHANNEL"] = self.options.with_ssl == "schannel" else: cmake.definitions["CMAKE_USE_WINSSL"] = self.options.with_ssl == "schannel" - if tools.Version(self.version) >= "7.81.0": + if Version(self.version) >= "7.81.0": cmake.definitions["CURL_USE_OPENSSL"] = self.options.with_ssl == "openssl" else: cmake.definitions["CMAKE_USE_OPENSSL"] = self.options.with_ssl == "openssl" - if tools.Version(self.version) >= "7.81.0": + if Version(self.version) >= "7.81.0": cmake.definitions["CURL_USE_WOLFSSL"] = self.options.with_ssl == "wolfssl" - elif tools.Version(self.version) >= "7.70.0": + elif Version(self.version) >= "7.70.0": cmake.definitions["CMAKE_USE_WOLFSSL"] = self.options.with_ssl == "wolfssl" cmake.definitions["USE_NGHTTP2"] = self.options.with_nghttp2 cmake.definitions["CURL_ZLIB"] = self.options.with_zlib cmake.definitions["CURL_BROTLI"] = self.options.with_brotli if self._has_zstd_option: cmake.definitions["CURL_ZSTD"] = self.options.with_zstd - if tools.Version(self.version) >= "7.81.0": + if Version(self.version) >= "7.81.0": cmake.definitions["CURL_USE_LIBSSH2"] = self.options.with_libssh2 else: cmake.definitions["CMAKE_USE_LIBSSH2"] = self.options.with_libssh2 @@ -560,7 +565,7 @@ def _configure_cmake(self): cmake.definitions["ENABLE_THREADED_RESOLVER"] = self.options.with_threaded_resolver cmake.definitions["CURL_DISABLE_PROXY"] = not self.options.with_proxy cmake.definitions["USE_LIBRTMP"] = self.options.with_librtmp - if tools.Version(self.version) >= "7.75.0": + if Version(self.version) >= "7.75.0": cmake.definitions["USE_LIBIDN2"] = self.options.with_libidn cmake.definitions["CURL_DISABLE_RTSP"] = not self.options.with_rtsp cmake.definitions["CURL_DISABLE_CRYPTO_AUTH"] = not self.options.with_crypto_auth @@ -568,7 +573,7 @@ def _configure_cmake(self): # Also disables NTLM_WB if set to false if not self.options.with_ntlm: - if tools.Version(self.version) <= "7.77.0": + if Version(self.version) <= "7.77.0": cmake.definitions["CURL_DISABLE_CRYPTO_AUTH"] = True else: cmake.definitions["CURL_DISABLE_NTLM"] = True @@ -597,13 +602,13 @@ def package(self): if self._is_using_cmake_build: cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) else: with tools.run_environment(self): - with tools.chdir(self._source_subfolder): + with chdir(self, self._source_subfolder): autotools, autotools_vars = self._configure_autotools() autotools.install(vars=autotools_vars) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "share")) for la_file in glob.glob(os.path.join(self.package_folder, "lib", "*.la")): os.remove(la_file) if self._is_mingw and self.options.shared: @@ -611,7 +616,7 @@ def package(self): self.copy(pattern="*.dll", dst="bin", keep_path=False) self.copy(pattern="*.dll.a", dst="lib", keep_path=False) self.copy(pattern="*.lib", dst="lib", keep_path=False) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): self.cpp_info.set_property("cmake_file_name", "CURL") @@ -638,8 +643,8 @@ def package_info(self): self.cpp_info.components["curl"].system_libs.append("wldap32") if self.options.with_ssl == "schannel": self.cpp_info.components["curl"].system_libs.append("crypt32") - elif tools.is_apple_os(self.settings.os): - if tools.Version(self.version) >= "7.77.0": + elif is_apple_os(self): + if Version(self.version) >= "7.77.0": self.cpp_info.components["curl"].frameworks.append("SystemConfiguration") if self.options.with_ldap: self.cpp_info.components["curl"].system_libs.append("ldap") diff --git a/recipes/libcurl/all/test_package/conanfile.py b/recipes/libcurl/all/test_package/conanfile.py index b52ccfa4d538e..6221e377a7254 100644 --- a/recipes/libcurl/all/test_package/conanfile.py +++ b/recipes/libcurl/all/test_package/conanfile.py @@ -1,4 +1,5 @@ -from conans import ConanFile, CMake, tools +from conans import ConanFile, CMake +from conan.tools.build import cross_building import os import subprocess import re @@ -30,7 +31,7 @@ def _test_executable(self): return os.path.join("bin", "test_package") def test(self): - if not tools.cross_building(self): + if not cross_building(self): self.run(self._test_executable, run_environment=True) else: # We will dump information for the generated executable diff --git a/recipes/libheif/all/CMakeLists.txt b/recipes/libheif/all/CMakeLists.txt deleted file mode 100644 index 68bfd75fb1882..0000000000000 --- a/recipes/libheif/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) -project(cmake_wrapper) - -include("conanbuildinfo.cmake") -conan_basic_setup() - -add_subdirectory("source_subfolder") diff --git a/recipes/libheif/all/conandata.yml b/recipes/libheif/all/conandata.yml index 2252a2b077a47..c5668b6d3c93a 100644 --- a/recipes/libheif/all/conandata.yml +++ b/recipes/libheif/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.13.0": + url: "https://github.com/strukturag/libheif/releases/download/v1.13.0/libheif-1.13.0.tar.gz" + sha256: "c20ae01bace39e89298f6352f1ff4a54b415b33b9743902da798e8a1e51d7ca1" "1.12.0": url: "https://github.com/strukturag/libheif/releases/download/v1.12.0/libheif-1.12.0.tar.gz" sha256: "e1ac2abb354fdc8ccdca71363ebad7503ad731c84022cf460837f0839e171718" @@ -9,12 +12,11 @@ sources: url: "https://github.com/strukturag/libheif/releases/download/v1.9.1/libheif-1.9.1.tar.gz" sha256: "5f65ca2bd2510eed4e13bdca123131c64067e9dd809213d7aef4dc5e37948bca" patches: + "1.13.0": + - patch_file: "patches/0001-cmake_1.13.0.patch" "1.12.0": - - patch_file: "patches/0001-cmake_1.11.0.patch" - base_path: "source_subfolder" + - patch_file: "patches/0001-cmake_1.12.0.patch" "1.11.0": - patch_file: "patches/0001-cmake_1.11.0.patch" - base_path: "source_subfolder" "1.9.1": - patch_file: "patches/0001-cmake-1.9.1.patch" - base_path: "source_subfolder" diff --git a/recipes/libheif/all/conanfile.py b/recipes/libheif/all/conanfile.py index 6ff54cf5dcb33..d70912d7df209 100644 --- a/recipes/libheif/all/conanfile.py +++ b/recipes/libheif/all/conanfile.py @@ -1,10 +1,15 @@ -from conans import ConanFile, tools, CMake +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version +from conans import tools as tools_legacy import os -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" -class Libheif(ConanFile): +class LibheifConan(ConanFile): name = "libheif" description = "libheif is an HEIF and AVIF file format decoder and encoder." topics = ("libheif", "heif", "codec", "video") @@ -16,99 +21,80 @@ class Libheif(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "with_libde265": [True, False], "with_x265": [True, False], - "with_dav1d": [True, False], "with_libaomav1": [True, False], + "with_dav1d": [True, False], } default_options = { "shared": False, "fPIC": True, + "with_libde265": True, "with_x265": False, - "with_dav1d": False, "with_libaomav1": False, + "with_dav1d": False, } - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - if tools.Version(self.version) < "1.11.0": - # dav1d supported since 1.10.0 but usable option `WITH_DAV1D` - # for controlling support exists only since 1.11.0 - del self.options.with_dav1d def configure(self): if self.options.shared: del self.options.fPIC def requirements(self): - self.requires("libde265/1.0.8") + if self.options.with_libde265: + self.requires("libde265/1.0.8") if self.options.with_x265: self.requires("libx265/3.4") if self.options.with_libaomav1: - self.requires("libaom-av1/3.1.2") - if self.options.get_safe("with_dav1d"): - self.requires("dav1d/0.9.1") + self.requires("libaom-av1/3.3.0") + if self.options.with_dav1d: + self.requires("dav1d/1.0.0") def validate(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["WITH_EXAMPLES"] = False - self._cmake.definitions["WITH_RAV1E"] = False - # x265 - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_X265"] = not self.options.with_x265 - self._cmake.definitions["WITH_X265"] = self.options.with_x265 - # aom - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_LibAOM"] = not self.options.with_libaomav1 - self._cmake.definitions["WITH_AOM"] = self.options.with_libaomav1 - # dav1d - self._cmake.definitions["WITH_DAV1D"] = self.options.get_safe("with_dav1d", False) - - # Workaround for cross-build to at least iOS/tvOS/watchOS, - # when dependencies are found with find_path() and find_library() - # TODO: won't be necessary with CMakeToolchain (https://github.com/conan-io/conan/pull/10186) - if tools.cross_building(self): - self._cmake.definitions["CMAKE_FIND_ROOT_PATH_MODE_INCLUDE"] = "BOTH" - self._cmake.definitions["CMAKE_FIND_ROOT_PATH_MODE_LIBRARY"] = "BOTH" - - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITH_LIBDE265"] = self.options.with_libde265 + tc.variables["WITH_X265"] = self.options.with_x265 + tc.variables["WITH_AOM"] = self.options.with_libaomav1 + tc.variables["WITH_RAV1E"] = False + tc.variables["WITH_DAV1D"] = self.options.with_dav1d + tc.variables["WITH_EXAMPLES"] = False + if Version(self.version) < "1.11.0": + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): self.cpp_info.set_property("cmake_file_name", "libheif") @@ -120,16 +106,20 @@ def package_info(self): self.cpp_info.components["heif"].defines = ["LIBHEIF_STATIC_BUILD"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["heif"].system_libs.extend(["m", "pthread"]) - if not self.options.shared and tools.stdcpp_library(self): - self.cpp_info.components["heif"].system_libs.append(tools.stdcpp_library(self)) + if not self.options.shared: + libcxx = tools_legacy.stdcpp_library(self) + if libcxx: + self.cpp_info.components["heif"].system_libs.append(libcxx) # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.components["heif"].set_property("cmake_target_name", "libheif::heif") self.cpp_info.components["heif"].set_property("pkg_config_name", "libheif") - self.cpp_info.components["heif"].requires = ["libde265::libde265"] + self.cpp_info.components["heif"].requires = [] + if self.options.with_libde265: + self.cpp_info.components["heif"].requires.append("libde265::libde265") if self.options.with_x265: self.cpp_info.components["heif"].requires.append("libx265::libx265") if self.options.with_libaomav1: self.cpp_info.components["heif"].requires.append("libaom-av1::libaom-av1") - if self.options.get_safe("with_dav1d"): + if self.options.with_dav1d: self.cpp_info.components["heif"].requires.append("dav1d::dav1d") diff --git a/recipes/libheif/all/patches/0001-cmake-1.9.1.patch b/recipes/libheif/all/patches/0001-cmake-1.9.1.patch index 6397180df605d..65b0f3637413f 100644 --- a/recipes/libheif/all/patches/0001-cmake-1.9.1.patch +++ b/recipes/libheif/all/patches/0001-cmake-1.9.1.patch @@ -1,27 +1,146 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 5076fec..71891d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -41,8 +41,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) +@@ -34,14 +34,10 @@ if(NOT MSVC) + add_definitions(-Wno-error=deprecated-declarations) + endif() + +-set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_CXX_STANDARD_REQUIRED ON) +-set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) -- + # Create the compile command database for clang by default set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -@@ -54,7 +52,7 @@ if (has_potentially_evaluated_expression) - add_definitions(-Wno-error=potentially-evaluated-expression) +@@ -55,10 +51,20 @@ if (has_potentially_evaluated_expression) endif() --LIST (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") -+LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") - find_package(Libde265 REQUIRED) - find_package(X265) - find_package(LibAOM) -@@ -128,4 +126,3 @@ if(WITH_EXAMPLES) + LIST (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") +-find_package(Libde265 REQUIRED) +-find_package(X265) +-find_package(LibAOM) ++if(WITH_LIBDE265) ++find_package(libde265 REQUIRED CONFIG) ++endif() ++if(WITH_X265) ++find_package(libx265 REQUIRED CONFIG) ++endif() ++if(WITH_AOM) ++find_package(libaom-av1 REQUIRED CONFIG) ++endif() ++if(WITH_DAV1D) ++find_package(dav1d REQUIRED CONFIG) ++endif() + ++if(0) + if (LIBDE265_FOUND) + message("HEIF decoder, libde265: found") + else () +@@ -88,6 +94,7 @@ if (USE_LOCAL_DAV1D) + else () + message("AVIF decoder, use local dav1d: no") + endif () ++endif() + + + # Create libheif pkgconfig file +@@ -128,4 +135,3 @@ if(WITH_EXAMPLES) add_subdirectory (examples) endif() add_subdirectory (libheif) -add_subdirectory (gdk-pixbuf) +--- a/libheif/CMakeLists.txt ++++ b/libheif/CMakeLists.txt +@@ -59,45 +59,36 @@ target_compile_definitions(heif + LIBHEIF_EXPORTS + HAVE_VISIBILITY) + +-if(LIBDE265_FOUND) ++target_compile_features(heif PRIVATE cxx_std_11) ++if(WITH_LIBDE265) + target_compile_definitions(heif PRIVATE HAVE_LIBDE265=1) + target_sources(heif + PRIVATE + heif_decoder_libde265.cc + heif_decoder_libde265.h) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBDE265_CFLAGS}") + +- if (NOT "${LIBDE265_LIBRARY_DIRS}" STREQUAL "") +- set(LIBDE265_LINKDIR "-L${LIBDE265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${LIBDE265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${LIBDE265_LIBRARIES} ${LIBDE265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libde265) + + install(FILES heif_decoder_libde265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(X265_FOUND) ++if(WITH_X265) + target_compile_definitions(heif PRIVATE HAVE_X265=1) + target_sources(heif PRIVATE + heif_encoder_x265.cc + heif_encoder_x265.h + ) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${X265_CFLAGS}") + +- if (NOT "${X265_LIBRARY_DIRS}" STREQUAL "") +- set(X265_LINKDIR "-L${X265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${X265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${X265_LIBRARIES} ${X265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libx265::libx265) + + install(FILES heif_encoder_x265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(AOM_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM=1) + target_sources(heif PRIVATE + heif_decoder_aom.cc +@@ -105,15 +96,9 @@ if(AOM_FOUND) + heif_encoder_aom.cc + heif_encoder_aom.h + ) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AOM_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AOM_CFLAGS}") + +- if (NOT "${AOM_LIBRARY_DIRS}" STREQUAL "") +- set(AOM_LINKDIR "-L${AOM_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${AOM_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${AOM_LIBRARIES} ${AOM_LINKDIR}) ++ target_link_libraries(heif PRIVATE libaom-av1::libaom-av1) + endif() + + if(USE_LOCAL_RAV1E) +@@ -126,18 +111,14 @@ if(USE_LOCAL_RAV1E) + target_link_libraries(heif PRIVATE ${CMAKE_SOURCE_DIR}/third-party/rav1e/target/release/librav1e.a -ldl) + endif() + +-if(USE_LOCAL_DAV1D) ++if(WITH_DAV1D) + target_compile_definitions(heif PRIVATE HAVE_DAV1D=1) + target_sources(heif PRIVATE + heif_decoder_dav1d.cc + heif_decoder_dav1d.h + ) +- target_include_directories(heif PRIVATE ${CMAKE_SOURCE_DIR}/third-party/dav1d/build +- ${CMAKE_SOURCE_DIR}/third-party/dav1d/build/include +- ${CMAKE_SOURCE_DIR}/third-party/dav1d/build/include/dav1d +- ${CMAKE_SOURCE_DIR}/third-party/dav1d/include) + +- target_link_libraries(heif PRIVATE ${CMAKE_SOURCE_DIR}/third-party/dav1d/build/src/libdav1d.a -ldl) ++ target_link_libraries(heif PRIVATE dav1d::dav1d) + endif () + + write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY ExactVersion) diff --git a/recipes/libheif/all/patches/0001-cmake_1.11.0.patch b/recipes/libheif/all/patches/0001-cmake_1.11.0.patch index 0187ded1585bb..1bf34c06d1da8 100644 --- a/recipes/libheif/all/patches/0001-cmake_1.11.0.patch +++ b/recipes/libheif/all/patches/0001-cmake_1.11.0.patch @@ -1,18 +1,162 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index fabf381..6379d09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -38,8 +38,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) +@@ -31,14 +31,10 @@ if(NOT MSVC) + add_definitions(-Wno-error=deprecated-declarations) + endif() + +-set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_CXX_STANDARD_REQUIRED ON) +-set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) -- + # Create the compile command database for clang by default set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +@@ -55,17 +51,17 @@ LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") + + option(WITH_LIBDE265 "Build libde265 decoder" ON) + if (WITH_LIBDE265) +- find_package(Libde265) ++ find_package(libde265 REQUIRED CONFIG) + endif () + + option(WITH_X265 "Build x265 encoder" ON) + if (WITH_X265) +- find_package(X265) ++ find_package(libx265 REQUIRED CONFIG) + endif () + + option(WITH_AOM "Build aom encoder/decoder" ON) + if (WITH_AOM) +- find_package(LibAOM) ++ find_package(libaom-av1 REQUIRED CONFIG) + endif() + + option(WITH_RAV1E "Build rav1e encoder" ON) +@@ -75,9 +71,10 @@ endif () + option(WITH_DAV1D "Build dav1e decoder" ON) + if (WITH_DAV1D) +- find_package(Dav1d) ++ find_package(dav1d REQUIRED CONFIG) + endif () + ++if(0) + if (LIBDE265_FOUND) + message("HEIF decoder, libde265: found") + else () +@@ -113,6 +110,7 @@ if (DAV1D_FOUND) + else () + message("AVIF decoder, dav1d: not found") + endif () ++endif() + + + # Create libheif pkgconfig file @@ -165,4 +163,3 @@ if(WITH_EXAMPLES) add_subdirectory (examples) endif() add_subdirectory (libheif) -add_subdirectory (gdk-pixbuf) +--- a/libheif/CMakeLists.txt ++++ b/libheif/CMakeLists.txt +@@ -59,63 +59,48 @@ target_compile_definitions(heif + LIBHEIF_EXPORTS + HAVE_VISIBILITY) + +-if(LIBDE265_FOUND) ++target_compile_features(heif PRIVATE cxx_std_11) ++if(WITH_LIBDE265) + target_compile_definitions(heif PRIVATE HAVE_LIBDE265=1) + target_sources(heif + PRIVATE + heif_decoder_libde265.cc + heif_decoder_libde265.h) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBDE265_CFLAGS}") + +- if (NOT "${LIBDE265_LIBRARY_DIRS}" STREQUAL "") +- set(LIBDE265_LINKDIR "-L${LIBDE265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${LIBDE265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${LIBDE265_LIBRARIES} ${LIBDE265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libde265) + + install(FILES heif_decoder_libde265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(X265_FOUND) ++if(WITH_X265) + target_compile_definitions(heif PRIVATE HAVE_X265=1) + target_sources(heif PRIVATE + heif_encoder_x265.cc + heif_encoder_x265.h + ) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${X265_CFLAGS}") + +- if (NOT "${X265_LIBRARY_DIRS}" STREQUAL "") +- set(X265_LINKDIR "-L${X265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${X265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${X265_LIBRARIES} ${X265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libx265::libx265) + + install(FILES heif_encoder_x265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(AOM_ENCODER_FOUND OR AOM_DECODER_FOUND) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AOM_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AOM_CFLAGS}") ++if(WITH_AOM) + +- if (NOT "${AOM_LIBRARY_DIRS}" STREQUAL "") +- set(AOM_LINKDIR "-L${AOM_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${AOM_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${AOM_LIBRARIES} ${AOM_LINKDIR}) ++ target_link_libraries(heif PRIVATE libaom-av1::libaom-av1) + endif() +-if(AOM_ENCODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_ENCODER=1) + target_sources(heif PRIVATE + heif_encoder_aom.cc + heif_encoder_aom.h + ) + endif() +-if(AOM_DECODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_DECODER=1) + target_sources(heif PRIVATE + heif_decoder_aom.cc +@@ -140,21 +125,15 @@ if(RAV1E_FOUND) + target_link_libraries(heif PRIVATE ${RAV1E_LIBRARIES} ${RAV1E_LINKDIR}) + endif() + +-if(DAV1D_FOUND) ++if(WITH_DAV1D) + target_compile_definitions(heif PRIVATE HAVE_DAV1D=1) + target_sources(heif PRIVATE + heif_decoder_dav1d.cc + heif_decoder_dav1d.h + ) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DAV1D_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DAV1D_CFLAGS}") + +- if (NOT "${DAV1D_LIBRARY_DIRS}" STREQUAL "") +- set(DAV1D_LINKDIR "-L${DAV1D_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${DAV1D_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${DAV1D_LIBRARIES} ${DAV1D_LINKDIR}) ++ target_link_libraries(heif PRIVATE dav1d::dav1d) + endif () + + write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY ExactVersion) diff --git a/recipes/libheif/all/patches/0001-cmake_1.12.0.patch b/recipes/libheif/all/patches/0001-cmake_1.12.0.patch new file mode 100644 index 0000000000000..7504a4c708fcd --- /dev/null +++ b/recipes/libheif/all/patches/0001-cmake_1.12.0.patch @@ -0,0 +1,162 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -31,14 +31,10 @@ if(NOT MSVC) + add_definitions(-Wno-error=deprecated-declarations) + endif() + +-set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_CXX_STANDARD_REQUIRED ON) +-set(CMAKE_CXX_EXTENSIONS OFF) + + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) + +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + # Create the compile command database for clang by default + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +@@ -55,17 +51,17 @@ LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") + + option(WITH_LIBDE265 "Build libde265 decoder" ON) + if (WITH_LIBDE265) +- find_package(Libde265) ++ find_package(libde265 REQUIRED CONFIG) + endif () + + option(WITH_X265 "Build x265 encoder" ON) + if (WITH_X265) +- find_package(X265) ++ find_package(libx265 REQUIRED CONFIG) + endif () + + option(WITH_AOM "Build aom encoder/decoder" ON) + if (WITH_AOM) +- find_package(LibAOM) ++ find_package(libaom-av1 REQUIRED CONFIG) + endif() + + option(WITH_RAV1E "Build rav1e encoder" ON) +@@ -75,9 +71,10 @@ endif () + + option(WITH_DAV1D "Build dav1d decoder" ON) + if (WITH_DAV1D) +- find_package(Dav1d) ++ find_package(dav1d REQUIRED CONFIG) + endif () + ++if(0) + if (LIBDE265_FOUND) + message("HEIF decoder, libde265: found") + else () +@@ -113,6 +110,7 @@ if (DAV1D_FOUND) + else () + message("AVIF decoder, dav1d: not found") + endif () ++endif() + + + # Create libheif pkgconfig file +@@ -165,4 +163,3 @@ if(WITH_EXAMPLES) + add_subdirectory (examples) + endif() + add_subdirectory (libheif) +-add_subdirectory (gdk-pixbuf) +--- a/libheif/CMakeLists.txt ++++ b/libheif/CMakeLists.txt +@@ -59,63 +59,48 @@ target_compile_definitions(heif + LIBHEIF_EXPORTS + HAVE_VISIBILITY) + +-if(LIBDE265_FOUND) ++target_compile_features(heif PRIVATE cxx_std_11) ++if(WITH_LIBDE265) + target_compile_definitions(heif PRIVATE HAVE_LIBDE265=1) + target_sources(heif + PRIVATE + heif_decoder_libde265.cc + heif_decoder_libde265.h) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBDE265_CFLAGS}") + +- if (NOT "${LIBDE265_LIBRARY_DIRS}" STREQUAL "") +- set(LIBDE265_LINKDIR "-L${LIBDE265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${LIBDE265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${LIBDE265_LIBRARIES} ${LIBDE265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libde265) + + install(FILES heif_decoder_libde265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(X265_FOUND) ++if(WITH_X265) + target_compile_definitions(heif PRIVATE HAVE_X265=1) + target_sources(heif PRIVATE + heif_encoder_x265.cc + heif_encoder_x265.h + ) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${X265_CFLAGS}") + +- if (NOT "${X265_LIBRARY_DIRS}" STREQUAL "") +- set(X265_LINKDIR "-L${X265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${X265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${X265_LIBRARIES} ${X265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libx265::libx265) + + install(FILES heif_encoder_x265.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) + endif() + +-if(AOM_ENCODER_FOUND OR AOM_DECODER_FOUND) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AOM_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AOM_CFLAGS}") ++if(WITH_AOM) + +- if (NOT "${AOM_LIBRARY_DIRS}" STREQUAL "") +- set(AOM_LINKDIR "-L${AOM_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${AOM_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${AOM_LIBRARIES} ${AOM_LINKDIR}) ++ target_link_libraries(heif PRIVATE libaom-av1::libaom-av1) + endif() +-if(AOM_ENCODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_ENCODER=1) + target_sources(heif PRIVATE + heif_encoder_aom.cc + heif_encoder_aom.h + ) + endif() +-if(AOM_DECODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_DECODER=1) + target_sources(heif PRIVATE + heif_decoder_aom.cc +@@ -140,21 +125,15 @@ if(RAV1E_FOUND) + target_link_libraries(heif PRIVATE ${RAV1E_LIBRARIES} ${RAV1E_LINKDIR}) + endif() + +-if(DAV1D_FOUND) ++if(WITH_DAV1D) + target_compile_definitions(heif PRIVATE HAVE_DAV1D=1) + target_sources(heif PRIVATE + heif_decoder_dav1d.cc + heif_decoder_dav1d.h + ) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DAV1D_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DAV1D_CFLAGS}") + +- if (NOT "${DAV1D_LIBRARY_DIRS}" STREQUAL "") +- set(DAV1D_LINKDIR "-L${DAV1D_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${DAV1D_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${DAV1D_LIBRARIES} ${DAV1D_LINKDIR}) ++ target_link_libraries(heif PRIVATE dav1d::dav1d) + endif () + + write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY ExactVersion) diff --git a/recipes/libheif/all/patches/0001-cmake_1.13.0.patch b/recipes/libheif/all/patches/0001-cmake_1.13.0.patch new file mode 100644 index 0000000000000..ce89cda4b5c16 --- /dev/null +++ b/recipes/libheif/all/patches/0001-cmake_1.13.0.patch @@ -0,0 +1,159 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -35,14 +35,10 @@ if(NOT MSVC) + endif () + endif() + +-set(CMAKE_CXX_STANDARD 11) +-set(CMAKE_CXX_STANDARD_REQUIRED ON) +-set(CMAKE_CXX_EXTENSIONS OFF) + + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) + +-set(CMAKE_POSITION_INDEPENDENT_CODE ON) + + # Create the compile command database for clang by default + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +@@ -59,17 +55,17 @@ LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") + + option(WITH_LIBDE265 "Build libde265 decoder" ON) + if (WITH_LIBDE265) +- find_package(Libde265) ++ find_package(libde265 REQUIRED CONFIG) + endif () + + option(WITH_X265 "Build x265 encoder" ON) + if (WITH_X265) +- find_package(X265) ++ find_package(libx265 REQUIRED CONFIG) + endif () + + option(WITH_AOM "Build aom encoder/decoder" ON) + if (WITH_AOM) +- find_package(LibAOM) ++ find_package(libaom-av1 REQUIRED CONFIG) + endif() + + option(WITH_RAV1E "Build rav1e encoder" ON) +@@ -79,9 +75,10 @@ endif () + + option(WITH_DAV1D "Build dav1d decoder" ON) + if (WITH_DAV1D) +- find_package(Dav1d) ++ find_package(dav1d REQUIRED CONFIG) + endif () + ++if(0) + if (LIBDE265_FOUND) + message("HEIF decoder, libde265: found") + else () +@@ -117,6 +114,7 @@ if (DAV1D_FOUND) + else () + message("AVIF decoder, dav1d: not found") + endif () ++endif() + + + # Create libheif pkgconfig file +@@ -169,5 +167,3 @@ if(WITH_EXAMPLES) + add_subdirectory (examples) + endif() + add_subdirectory (libheif) +-add_subdirectory (gdk-pixbuf) +-add_subdirectory (gnome) +--- a/libheif/CMakeLists.txt ++++ b/libheif/CMakeLists.txt +@@ -60,59 +60,44 @@ target_compile_definitions(heif + LIBHEIF_EXPORTS + HAVE_VISIBILITY) + +-if(LIBDE265_FOUND) ++target_compile_features(heif PRIVATE cxx_std_11) ++if(WITH_LIBDE265) + target_compile_definitions(heif PRIVATE HAVE_LIBDE265=1) + target_sources(heif + PRIVATE + heif_decoder_libde265.cc + heif_decoder_libde265.h) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBDE265_CFLAGS}") + +- if (NOT "${LIBDE265_LIBRARY_DIRS}" STREQUAL "") +- set(LIBDE265_LINKDIR "-L${LIBDE265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${LIBDE265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${LIBDE265_LIBRARIES} ${LIBDE265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libde265) + endif() + +-if(X265_FOUND) ++if(WITH_X265) + target_compile_definitions(heif PRIVATE HAVE_X265=1) + target_sources(heif PRIVATE + heif_encoder_x265.cc + heif_encoder_x265.h + ) + +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${X265_CFLAGS}") + +- if (NOT "${X265_LIBRARY_DIRS}" STREQUAL "") +- set(X265_LINKDIR "-L${X265_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${X265_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${X265_LIBRARIES} ${X265_LINKDIR}) ++ target_link_libraries(heif PRIVATE libx265::libx265) + endif() + +-if(AOM_ENCODER_FOUND OR AOM_DECODER_FOUND) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AOM_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AOM_CFLAGS}") ++if(WITH_AOM) + +- if (NOT "${AOM_LIBRARY_DIRS}" STREQUAL "") +- set(AOM_LINKDIR "-L${AOM_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${AOM_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${AOM_LIBRARIES} ${AOM_LINKDIR}) ++ target_link_libraries(heif PRIVATE libaom-av1::libaom-av1) + endif() +-if(AOM_ENCODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_ENCODER=1) + target_sources(heif PRIVATE + heif_encoder_aom.cc + heif_encoder_aom.h + ) + endif() +-if(AOM_DECODER_FOUND) ++if(WITH_AOM) + target_compile_definitions(heif PRIVATE HAVE_AOM_DECODER=1) + target_sources(heif PRIVATE + heif_decoder_aom.cc +@@ -137,21 +122,15 @@ if(RAV1E_FOUND) + target_link_libraries(heif PRIVATE ${RAV1E_LIBRARIES} ${RAV1E_LINKDIR}) + endif() + +-if(DAV1D_FOUND) ++if(WITH_DAV1D) + target_compile_definitions(heif PRIVATE HAVE_DAV1D=1) + target_sources(heif PRIVATE + heif_decoder_dav1d.cc + heif_decoder_dav1d.h + ) +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DAV1D_CFLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DAV1D_CFLAGS}") + +- if (NOT "${DAV1D_LIBRARY_DIRS}" STREQUAL "") +- set(DAV1D_LINKDIR "-L${DAV1D_LIBRARY_DIRS}") +- endif() + +- include_directories(SYSTEM ${DAV1D_INCLUDE_DIR}) +- target_link_libraries(heif PRIVATE ${DAV1D_LIBRARIES} ${DAV1D_LINKDIR}) ++ target_link_libraries(heif PRIVATE dav1d::dav1d) + endif () + + write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY ExactVersion) diff --git a/recipes/libheif/all/test_package/CMakeLists.txt b/recipes/libheif/all/test_package/CMakeLists.txt index 8c009895d93fd..13ebf8fab7134 100644 --- a/recipes/libheif/all/test_package/CMakeLists.txt +++ b/recipes/libheif/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(libheif REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} libheif::heif) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE libheif::heif) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libheif/all/test_package/conanfile.py b/recipes/libheif/all/test_package/conanfile.py index 49a3a66ea5bad..d120a992c06a6 100644 --- a/recipes/libheif/all/test_package/conanfile.py +++ b/recipes/libheif/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libheif/all/test_v1_package/CMakeLists.txt b/recipes/libheif/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..02d32b85a6658 --- /dev/null +++ b/recipes/libheif/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(libheif REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libheif::heif) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libheif/all/test_v1_package/conanfile.py b/recipes/libheif/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libheif/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libheif/config.yml b/recipes/libheif/config.yml index f4ddb18d1af15..1b1bac20e2e23 100644 --- a/recipes/libheif/config.yml +++ b/recipes/libheif/config.yml @@ -1,4 +1,6 @@ versions: + "1.13.0": + folder: all "1.12.0": folder: all "1.11.0": diff --git a/recipes/libsndfile/all/CMakeLists.txt b/recipes/libsndfile/all/CMakeLists.txt deleted file mode 100644 index b71c882d9d33f..0000000000000 --- a/recipes/libsndfile/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory(source_subfolder) diff --git a/recipes/libsndfile/all/conandata.yml b/recipes/libsndfile/all/conandata.yml index 2ccb8bad39dfa..9c03d46a973d3 100644 --- a/recipes/libsndfile/all/conandata.yml +++ b/recipes/libsndfile/all/conandata.yml @@ -10,8 +10,6 @@ sources: sha256: "2ba20d44817c8176f097ab25eff44ef0aeec9e00973def5a7174c5ae0764b22f" patches: "1.0.31": - - base_path: "source_subfolder" - patch_file: "patches/1.0.31-0001-disable-static-runtime-logic.patch" + - patch_file: "patches/1.0.31-0001-fix-msvc-runtime-logic.patch" "1.0.30": - - base_path: "source_subfolder" - patch_file: "patches/1.0.30-0001-disable-static-runtime-logic.patch" + - patch_file: "patches/1.0.30-0001-disable-static-libgcc-mingw.patch" diff --git a/recipes/libsndfile/all/conanfile.py b/recipes/libsndfile/all/conanfile.py index 25bc4b9d31f4c..945a12b9aff7b 100644 --- a/recipes/libsndfile/all/conanfile.py +++ b/recipes/libsndfile/all/conanfile.py @@ -1,8 +1,11 @@ -from conan.tools.microsoft import msvc_runtime_flag -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version import os -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" class LibsndfileConan(ConanFile): @@ -34,21 +37,9 @@ class LibsndfileConan(ConanFile): "with_external_libs": True, } - generators = "cmake", "cmake_find_package" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _is_msvc(self): - return str(self.settings.compiler) in ["Visual Studio", "msvc"] - def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -61,60 +52,63 @@ def configure(self): def requirements(self): if self.options.get_safe("with_alsa"): - self.requires("libalsa/1.2.5.1") + self.requires("libalsa/1.2.7.2") if self.options.with_external_libs: self.requires("ogg/1.3.5") self.requires("vorbis/1.3.7") self.requires("flac/1.3.3") self.requires("opus/1.3.1") + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Sndio"] = True # FIXME: missing sndio cci recipe (check whether it is really required) - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Speex"] = True # FIXME: missing sndio cci recipe (check whether it is really required) - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_SQLite3"] = True # only used for regtest - self._cmake.definitions["ENABLE_EXTERNAL_LIBS"] = self.options.with_external_libs + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Sndio"] = True # FIXME: missing sndio cci recipe (check whether it is really required) + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Speex"] = True # FIXME: missing sndio cci recipe (check whether it is really required) + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_SQLite3"] = True # only used for regtest + tc.variables["ENABLE_EXTERNAL_LIBS"] = self.options.with_external_libs if not self.options.with_external_libs: - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Ogg"] = True - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Vorbis"] = True - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_FLAC"] = True - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Opus"] = True + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Ogg"] = True + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Vorbis"] = True + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_FLAC"] = True + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Opus"] = True if not self.options.get_safe("with_alsa", False): - self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_ALSA"] = True - self._cmake.definitions["BUILD_PROGRAMS"] = self.options.programs - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.definitions["ENABLE_CPACK"] = False - self._cmake.definitions["ENABLE_EXPERIMENTAL"] = self.options.experimental - if self._is_msvc: - self._cmake.definitions["ENABLE_STATIC_RUNTIME"] = "MT" in msvc_runtime_flag(self) - self._cmake.definitions["BUILD_REGTEST"] = False - self._cmake.configure() - return self._cmake + tc.variables["CMAKE_DISABLE_FIND_PACKAGE_ALSA"] = True + tc.variables["BUILD_PROGRAMS"] = self.options.programs + tc.variables["BUILD_EXAMPLES"] = False + tc.variables["BUILD_TESTING"] = False + tc.variables["ENABLE_CPACK"] = False + tc.variables["ENABLE_EXPERIMENTAL"] = self.options.experimental + if is_msvc(self) and Version(self.version) < "1.0.30": + tc.variables["ENABLE_STATIC_RUNTIME"] = is_msvc_static_runtime(self) + tc.variables["BUILD_REGTEST"] = False + # Fix iOS/tvOS/watchOS + tc.variables["CMAKE_MACOSX_BUNDLE"] = False + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}", - "RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}") - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): self.cpp_info.set_property("cmake_file_name", "SndFile") diff --git a/recipes/libsndfile/all/patches/1.0.30-0001-disable-static-runtime-logic.patch b/recipes/libsndfile/all/patches/1.0.30-0001-disable-static-libgcc-mingw.patch similarity index 58% rename from recipes/libsndfile/all/patches/1.0.30-0001-disable-static-runtime-logic.patch rename to recipes/libsndfile/all/patches/1.0.30-0001-disable-static-libgcc-mingw.patch index 1de3ec58e57ae..f7e1a5bf32674 100644 --- a/recipes/libsndfile/all/patches/1.0.30-0001-disable-static-runtime-logic.patch +++ b/recipes/libsndfile/all/patches/1.0.30-0001-disable-static-libgcc-mingw.patch @@ -1,5 +1,3 @@ -diff --git a/cmake/SndFileChecks.cmake b/cmake/SndFileChecks.cmake -index 3528c325..f9e43c91 100644 --- a/cmake/SndFileChecks.cmake +++ b/cmake/SndFileChecks.cmake @@ -213,7 +213,7 @@ if (MSVC) @@ -11,12 +9,3 @@ index 3528c325..f9e43c91 100644 if (CMAKE_C_COMPILER_ID STREQUAL GNU) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc") set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s") -@@ -232,7 +232,7 @@ if (MINGW) - endif () - endif () - --if (DEFINED ENABLE_STATIC_RUNTIME) -+if (FALSE) - if (MSVC) - if (CMAKE_VERSION VERSION_LESS 3.15) - if (ENABLE_STATIC_RUNTIME) diff --git a/recipes/libsndfile/all/patches/1.0.31-0001-disable-static-runtime-logic.patch b/recipes/libsndfile/all/patches/1.0.31-0001-disable-static-runtime-logic.patch deleted file mode 100644 index 476f873084a20..0000000000000 --- a/recipes/libsndfile/all/patches/1.0.31-0001-disable-static-runtime-logic.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- cmake/SndFileChecks.cmake -+++ cmake/SndFileChecks.cmake -@@ -222,7 +222,7 @@ - add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) - endif (MSVC) - --if (DEFINED ENABLE_STATIC_RUNTIME) -+if (FALSE) - if (MSVC) - if (ENABLE_STATIC_RUNTIME) - foreach (flag_var diff --git a/recipes/libsndfile/all/patches/1.0.31-0001-fix-msvc-runtime-logic.patch b/recipes/libsndfile/all/patches/1.0.31-0001-fix-msvc-runtime-logic.patch new file mode 100644 index 0000000000000..abada26c071ce --- /dev/null +++ b/recipes/libsndfile/all/patches/1.0.31-0001-fix-msvc-runtime-logic.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -8,7 +8,7 @@ if (POLICY CMP0091) + return () + endif () + +- if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) ++ if (1) + cmake_policy (SET CMP0091 NEW) + else () + cmake_policy (SET CMP0091 OLD) diff --git a/recipes/libsndfile/all/test_package/CMakeLists.txt b/recipes/libsndfile/all/test_package/CMakeLists.txt index cf2b7660cdaef..3fb4ef12f8bc8 100644 --- a/recipes/libsndfile/all/test_package/CMakeLists.txt +++ b/recipes/libsndfile/all/test_package/CMakeLists.txt @@ -1,8 +1,5 @@ cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(SndFile REQUIRED CONFIG) diff --git a/recipes/libsndfile/all/test_package/conanfile.py b/recipes/libsndfile/all/test_package/conanfile.py index 49a3a66ea5bad..d120a992c06a6 100644 --- a/recipes/libsndfile/all/test_package/conanfile.py +++ b/recipes/libsndfile/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libsndfile/all/test_v1_package/CMakeLists.txt b/recipes/libsndfile/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9d5c55d61ca3e --- /dev/null +++ b/recipes/libsndfile/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(SndFile REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE SndFile::sndfile) diff --git a/recipes/libsndfile/all/test_v1_package/conanfile.py b/recipes/libsndfile/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/libsndfile/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mariadb-connector-c/all/CMakeLists.txt b/recipes/mariadb-connector-c/all/CMakeLists.txt deleted file mode 100644 index b71c882d9d33f..0000000000000 --- a/recipes/mariadb-connector-c/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory(source_subfolder) diff --git a/recipes/mariadb-connector-c/all/conandata.yml b/recipes/mariadb-connector-c/all/conandata.yml index cf5cbd99d1eab..a74dc266f2982 100644 --- a/recipes/mariadb-connector-c/all/conandata.yml +++ b/recipes/mariadb-connector-c/all/conandata.yml @@ -8,23 +8,13 @@ sources: patches: "3.1.12": - patch_file: "patches/0001-fix-install-and-static-or-shared.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-msvc-no-override-md-zi.patch" - base_path: "source_subfolder" - patch_file: "patches/0003-include-order-windows-winsock2.patch" - base_path: "source_subfolder" - patch_file: "patches/0004-include-mysqld_error-header.patch" - base_path: "source_subfolder" - patch_file: "patches/0005-fix-cmake-connectorname.patch" - base_path: "source_subfolder" "3.1.11": - patch_file: "patches/0001-fix-install-and-static-or-shared.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-msvc-no-override-md-zi.patch" - base_path: "source_subfolder" - patch_file: "patches/0003-include-order-windows-winsock2.patch" - base_path: "source_subfolder" - patch_file: "patches/0004-include-mysqld_error-header.patch" - base_path: "source_subfolder" - patch_file: "patches/0005-fix-cmake-connectorname.patch" - base_path: "source_subfolder" diff --git a/recipes/mariadb-connector-c/all/conanfile.py b/recipes/mariadb-connector-c/all/conanfile.py index ca7c4933a60fa..2f72898f8206d 100644 --- a/recipes/mariadb-connector-c/all/conanfile.py +++ b/recipes/mariadb-connector-c/all/conanfile.py @@ -1,8 +1,10 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get, replace_in_file, rm, rmdir import os -required_conan_version = ">=1.36.0" +required_conan_version = ">=1.51.1" class MariadbConnectorcConan(ConanFile): @@ -32,17 +34,9 @@ class MariadbConnectorcConan(ConanFile): "with_ssl": "openssl", } - generators = "cmake", "cmake_find_package" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -53,8 +47,14 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass def requirements(self): self.requires("zlib/1.2.12") @@ -66,68 +66,73 @@ def requirements(self): self.requires("openssl/1.1.1q") def validate(self): - if self.settings.os != "Windows" and self.options.with_ssl == "schannel": + if self.info.settings.os != "Windows" and self.info.options.with_ssl == "schannel": raise ConanInvalidConfiguration("schannel only supported on Windows") - if self.options.with_ssl == "gnutls": + if self.info.options.with_ssl == "gnutls": raise ConanInvalidConfiguration("gnutls not yet available in CCI") + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if self.settings.os == "Windows": + tc.variables["WITH_MSI"] = False + tc.variables["WITH_SIGNCODE"] = False + tc.variables["WITH_RTC"] = False + else: + tc.variables["WITH_MYSQLCOMPAT"] = False + tc.variables["WITH_ICONV"] = self.options.with_iconv + tc.variables["WITH_UNIT_TESTS"] = False + tc.variables["WITH_DYNCOL"] = self.options.dyncol + tc.variables["WITH_EXTERNAL_ZLIB"] = True + tc.variables["WITH_CURL"] = self.options.with_curl + tc.variables["WITH_SSL"] = self.options.with_ssl + tc.variables["INSTALL_BINDIR"] = "bin" + tc.variables["INSTALL_LIBDIR"] = "lib" + tc.variables["INSTALL_PLUGINDIR"] = os.path.join("lib", "plugin").replace("\\", "/") + # To install relocatable shared libs on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() + deps = CMakeDeps(self) + deps.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) - root_cmake = os.path.join(self._source_subfolder, "CMakeLists.txt") - tools.replace_in_file(root_cmake, "${ZLIB_LIBRARY}", "${ZLIB_LIBRARIES}") - tools.replace_in_file( + root_cmake = os.path.join(self.source_folder, "CMakeLists.txt") + replace_in_file(self, root_cmake, "${ZLIB_LIBRARY}", "${ZLIB_LIBRARIES}") + replace_in_file(self, root_cmake, "SET(SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})", - "SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})" + "SET(SSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)" ) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - if self.settings.os == "Windows": - self._cmake.definitions["WITH_MSI"] = False - self._cmake.definitions["WITH_SIGNCODE"] = False - self._cmake.definitions["WITH_RTC"] = False - else: - self._cmake.definitions["WITH_MYSQLCOMPAT"] = False - self._cmake.definitions["WITH_ICONV"] = self.options.with_iconv - self._cmake.definitions["WITH_UNIT_TESTS"] = False - self._cmake.definitions["WITH_DYNCOL"] = self.options.dyncol - self._cmake.definitions["WITH_EXTERNAL_ZLIB"] = True - self._cmake.definitions["WITH_CURL"] = self.options.with_curl - self._cmake.definitions["WITH_SSL"] = self.options.with_ssl - self._cmake.definitions["INSTALL_BINDIR"] = "bin" - self._cmake.definitions["INSTALL_LIBDIR"] = "lib" - self._cmake.definitions["INSTALL_PLUGINDIR"] = os.path.join("lib", "plugin").replace("\\", "/") - # To install relocatable shared libs on Macos - self._cmake.definitions["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" - self._cmake.configure() - return self._cmake + replace_in_file(self, root_cmake, "${CURL_LIBRARIES}", "CURL::libcurl") + plugins_io_cmake = os.path.join(self.source_folder, "plugins", "io", "CMakeLists.txt") + replace_in_file(self, plugins_io_cmake, "${CURL_LIBRARIES}", "CURL::libcurl") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING.LIB", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING.LIB", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "symbols")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.pdb") + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "symbols")) + rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) def package_info(self): self.cpp_info.set_property("pkg_config_name", "libmariadb") self.cpp_info.includedirs.append(os.path.join("include", "mariadb")) - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = collect_libs(self) if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["dl", "m", "pthread"] elif self.settings.os == "Windows": diff --git a/recipes/mariadb-connector-c/all/test_package/CMakeLists.txt b/recipes/mariadb-connector-c/all/test_package/CMakeLists.txt index 7b9b613cbb24a..d314b6a18b20d 100644 --- a/recipes/mariadb-connector-c/all/test_package/CMakeLists.txt +++ b/recipes/mariadb-connector-c/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(mariadb-connector-c REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE mariadb-connector-c::mariadb-connector-c) diff --git a/recipes/mariadb-connector-c/all/test_package/conanfile.py b/recipes/mariadb-connector-c/all/test_package/conanfile.py index 5c09494bc67c0..8a5bb47f50c4c 100644 --- a/recipes/mariadb-connector-c/all/test_package/conanfile.py +++ b/recipes/mariadb-connector-c/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "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) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mariadb-connector-c/all/test_v1_package/CMakeLists.txt b/recipes/mariadb-connector-c/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2ff7650134f6d --- /dev/null +++ b/recipes/mariadb-connector-c/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(mariadb-connector-c REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE mariadb-connector-c::mariadb-connector-c) diff --git a/recipes/mariadb-connector-c/all/test_v1_package/conanfile.py b/recipes/mariadb-connector-c/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..f5c483de856db --- /dev/null +++ b/recipes/mariadb-connector-c/all/test_v1_package/conanfile.py @@ -0,0 +1,21 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/meson/all/conandata.yml b/recipes/meson/all/conandata.yml index 2415a7bd5e652..8b3154bd5a7bf 100644 --- a/recipes/meson/all/conandata.yml +++ b/recipes/meson/all/conandata.yml @@ -1,103 +1,40 @@ sources: - # "0.51.0": - # url: "https://github.com/mesonbuild/meson/archive/0.51.0.tar.gz" - # sha256: "ec1e3942215a858d82c3d2e095d18adcf1ede94a34144662643d88db4dcb5263" - "0.51.2": - url: "https://github.com/mesonbuild/meson/archive/0.51.2.tar.gz" - sha256: "96871cf62c9cf2b212e2f38aa3e543323403b1314fd3835e14120ef837c00f01" - # "0.52.0": - # url: "https://github.com/mesonbuild/meson/archive/0.52.0.tar.gz" - # sha256: "0f426ed1362c38bcc5b9027ec6aec3445d6db88e8d7249ed992e9af88a42d0e0" - "0.52.1": - url: "https://github.com/mesonbuild/meson/archive/0.52.1.tar.gz" - sha256: "ad8dbad61d4c22cb7d768cb1f8a212b4abf0f3fbc17c298d816140ecd9f5d1df" - # "0.53.0": - # url: "https://github.com/mesonbuild/meson/archive/0.53.0.tar.gz" - # sha256: "cc15f416d0b538fb079c15a59ee2cd106895ca115fa5d654731a695c85c992fc" - # "0.53.1": - # url: "https://github.com/mesonbuild/meson/archive/0.53.1.tar.gz" - # sha256: "f69ff8ce6cb52cbfb9bcc844086fade76920a292a017e68201317eeacd3ab943" - "0.53.2": - url: "https://github.com/mesonbuild/meson/archive/0.53.2.tar.gz" - sha256: "eab4f5d5dde12d002b7ddd958a9a0658589b63622b6cea2715e0235b95917888" - # "0.54.0": - # url: "https://github.com/mesonbuild/meson/archive/0.54.0.tar.gz" - # sha256: "95efdbaa7cb3e915ab9a7b26b1412475398fdc3e834842a780f1646c7764f2d9" - # "0.54.1": - # url: "https://github.com/mesonbuild/meson/archive/0.54.1.tar.gz" - # sha256: "854e8b94ab36e5aece813d2b2aee8a639bd52201dfea50890722ac9128e2f59e" - # "0.54.2": - # url: "https://github.com/mesonbuild/meson/archive/0.54.2.tar.gz" - # sha256: "85cafdc70ae7d1d9d506e7356b917c649c4df2077bd6a0382db37648aa4ecbdb" - "0.54.3": - url: "https://github.com/mesonbuild/meson/archive/0.54.3.tar.gz" - sha256: "c25caff342b5368bfe33fab6108f454fcf12e2f2cef70817205872ddef669e8b" - # "0.55.0": - # url: "https://github.com/mesonbuild/meson/archive/0.55.0.tar.gz" - # sha256: "9034c943c8cf4d734c0e18e5ba038dd762fcdcc614c45b41703305da8382e90c" - # "0.55.1": - # url: "https://github.com/mesonbuild/meson/archive/0.55.1.tar.gz" - # sha256: "c7ebf2fff5934a974c7edd1aebb5fc9c3e1da5ae3184a29581fde917638eea39" - # "0.55.2": - # url: "https://github.com/mesonbuild/meson/archive/0.55.2.tar.gz" - # sha256: "56244896e56c2b619f819d047b6de412ecc5250975ee8717f1e329113d178e06" - "0.55.3": - url: "https://github.com/mesonbuild/meson/archive/0.55.3.tar.gz" - sha256: "2b276df50c5b13ccdbfb14d3333141e9e7985aca31b60400b3f3e0be2ee6897e" - # "0.56.0": - # url: "https://github.com/mesonbuild/meson/archive/0.56.0.tar.gz" - # sha256: "a9ca7adf66dc69fbb7e583f7c7aef16b9fe56ec2874a3d58747e69a3affdf300" - # "0.56.1": - # url: "https://github.com/mesonbuild/meson/archive/0.56.1.tar.gz" - # sha256: "db3545231bb8f3ae3186a1a0f49f0acd239724af91781b783e843b80400f10ec" - "0.56.2": - url: "https://github.com/mesonbuild/meson/archive/0.56.2.tar.gz" - sha256: "aaae961c3413033789248ffe6762589e80b6cf487c334d0b808e31a32c48f35f" - # "0.57.0": - # url: "https://github.com/mesonbuild/meson/archive/0.57.0.tar.gz" - # sha256: "fd26a27c1a509240c668ebd29d280649d9239cf8684ead51d5cb499d1e1188bd" - # "0.57.1": - # url: "https://github.com/mesonbuild/meson/archive/0.57.1.tar.gz" - # sha256: "0c043c9b5350e9087cd4f6becf6c0d10b1d618ca3f919e0dcca2cdf342360d5d" - "0.57.2": - url: "https://github.com/mesonbuild/meson/archive/0.57.2.tar.gz" - sha256: "cd3773625253df4fd1c380faf03ffae3d02198d6301e7c8bc7bba6c66af66096" - # "0.58.0": - # url: "https://github.com/mesonbuild/meson/archive/0.58.0.tar.gz" - # sha256: "991b882bfe4d37acc23c064a29ca209458764a580d52f044f3d50055a132bed4" - "0.58.1": - url: "https://github.com/mesonbuild/meson/archive/0.58.1.tar.gz" - sha256: "78e0f553dd3bc632d5f96ab943b1bbccb599c2c84ff27c5fb7f7fff9c8a3f6b4" - # "0.59.0": - # url: "https://github.com/mesonbuild/meson/archive/0.59.0.tar.gz" - # sha256: "fdbbe8ea8a47f9e21cf4f578f85be8ec3d9c030df3d8cb17df1ae59d8683813a" - # "0.59.1": - # url: "https://github.com/mesonbuild/meson/archive/0.59.1.tar.gz" - # sha256: "f256eb15329a6064f8cc1f23b29de1fa8d21e324f939041e1a4efe77cf1362ef" - # "0.59.2": - # url: "https://github.com/mesonbuild/meson/archive/0.59.2.tar.gz" - # sha256: "e6d5ccd503d41f938f6cfc4dc9e7326ffe28acabe091b1ff0c6535bdf09732dd" - "0.59.3": - url: "https://github.com/mesonbuild/meson/archive/0.59.3.tar.gz" - sha256: "b2c5bfd5032189a66cf6a32d98ba82d94d7d314577d8efe4d9dc159c4073f282" - "0.60.2": - url: "https://github.com/mesonbuild/meson/archive/0.60.2.tar.gz" - sha256: "fc7c2f315b5b63fee0414b0b94b5a7d0e9c71c8c9bb8487314eb5a9a33984b8d" - "0.61.2": - url: "https://github.com/mesonbuild/meson/archive/0.61.2.tar.gz" - sha256: "33cd555314a94d52acfbb3f6f44d4e61c4ad0bfec7acf4301be7e40bb969b3a8" - "0.62.0": - url: "https://github.com/mesonbuild/meson/archive/0.62.0.tar.gz" - sha256: "72ac3bab701dfd597604de29cc74baaa1cc0ad8ca26ae23d5288de26abfe1c80" - "0.62.1": - url: "https://github.com/mesonbuild/meson/archive/0.62.1.tar.gz" - sha256: "9fb52e66dbc613479a5f70e46cc2e8faf5aa65e09313f2c71fa63b8afd018107" - 0.62.2: - sha256: "97108f4d9bb16bc758c44749bd25ec7d42c6a762961efbed8b7589a2a3551ea6" - url: "https://github.com/mesonbuild/meson/archive/0.62.2.tar.gz" - "0.63.0": - url: "https://github.com/mesonbuild/meson/archive/0.63.0.tar.gz" - sha256: "77808d47fa05875c2553d66cb6c6140c2f687b46256dc537eeb8a63889e0bea2" + "0.63.2": + url: "https://github.com/mesonbuild/meson/archive/0.63.2.tar.gz" + sha256: "023a3f7c74e68991154c3205a6975705861eedbf8130e013d15faa1df1af216e" "0.63.1": url: "https://github.com/mesonbuild/meson/archive/0.63.1.tar.gz" sha256: "f355829f0e8c714423f03a06604c04c216d4cbe3586f3154cb2181076b19207a" + "0.63.0": + url: "https://github.com/mesonbuild/meson/archive/0.63.0.tar.gz" + sha256: "77808d47fa05875c2553d66cb6c6140c2f687b46256dc537eeb8a63889e0bea2" + "0.62.2": + url: "https://github.com/mesonbuild/meson/archive/0.62.2.tar.gz" + sha256: "97108f4d9bb16bc758c44749bd25ec7d42c6a762961efbed8b7589a2a3551ea6" + "0.62.1": + url: "https://github.com/mesonbuild/meson/archive/0.62.1.tar.gz" + sha256: "9fb52e66dbc613479a5f70e46cc2e8faf5aa65e09313f2c71fa63b8afd018107" + "0.62.0": + url: "https://github.com/mesonbuild/meson/archive/0.62.0.tar.gz" + sha256: "72ac3bab701dfd597604de29cc74baaa1cc0ad8ca26ae23d5288de26abfe1c80" + "0.61.2": + url: "https://github.com/mesonbuild/meson/archive/0.61.2.tar.gz" + sha256: "33cd555314a94d52acfbb3f6f44d4e61c4ad0bfec7acf4301be7e40bb969b3a8" + "0.60.2": + url: "https://github.com/mesonbuild/meson/archive/0.60.2.tar.gz" + sha256: "fc7c2f315b5b63fee0414b0b94b5a7d0e9c71c8c9bb8487314eb5a9a33984b8d" + "0.59.3": + url: "https://github.com/mesonbuild/meson/archive/0.59.3.tar.gz" + sha256: "b2c5bfd5032189a66cf6a32d98ba82d94d7d314577d8efe4d9dc159c4073f282" + "0.58.1": + url: "https://github.com/mesonbuild/meson/archive/0.58.1.tar.gz" + sha256: "78e0f553dd3bc632d5f96ab943b1bbccb599c2c84ff27c5fb7f7fff9c8a3f6b4" + "0.57.2": + url: "https://github.com/mesonbuild/meson/archive/0.57.2.tar.gz" + sha256: "cd3773625253df4fd1c380faf03ffae3d02198d6301e7c8bc7bba6c66af66096" + "0.56.2": + url: "https://github.com/mesonbuild/meson/archive/0.56.2.tar.gz" + sha256: "aaae961c3413033789248ffe6762589e80b6cf487c334d0b808e31a32c48f35f" + "0.55.3": + url: "https://github.com/mesonbuild/meson/archive/0.55.3.tar.gz" + sha256: "2b276df50c5b13ccdbfb14d3333141e9e7985aca31b60400b3f3e0be2ee6897e" diff --git a/recipes/meson/all/conanfile.py b/recipes/meson/all/conanfile.py index 33062c86b17ea..dfb05d6d59a9e 100644 --- a/recipes/meson/all/conanfile.py +++ b/recipes/meson/all/conanfile.py @@ -1,71 +1,84 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.files import copy, get, rmdir, save +from conan.tools.layout import basic_layout import os import textwrap -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" -class MesonInstallerConan(ConanFile): +class MesonConan(ConanFile): name = "meson" description = "Meson is a project to create the best possible next-generation build system" topics = ("meson", "mesonbuild", "build-system") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/mesonbuild/meson" license = "Apache-2.0" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - _source_subfolder = "source_subfolder" + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) def requirements(self): - self.requires("ninja/1.10.2") + self.requires("ninja/1.11.0") def package_id(self): - self.info.header_only() + self.info.clear() - def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + def layout(self): + basic_layout(self, src_folder="src") - # create wrapper scripts - tools.save(os.path.join(self._source_subfolder, "meson.cmd"), textwrap.dedent("""\ - @echo off - CALL python %~dp0/meson.py %* - """)) - tools.save(os.path.join(self._source_subfolder, "meson"), textwrap.dedent("""\ - #!/usr/bin/env bash - meson_dir=$(dirname "$0") - exec "$meson_dir/meson.py" "$@" - """)) - - @staticmethod - def _chmod_plus_x(filename): - if os.name == "posix": - os.chmod(filename, os.stat(filename).st_mode | 0o111) + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def package(self): # FIXME: https://github.com/conan-io/conan/issues/10726 def _fix_symlinks(root, files): - if not tools.os_info.is_windows: + if not self._settings_build.os == "Windows": return for filename in files: filename = os.path.join(root, filename) if os.path.islink(filename): target = os.readlink(filename) if "/" in target: - self.output.info("fixing broken link {}".format(target)) + self.output.info(f"fixing broken link {target}") target = target.replace("/", "\\") os.unlink(filename) os.symlink(target, filename) - for root, dirs, files in os.walk(self.source_folder, self._source_subfolder): + for root, dirs, files in os.walk(self.source_folder): _fix_symlinks(root, dirs) _fix_symlinks(root, files) - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - self.copy(pattern="*", dst="bin", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, "bin", "test cases")) + + def build(self): + pass + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=self.source_folder, dst=os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "bin", "test cases")) + + # create wrapper scripts + save(self, os.path.join(self.package_folder, "bin", "meson.cmd"), textwrap.dedent("""\ + @echo off + CALL python %~dp0/meson.py %* + """)) + save(self, os.path.join(self.package_folder, "bin", "meson"), textwrap.dedent("""\ + #!/usr/bin/env bash + meson_dir=$(dirname "$0") + exec "$meson_dir/meson.py" "$@" + """)) + + @staticmethod + def _chmod_plus_x(filename): + if os.name == "posix": + os.chmod(filename, os.stat(filename).st_mode | 0o111) def package_info(self): meson_root = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(meson_root)) + self.output.info(f"Appending PATH environment variable: {meson_root}") self.env_info.PATH.append(meson_root) self._chmod_plus_x(os.path.join(meson_root, "meson")) @@ -73,4 +86,7 @@ def package_info(self): self.cpp_info.builddirs = [os.path.join("bin", "mesonbuild", "cmake", "data")] + self.cpp_info.frameworkdirs = [] self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/meson/all/test_package/conanfile.py b/recipes/meson/all/test_package/conanfile.py index f681074ef1deb..946c63a8024cb 100644 --- a/recipes/meson/all/test_package/conanfile.py +++ b/recipes/meson/all/test_package/conanfile.py @@ -1,21 +1,28 @@ -from conans import ConanFile, Meson, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "pkg_config" + settings = "os", "arch", "compiler", "build_type" + generators = "MesonToolchain", "VirtualBuildEnv", "VirtualRunEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + def layout(self): + basic_layout(self) def build(self): - if not tools.cross_building(self): - with tools.environment_append(tools.RunEnvironment(self).vars): - meson = Meson(self) - meson.configure(build_folder="build") - meson.build() + meson = Meson(self) + meson.configure() + meson.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("build", "test_package") - self.run(bin_path, run_environment=True) - - self.run("meson --version", run_environment=True) + self.run("meson --version") + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/meson/all/test_v1_package/conanfile.py b/recipes/meson/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c8624c6f85f40 --- /dev/null +++ b/recipes/meson/all/test_v1_package/conanfile.py @@ -0,0 +1,22 @@ +from conans import ConanFile, Meson, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + test_type = "explicit" + + def build_requirements(self): + self.build_requires(self.tested_reference_str) + + def build(self): + if not tools.cross_building(self): + meson = Meson(self) + meson.configure(build_folder="build") + meson.build() + + def test(self): + self.run("meson --version") + if not tools.cross_building(self): + bin_path = os.path.join("build", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/meson/all/test_v1_package/meson.build b/recipes/meson/all/test_v1_package/meson.build new file mode 100644 index 0000000000000..e67dd979af3c4 --- /dev/null +++ b/recipes/meson/all/test_v1_package/meson.build @@ -0,0 +1,2 @@ +project('test_package', 'cpp') +executable('test_package', '../test_package/test_package.cpp') diff --git a/recipes/meson/config.yml b/recipes/meson/config.yml index 70b6375837050..07ee0c49f572f 100644 --- a/recipes/meson/config.yml +++ b/recipes/meson/config.yml @@ -1,69 +1,27 @@ versions: - # "0.51.0": - # folder: all - "0.51.2": + "0.63.2": folder: all - # "0.52.0": - # folder: all - "0.52.1": - folder: all - # "0.53.0": - # folder: all - # "0.53.1": - # folder: all - "0.53.2": - folder: all - # "0.54.0": - # folder: all - # "0.54.1": - # folder: all - # "0.54.2": - # folder: all - "0.54.3": + "0.63.1": folder: all - # "0.55.0": - # folder: all - # "0.55.1": - # folder: all - # "0.55.2": - # folder: all - "0.55.3": + "0.63.0": folder: all - # "0.56.0": - # folder: all - # "0.56.1": - # folder: all - "0.56.2": + "0.62.2": folder: all - # "0.57.0": - # folder: all - # "0.57.1": - # folder: all - "0.57.2": + "0.62.1": folder: all - # "0.58.0": - # folder: all - "0.58.1": + "0.62.0": folder: all - # "0.59.0": - # folder: all - # "0.59.1": - # folder: all - # "0.59.2": - # folder: all - "0.59.3": + "0.61.2": folder: all "0.60.2": folder: all - "0.61.2": - folder: all - "0.62.0": + "0.59.3": folder: all - "0.62.1": + "0.58.1": folder: all - "0.62.2": + "0.57.2": folder: all - "0.63.0": + "0.56.2": folder: all - "0.63.1": + "0.55.3": folder: all diff --git a/recipes/mingw-w64/linux/conanfile.py b/recipes/mingw-w64/linux/conanfile.py index 0aac88eb400c0..1e781d08b3204 100644 --- a/recipes/mingw-w64/linux/conanfile.py +++ b/recipes/mingw-w64/linux/conanfile.py @@ -1,16 +1,21 @@ import os -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.files import get, mkdir, chdir, rm, rmdir +from conan.errors import ConanInvalidConfiguration +from conans import tools, AutoToolsBuildEnvironment + + +required_conan_version = ">=1.50.0" class MingwConan(ConanFile): name = "mingw-w64" description = "MinGW is a contraction of Minimalist GNU for Windows" url = "https://github.com/conan-io/conan-center-index" - homepage = "http://mingw-w64.org/doku.php" + homepage = "https://www.mingw-w64.org/" license = "ZPL-2.1", "MIT", "GPL-2.0-or-later" topics = ("gcc", "gnu", "unix", "mingw32", "binutils") - settings = "os", "arch" + settings = "os", "arch", "build_type", "compiler" options = {"threads": ["posix", "win32"], "exception": ["seh", "sjlj"], "gcc": ["10.3.0"]} default_options = {"threads": "posix", "exception": "seh", "gcc": "10.3.0"} no_copy_source = True @@ -41,6 +46,10 @@ def build_requirements(self): self.build_requires("mpfr/4.1.0") self.build_requires("mpc/1.2.0") + def package_id(self): + del self.info.settings.compiler + del self.info.settings.build_type + def _download_source(self): arch_data = self.conan_data["sources"][self.version] @@ -48,10 +57,10 @@ def _download_source(self): if package == "gcc": continue self.output.info("Downloading {} from {}".format(package, arch_data[package]['url'])) - tools.get(**arch_data[package], strip_root=True, destination=os.path.join(self.build_folder, "sources", package)) + get(self, **arch_data[package], strip_root=True, destination=os.path.join(self.build_folder, "sources", package)) # Download gcc version gcc_data = arch_data["gcc"][str(self.options.gcc)] - tools.get(**gcc_data, strip_root=True, destination=os.path.join(self.build_folder, "sources", "gcc")) + get(self, **gcc_data, strip_root=True, destination=os.path.join(self.build_folder, "sources", "gcc")) @property def _target_tag(self): @@ -87,8 +96,8 @@ def build(self): ] self.output.info("Building binutils ...") - os.mkdir(os.path.join(self.build_folder, "binutils")) - with tools.chdir(os.path.join(self.build_folder, "binutils")): + mkdir(self, os.path.join(self.build_folder, "binutils")) + with chdir(self, os.path.join(self.build_folder, "binutils")): autotools = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", @@ -105,8 +114,8 @@ def build(self): autotools.install() self.output.info("Building mingw-w64-tools ...") - os.mkdir(os.path.join(self.build_folder, "mingw-w64-tools")) - with tools.chdir(os.path.join(self.build_folder, "mingw-w64-tools")): + mkdir(self, os.path.join(self.build_folder, "mingw-w64-tools")) + with chdir(self, os.path.join(self.build_folder, "mingw-w64-tools")): autotools = AutoToolsBuildEnvironment(self) conf_args = [] autotools.configure(configure_dir=os.path.join(self.build_folder, "sources", "mingw-w64", "mingw-w64-tools", "widl"), @@ -115,8 +124,8 @@ def build(self): autotools.install() self.output.info("Building mingw-w64-headers ...") - os.mkdir(os.path.join(self.build_folder, "mingw-w64-headers")) - with tools.chdir(os.path.join(self.build_folder, "mingw-w64-headers")): + mkdir(self, os.path.join(self.build_folder, "mingw-w64-headers")) + with chdir(self, os.path.join(self.build_folder, "mingw-w64-headers")): autotools = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", @@ -144,8 +153,8 @@ def build(self): os.path.join(self.package_folder, target_tag, 'lib64'))) self.output.info("Building core gcc ...") - os.mkdir(os.path.join(self.build_folder, "gcc")) - with tools.chdir(os.path.join(self.build_folder, "gcc")): + mkdir(self, os.path.join(self.build_folder, "gcc")) + with chdir(self, os.path.join(self.build_folder, "gcc")): autotools_gcc = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", @@ -183,8 +192,8 @@ def build(self): env_compiler["CXX"] = target_tag + "-g++" with tools.environment_append(env_compiler): self.output.info("Building mingw-w64-crt ...") - os.mkdir(os.path.join(self.build_folder, "mingw-w64-crt")) - with tools.chdir(os.path.join(self.build_folder, "mingw-w64-crt")): + mkdir(self, os.path.join(self.build_folder, "mingw-w64-crt")) + with chdir(self, os.path.join(self.build_folder, "mingw-w64-crt")): autotools = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", @@ -201,8 +210,8 @@ def build(self): if self.options.threads == "posix": self.output.info("Building mingw-w64-libraries-winpthreads ...") - os.mkdir(os.path.join(self.build_folder, "mingw-w64-libraries-winpthreads")) - with tools.chdir(os.path.join(self.build_folder, "mingw-w64-libraries-winpthreads")): + mkdir(self, os.path.join(self.build_folder, "mingw-w64-libraries-winpthreads")) + with chdir(self, os.path.join(self.build_folder, "mingw-w64-libraries-winpthreads")): autotools = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", @@ -215,7 +224,7 @@ def build(self): autotools.install() self.output.info("Building libgcc ...") - with tools.chdir(os.path.join(self.build_folder, "gcc")): + with chdir(self, os.path.join(self.build_folder, "gcc")): autotools_gcc.make() autotools_gcc.install() @@ -223,10 +232,10 @@ def build(self): def package(self): self.copy("COPYING", src=os.path.join(self.build_folder, "sources", "mingw-w64"), dst="licenses") - tools.remove_files_by_mask(self.package_folder, "*.la") - tools.rmdir(os.path.join(self.package_folder, "share", "man")) - tools.rmdir(os.path.join(self.package_folder, "share", "doc")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", self.package_folder, recursive=True) + rmdir(self, os.path.join(self.package_folder, "share", "man")) + rmdir(self, os.path.join(self.package_folder, "share", "doc")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) # replace with relative symlinks so they'll resolve correctly on consumer's machine os.unlink(os.path.join(self.package_folder, 'mingw')) os.unlink(os.path.join(self.package_folder, self._target_tag, 'lib64')) diff --git a/recipes/mingw-w64/linux/test_package/conanfile.py b/recipes/mingw-w64/linux/test_package/conanfile.py index 8be9692ac3c56..b6ef323de8d96 100644 --- a/recipes/mingw-w64/linux/test_package/conanfile.py +++ b/recipes/mingw-w64/linux/test_package/conanfile.py @@ -1,5 +1,6 @@ import os -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import cross_building class MinGWTestConan(ConanFile): @@ -11,5 +12,5 @@ def build(self): self.run("x86_64-w64-mingw32-g++ {} @conanbuildinfo.gcc -lstdc++ -o main".format(source_file), run_environment=True) def test(self): - if not tools.cross_building(self): + if not cross_building(self): self.run("x86_64-w64-mingw32-g++ --version", run_environment=True) diff --git a/recipes/mongo-c-driver/all/CMakeLists.txt b/recipes/mongo-c-driver/all/CMakeLists.txt deleted file mode 100644 index 083fd1875e429..0000000000000 --- a/recipes/mongo-c-driver/all/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory(source_subfolder) - -if(MSVC) - # Should be added because of - # https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initonceexecuteonce - add_definitions(-D_WIN32_WINNT=0x0600) -endif() diff --git a/recipes/mongo-c-driver/all/conandata.yml b/recipes/mongo-c-driver/all/conandata.yml index 47c9297cb5691..2546c26f4700e 100644 --- a/recipes/mongo-c-driver/all/conandata.yml +++ b/recipes/mongo-c-driver/all/conandata.yml @@ -17,20 +17,13 @@ sources: patches: "1.22.0": - patch_file: "patches/1.22.0-0001-disable-shared-when-static.patch" - base_path: "source_subfolder" - patch_file: "patches/1.22.0-0002-fix-uninitialized-warning.patch" - base_path: "source_subfolder" - patch_file: "patches/1.22.0-0003-disable-warning-errors.patch" - base_path: "source_subfolder" "1.17.6": - patch_file: "patches/1.17.6-0001-disable-shared-when-static.patch" - base_path: "source_subfolder" "1.17.4": - patch_file: "patches/1.17.2-0001-disable-shared-when-static.patch" - base_path: "source_subfolder" "1.17.3": - patch_file: "patches/1.17.2-0001-disable-shared-when-static.patch" - base_path: "source_subfolder" "1.17.2": - patch_file: "patches/1.17.2-0001-disable-shared-when-static.patch" - base_path: "source_subfolder" diff --git a/recipes/mongo-c-driver/all/conanfile.py b/recipes/mongo-c-driver/all/conanfile.py index 3e11f583e4a90..c046165084403 100644 --- a/recipes/mongo-c-driver/all/conanfile.py +++ b/recipes/mongo-c-driver/all/conanfile.py @@ -1,9 +1,15 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, get, replace_in_file, rmdir +from conan.tools.gnu import PkgConfigDeps +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os -import functools -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.51.3" class MongoCDriverConan(ConanFile): @@ -39,20 +45,10 @@ class MongoCDriverConan(ConanFile): } short_paths = True - generators = "cmake", "cmake_find_package", "pkg_config" - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -62,8 +58,14 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass def requirements(self): if self.options.with_ssl == "openssl": @@ -82,39 +84,23 @@ def requirements(self): self.requires("icu/71.1") def validate(self): - if self.options.with_ssl == "darwin" and not tools.is_apple_os(self.settings.os): + if self.info.options.with_ssl == "darwin" and not is_apple_os(self.settings.os): raise ConanInvalidConfiguration("with_ssl=darwin only allowed on Apple os family") - if self.options.with_ssl == "windows" and self.settings.os != "Windows": + if self.info.options.with_ssl == "windows" and self.info.settings.os != "Windows": raise ConanInvalidConfiguration("with_ssl=windows only allowed on Windows") - if self.options.with_sasl == "sspi" and self.settings.os != "Windows": + if self.info.options.with_sasl == "sspi" and self.info.settings.os != "Windows": raise ConanInvalidConfiguration("with_sasl=sspi only allowed on Windows") def build_requirements(self): if self.options.with_ssl == "libressl" or self.options.with_zstd: - self.build_requires("pkgconf/1.7.4") + self.tool_requires("pkgconf/1.7.4") - def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + def layout(self): + cmake_layout(self, src_folder="src") - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - to_replace_old_new = [ - # Fix Snappy - {"old": "include (FindSnappy)\nif (SNAPPY_INCLUDE_DIRS)", - "new": "if(ENABLE_SNAPPY MATCHES \"ON\")\n find_package(Snappy REQUIRED)"}, - {"old": "SNAPPY_LIBRARIES", "new": "Snappy_LIBRARIES"}, - {"old": "SNAPPY_INCLUDE_DIRS", "new": "Snappy_INCLUDE_DIRS"}, - # Fix LibreSSL - {"old": "set (SSL_LIBRARIES -ltls -lcrypto)", "new": ""}, - ] - for old_new in to_replace_old_new: - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "libmongoc", "CMakeLists.txt"), - old_new["old"], old_new["new"]) - # cleanup rpath - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)", "") + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) @property def _ssl_cmake_value(self): @@ -132,65 +118,102 @@ def _sasl_cmake_value(self): "cyrus": "CYRUS", }.get(str(self.options.with_sasl), "OFF") - @functools.lru_cache(1) - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP"] = "TRUE" - cmake.definitions["ENABLE_SSL"] = self._ssl_cmake_value - cmake.definitions["ENABLE_SASL"] = self._sasl_cmake_value - cmake.definitions["ENABLE_STATIC"] = "OFF" if self.options.shared else "ON" - cmake.definitions["ENABLE_TESTS"] = "OFF" - cmake.definitions["ENABLE_EXAMPLES"] = "OFF" - cmake.definitions["ENABLE_SRV"] = "ON" if self.options.srv else "OFF" - cmake.definitions["ENABLE_MAINTAINER_FLAGS"] = "OFF" - cmake.definitions["ENABLE_AUTOMATIC_INIT_AND_CLEANUP"] = "ON" - cmake.definitions["ENABLE_CRYPTO_SYSTEM_PROFILE"] = "OFF" - cmake.definitions["ENABLE_TRACING"] = "OFF" - cmake.definitions["ENABLE_COVERAGE"] = "OFF" - cmake.definitions["ENABLE_SHM_COUNTERS"] = "OFF" - cmake.definitions["ENABLE_MONGOC"] = "ON" - cmake.definitions["ENABLE_BSON"] = "ON" - cmake.definitions["ENABLE_SNAPPY"] = "ON" if self.options.with_snappy else "OFF" - cmake.definitions["ENABLE_ZLIB"] = "SYSTEM" if self.options.with_zlib else "OFF" - cmake.definitions["ENABLE_ZSTD"] = "ON" if self.options.with_zstd else "OFF" - cmake.definitions["ENABLE_MAN_PAGES"] = False - cmake.definitions["ENABLE_HTML_DOCS"] = False - cmake.definitions["ENABLE_EXTRA_ALIGNMENT"] = True - cmake.definitions["ENABLE_RDTSCP"] = False - cmake.definitions["ENABLE_APPLE_FRAMEWORK"] = False - cmake.definitions["ENABLE_ICU"] = "ON" if self.options.with_icu else "OFF" - cmake.definitions["ENABLE_UNINSTALL"] = False - cmake.definitions["ENABLE_CLIENT_SIDE_ENCRYPTION"] = "OFF" # libmongocrypt recipe not yet in CCI - cmake.definitions["ENABLE_MONGODB_AWS_AUTH"] = "AUTO" - cmake.definitions["ENABLE_PIC"] = self.options.get_safe("fPIC", True) + def generate(self): + tc = CMakeToolchain(self) + # All these variables are option() declared before project() in upstream CMakeLists + # therefore it defeats conan_toolchain variables, but it works fine with cache_variables + tc.cache_variables["ENABLE_SSL"] = self._ssl_cmake_value + tc.cache_variables["ENABLE_SASL"] = self._sasl_cmake_value + tc.cache_variables["ENABLE_STATIC"] = "OFF" if self.options.shared else "ON" + tc.cache_variables["ENABLE_TESTS"] = "OFF" + tc.cache_variables["ENABLE_EXAMPLES"] = "OFF" + tc.cache_variables["ENABLE_SRV"] = "ON" if self.options.srv else "OFF" + tc.cache_variables["ENABLE_MAINTAINER_FLAGS"] = "OFF" + tc.cache_variables["ENABLE_AUTOMATIC_INIT_AND_CLEANUP"] = "ON" + tc.cache_variables["ENABLE_CRYPTO_SYSTEM_PROFILE"] = "OFF" + tc.cache_variables["ENABLE_TRACING"] = "OFF" + tc.cache_variables["ENABLE_COVERAGE"] = "OFF" + tc.cache_variables["ENABLE_SHM_COUNTERS"] = "OFF" + tc.cache_variables["ENABLE_MONGOC"] = "ON" + tc.cache_variables["ENABLE_BSON"] = "ON" + tc.cache_variables["ENABLE_SNAPPY"] = "ON" if self.options.with_snappy else "OFF" + tc.cache_variables["ENABLE_ZLIB"] = "SYSTEM" if self.options.with_zlib else "OFF" + tc.cache_variables["ENABLE_ZSTD"] = "ON" if self.options.with_zstd else "OFF" + tc.cache_variables["ENABLE_MAN_PAGES"] = "OFF" + tc.cache_variables["ENABLE_HTML_DOCS"] = "OFF" + tc.cache_variables["ENABLE_EXTRA_ALIGNMENT"] = "ON" + tc.cache_variables["ENABLE_RDTSCP"] = "OFF" + tc.cache_variables["ENABLE_APPLE_FRAMEWORK"] = "OFF" + tc.cache_variables["ENABLE_ICU"] = "ON" if self.options.with_icu else "OFF" + tc.cache_variables["ENABLE_UNINSTALL"] = "OFF" + tc.cache_variables["ENABLE_CLIENT_SIDE_ENCRYPTION"] = "OFF" # libmongocrypt recipe not yet in CCI + tc.cache_variables["ENABLE_MONGODB_AWS_AUTH"] = "AUTO" + tc.cache_variables["ENABLE_PIC"] = "ON" if self.options.get_safe("fPIC", True) else "OFF" + # Avoid to install vc runtime stuff + tc.variables["CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP"] = "TRUE" if self.options.with_ssl == "openssl": - cmake.definitions["OPENSSL_ROOT_DIR"] = self.deps_cpp_info["openssl"].rootpath - if tools.Version(self.version) >= "1.20.0": - cmake.definitions["MONGO_USE_CCACHE"] = False - cmake.configure(build_folder=self._build_subfolder) - return cmake + tc.variables["OPENSSL_ROOT_DIR"] = self.dependencies["openssl"].package_folder.replace("\\", "/") + if Version(self.version) >= "1.20.0": + tc.variables["MONGO_USE_CCACHE"] = False + if is_msvc(self): + # Should be added because of + # https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initonceexecuteonce + tc.preprocessor_definitions["_WIN32_WINNT"] = "0x0600" + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + if self.options.with_ssl == "libressl" or self.options.with_zstd: + deps = PkgConfigDeps(self) + deps.generate() + env = VirtualBuildEnv(self) + env.generate() + # TODO: to remove when properly handled by conan (see https://github.com/conan-io/conan/issues/11962) + env = Environment() + env.prepend_path("PKG_CONFIG_PATH", self.generators_folder) + envvars = env.vars(self) + envvars.save_script("conanbuildenv_pkg_config_path") + + def _patch_sources(self): + apply_conandata_patches(self) + to_replace_old_new = [ + # Fix Snappy + {"old": "include (FindSnappy)\nif (SNAPPY_INCLUDE_DIRS)", + "new": "if(ENABLE_SNAPPY MATCHES \"ON\")\n find_package(Snappy REQUIRED)"}, + {"old": "SNAPPY_LIBRARIES", "new": "Snappy_LIBRARIES"}, + {"old": "SNAPPY_INCLUDE_DIRS", "new": "Snappy_INCLUDE_DIRS"}, + # Fix LibreSSL + {"old": "set (SSL_LIBRARIES -ltls -lcrypto)", "new": ""}, + ] + for old_new in to_replace_old_new: + replace_in_file(self, os.path.join(self.source_folder, "src", "libmongoc", "CMakeLists.txt"), + old_new["old"], old_new["new"]) + # cleanup rpath + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)", "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - self.copy(pattern="THIRD_PARTY_NOTICES", dst="licenses", src=self._source_subfolder) - - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "THIRD_PARTY_NOTICES", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): # FIXME: two CMake module/config files should be generated (mongoc-1.0-config.cmake and bson-1.0-config.cmake), # but it can't be modeled right now. mongoc_target = "mongoc_shared" if self.options.shared else "mongoc_static" self.cpp_info.set_property("cmake_file_name", "mongoc-1.0") - self.cpp_info.set_property("cmake_target_name", "mongo::{}".format(mongoc_target)) + self.cpp_info.set_property("cmake_target_name", f"mongo::{mongoc_target}") self.cpp_info.filenames["cmake_find_package"] = "mongoc-1.0" self.cpp_info.filenames["cmake_find_package_multi"] = "mongoc-1.0" @@ -198,7 +221,7 @@ def package_info(self): self.cpp_info.names["cmake_find_package_multi"] = "mongo" # mongoc - self.cpp_info.components["mongoc"].set_property("cmake_target_name", "mongo::{}".format(mongoc_target)) + self.cpp_info.components["mongoc"].set_property("cmake_target_name", f"mongo::{mongoc_target}") self.cpp_info.components["mongoc"].set_property("pkg_config_name", "libmongoc-1.0" if self.options.shared else "libmongoc-static-1.0") self.cpp_info.components["mongoc"].names["cmake_find_package"] = mongoc_target @@ -236,7 +259,7 @@ def package_info(self): # bson bson_target = "bson_shared" if self.options.shared else "bson_static" - self.cpp_info.components["bson"].set_property("cmake_target_name", "mongo::{}".format(bson_target)) + self.cpp_info.components["bson"].set_property("cmake_target_name", f"mongo::{bson_target}") self.cpp_info.components["bson"].set_property("pkg_config_name", "libbson-1.0" if self.options.shared else "libbson-static-1.0") self.cpp_info.components["bson"].names["cmake_find_package"] = bson_target diff --git a/recipes/mongo-c-driver/all/test_package/CMakeLists.txt b/recipes/mongo-c-driver/all/test_package/CMakeLists.txt index 5cae93d19dc3f..9ed8451d03a20 100644 --- a/recipes/mongo-c-driver/all/test_package/CMakeLists.txt +++ b/recipes/mongo-c-driver/all/test_package/CMakeLists.txt @@ -1,14 +1,11 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES C) find_package(mongoc-1.0 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) if(TARGET mongo::mongoc_shared) - target_link_libraries(${PROJECT_NAME} mongo::mongoc_shared mongo::bson_shared) + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongoc_shared mongo::bson_shared) else() - target_link_libraries(${PROJECT_NAME} mongo::mongoc_static mongo::bson_static) + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongoc_static mongo::bson_static) endif() diff --git a/recipes/mongo-c-driver/all/test_package/conanfile.py b/recipes/mongo-c-driver/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/mongo-c-driver/all/test_package/conanfile.py +++ b/recipes/mongo-c-driver/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mongo-c-driver/all/test_v1_package/CMakeLists.txt b/recipes/mongo-c-driver/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9963c43bd4637 --- /dev/null +++ b/recipes/mongo-c-driver/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(mongoc-1.0 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +if(TARGET mongo::mongoc_shared) + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongoc_shared mongo::bson_shared) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongoc_static mongo::bson_static) +endif() diff --git a/recipes/mongo-c-driver/all/test_v1_package/conanfile.py b/recipes/mongo-c-driver/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mongo-c-driver/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/mongo-cxx-driver/all/CMakeLists.txt b/recipes/mongo-cxx-driver/all/CMakeLists.txt deleted file mode 100644 index ad95cfd8209a3..0000000000000 --- a/recipes/mongo-cxx-driver/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory("source_subfolder") diff --git a/recipes/mongo-cxx-driver/all/conandata.yml b/recipes/mongo-cxx-driver/all/conandata.yml index 7f38f964decdb..9c36439157a9b 100644 --- a/recipes/mongo-cxx-driver/all/conandata.yml +++ b/recipes/mongo-cxx-driver/all/conandata.yml @@ -14,29 +14,13 @@ sources: patches: "3.6.7": - patch_file: "patches/dirs_and_tests.patch" - base_path: "source_subfolder" - - patch_file: "patches/link_conan_boost.patch" - base_path: "source_subfolder" - patch_file: "patches/poly_use_std_define.patch" - base_path: "source_subfolder" "3.6.6": - patch_file: "patches/dirs_and_tests.patch" - base_path: "source_subfolder" - - patch_file: "patches/link_conan_boost.patch" - base_path: "source_subfolder" - patch_file: "patches/poly_use_std_define.patch" - base_path: "source_subfolder" "3.6.2": - patch_file: "patches/dirs_and_tests.patch" - base_path: "source_subfolder" - - patch_file: "patches/link_conan_boost.patch" - base_path: "source_subfolder" - patch_file: "patches/poly_use_std_define.patch" - base_path: "source_subfolder" "3.6.1": - patch_file: "patches/dirs_and_tests.patch" - base_path: "source_subfolder" - - patch_file: "patches/link_conan_boost.patch" - base_path: "source_subfolder" - patch_file: "patches/poly_use_std_define.patch" - base_path: "source_subfolder" diff --git a/recipes/mongo-cxx-driver/all/conanfile.py b/recipes/mongo-cxx-driver/all/conanfile.py index f8db16bdc2ac4..0325bf551fe00 100644 --- a/recipes/mongo-cxx-driver/all/conanfile.py +++ b/recipes/mongo-cxx-driver/all/conanfile.py @@ -1,9 +1,13 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanException, ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd, valid_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rm, rmdir +from conan.tools.scm import Version import os import shutil -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.51.1" class MongoCxxConan(ConanFile): @@ -28,21 +32,9 @@ class MongoCxxConan(ConanFile): "with_ssl": True, } - generators = "cmake", "cmake_find_package" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -53,9 +45,9 @@ def configure(self): del self.options.fPIC def requirements(self): - self.requires("mongo-c-driver/1.17.6") + self.requires("mongo-c-driver/1.22.0") if self.options.polyfill == "boost": - self.requires("boost/1.78.0") + self.requires("boost/1.79.0") @property def _minimal_std_version(self): @@ -68,7 +60,7 @@ def _minimal_std_version(self): @property def _compilers_minimum_version(self): - if self.options.polyfill == "std": + if self.info.options.polyfill == "std": # C++17 return { "Visual Studio": "15", @@ -76,7 +68,7 @@ def _compilers_minimum_version(self): "clang": "5", "apple-clang": "10" } - elif self.options.polyfill == "experimental": + elif self.info.options.polyfill == "experimental": # C++14 return { "Visual Studio": "15", @@ -84,7 +76,7 @@ def _compilers_minimum_version(self): "clang": "3.5", "apple-clang": "10" } - elif self.options.polyfill == "boost": + elif self.info.options.polyfill == "boost": # C++11 return { "Visual Studio": "14", @@ -93,95 +85,89 @@ def _compilers_minimum_version(self): "apple-clang": "9" } else: - raise ConanInvalidConfiguration( - "please, specify _compilers_minimum_version for {} polyfill".format(self.options.polyfill) + raise ConanException( + f"please, specify _compilers_minimum_version for {self.options.polyfill} polyfill" ) def validate(self): - if self.options.with_ssl and not bool(self.options["mongo-c-driver"].with_ssl): + if self.info.options.with_ssl and not bool(self.dependencies["mongo-c-driver"].options.with_ssl): raise ConanInvalidConfiguration("mongo-cxx-driver with_ssl=True requires mongo-c-driver with a ssl implementation") - if self.options.polyfill == "mnmlstc": + if self.info.options.polyfill == "mnmlstc": # TODO: add mnmlstc polyfill support # Cannot model mnmlstc (not packaged, is pulled dynamically) polyfill dependencies raise ConanInvalidConfiguration("mnmlstc polyfill is not yet supported") - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, self._minimal_std_version) + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._minimal_std_version) - compiler = str(self.settings.compiler) - if self.options.polyfill == "experimental" and compiler == "apple-clang": + compiler = str(self.info.settings.compiler) + if self.info.options.polyfill == "experimental" and compiler == "apple-clang": raise ConanInvalidConfiguration("experimental polyfill is not supported for apple-clang") - if compiler not in self._compilers_minimum_version: - self.output.warn("Unknown compiler, assuming it supports at least C++{}".format(self._minimal_std_version)) - return - - version = tools.Version(self.settings.compiler.version) - if version < self._compilers_minimum_version[compiler]: + version = Version(self.info.settings.compiler.version) + if compiler in self._compilers_minimum_version and version < self._compilers_minimum_version[compiler]: raise ConanInvalidConfiguration( - "{} requires a compiler that supports at least C++{}".format( - self.name, - self._minimal_std_version - ) + f"{self.name} {self.version} requires a compiler that supports at least C++{self._minimal_std_version}", ) + def layout(self): + cmake_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - - self._cmake = CMake(self) - self._cmake.definitions["BSONCXX_POLY_USE_MNMLSTC"] = self.options.polyfill == "mnmlstc" - self._cmake.definitions["BSONCXX_POLY_USE_STD"] = self.options.polyfill == "std" - self._cmake.definitions["BSONCXX_POLY_USE_STD_EXPERIMENTAL"] = self.options.polyfill == "experimental" - self._cmake.definitions["BSONCXX_POLY_USE_BOOST"] = self.options.polyfill == "boost" - self._cmake.definitions["BUILD_VERSION"] = self.version - self._cmake.definitions["BSONCXX_LINK_WITH_STATIC_MONGOC"] = not self.options["mongo-c-driver"].shared - self._cmake.definitions["MONGOCXX_LINK_WITH_STATIC_MONGOC"] = not self.options["mongo-c-driver"].shared - self._cmake.definitions["MONGOCXX_ENABLE_SSL"] = self.options.with_ssl - if not tools.valid_min_cppstd(self, self._minimal_std_version): - self._cmake.definitions["CMAKE_CXX_STANDARD"] = self._minimal_std_version + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BSONCXX_POLY_USE_MNMLSTC"] = self.options.polyfill == "mnmlstc" + tc.variables["BSONCXX_POLY_USE_STD"] = self.options.polyfill == "std" + tc.variables["BSONCXX_POLY_USE_STD_EXPERIMENTAL"] = self.options.polyfill == "experimental" + tc.variables["BSONCXX_POLY_USE_BOOST"] = self.options.polyfill == "boost" + tc.cache_variables["BUILD_VERSION"] = self.version + tc.cache_variables["BSONCXX_LINK_WITH_STATIC_MONGOC"] = "OFF" if self.dependencies["mongo-c-driver"].options.shared else "ON" + tc.cache_variables["MONGOCXX_LINK_WITH_STATIC_MONGOC"] = "OFF" if self.dependencies["mongo-c-driver"].options.shared else "ON" + tc.variables["MONGOCXX_ENABLE_SSL"] = self.options.with_ssl + if not valid_min_cppstd(self, self._minimal_std_version): + tc.variables["CMAKE_CXX_STANDARD"] = self._minimal_std_version + # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + deps = CMakeDeps(self) + deps.generate() # FIXME: two CMake module/config files should be generated (mongoc-1.0-config.cmake and bson-1.0-config.cmake), # but it can't be modeled right now. # Fix should happen in mongo-c-driver recipe - if not os.path.exists("Findbson-1.0.cmake"): + mongoc_config_file = os.path.join(self.generators_folder, "mongoc-1.0-config.cmake") + bson_config_file = os.path.join(self.generators_folder, "bson-1.0-config.cmake") + if not os.path.exists(bson_config_file): self.output.info("Copying mongoc config file to bson") - shutil.copy("Findmongoc-1.0.cmake", "Findbson-1.0.cmake") - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + shutil.copy(src=mongoc_config_file, dst=bson_config_file) def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - self.copy(pattern="THIRD-PARTY-NOTICES", dst="licenses", src=self._source_subfolder) - - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "THIRD-PARTY-NOTICES", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - if self.settings.os == "Windows": for vc_file in ("concrt", "msvcp", "vcruntime"): - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "{}*.dll".format(vc_file)) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, f"{vc_file}*.dll", os.path.join(self.package_folder, "bin")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): # FIXME: two CMake module/config files should be generated (mongocxx-config.cmake and bsoncxx-config.cmake), # but it can't be modeled right now. mongocxx_target = "mongocxx_shared" if self.options.shared else "mongocxx_static" self.cpp_info.set_property("cmake_file_name", "mongocxx") - self.cpp_info.set_property("cmake_target_name", "mongo::{}".format(mongocxx_target)) + self.cpp_info.set_property("cmake_target_name", f"mongo::{mongocxx_target}") self.cpp_info.filenames["cmake_find_package"] = "mongocxx" self.cpp_info.filenames["cmake_find_package_multi"] = "mongocxx" @@ -189,7 +175,7 @@ def package_info(self): self.cpp_info.names["cmake_find_package_multi"] = "mongo" # mongocxx - self.cpp_info.components["mongocxx"].set_property("cmake_target_name", "mongo::{}".format(mongocxx_target)) + self.cpp_info.components["mongocxx"].set_property("cmake_target_name", f"mongo::{mongocxx_target}") self.cpp_info.components["mongocxx"].set_property("pkg_config_name", "libmongocxx" if self.options.shared else "libmongocxx-static") self.cpp_info.components["mongocxx"].names["cmake_find_package"] = mongocxx_target @@ -202,7 +188,7 @@ def package_info(self): # bsoncxx bsoncxx_target = "bsoncxx_shared" if self.options.shared else "bsoncxx_static" - self.cpp_info.components["bsoncxx"].set_property("cmake_target_name", "mongo::{}".format(bsoncxx_target)) + self.cpp_info.components["bsoncxx"].set_property("cmake_target_name", f"mongo::{bsoncxx_target}") self.cpp_info.components["bsoncxx"].set_property("pkg_config_name", "libbsoncxx" if self.options.shared else "libbsoncxx-static") self.cpp_info.components["bsoncxx"].names["cmake_find_package"] = bsoncxx_target @@ -213,4 +199,4 @@ def package_info(self): self.cpp_info.components["bsoncxx"].defines = ["BSONCXX_STATIC"] self.cpp_info.components["bsoncxx"].requires = ["mongo-c-driver::bson"] if self.options.polyfill == "boost": - self.cpp_info.components["bsoncxx"].requires.append("boost::boost") + self.cpp_info.components["bsoncxx"].requires.append("boost::headers") diff --git a/recipes/mongo-cxx-driver/all/patches/dirs_and_tests.patch b/recipes/mongo-cxx-driver/all/patches/dirs_and_tests.patch index 9febde050e8c8..f1fed9501d06a 100644 --- a/recipes/mongo-cxx-driver/all/patches/dirs_and_tests.patch +++ b/recipes/mongo-cxx-driver/all/patches/dirs_and_tests.patch @@ -61,7 +61,7 @@ index 7c79f45..0fcb305 100644 # Attempt to find libbson by new package name (without lib). -find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} QUIET) -+find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} REQUIRED) ++find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED) +set(bson-${LIBBSON_REQUIRED_ABI_VERSION}_FOUND TRUE) if(bson-${LIBBSON_REQUIRED_ABI_VERSION}_FOUND) diff --git a/recipes/mongo-cxx-driver/all/patches/link_conan_boost.patch b/recipes/mongo-cxx-driver/all/patches/link_conan_boost.patch deleted file mode 100644 index 759e014c4dce7..0000000000000 --- a/recipes/mongo-cxx-driver/all/patches/link_conan_boost.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake -index b38f9af..7ec9d72 100644 ---- a/cmake/BsoncxxUtil.cmake -+++ b/cmake/BsoncxxUtil.cmake -@@ -36,7 +36,7 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE) - if (CMAKE_VERSION VERSION_LESS 3.15.0) - target_include_directories(${TARGET} PUBLIC ${Boost_INCLUDE_DIRS}) - else() -- target_link_libraries(${TARGET} PUBLIC Boost::boost) -+ target_link_libraries(${TARGET} PUBLIC CONAN_PKG::boost) - endif() - endif() - diff --git a/recipes/mongo-cxx-driver/all/test_package/CMakeLists.txt b/recipes/mongo-cxx-driver/all/test_package/CMakeLists.txt index c7f8497c45f2a..3d606dc3359ce 100644 --- a/recipes/mongo-cxx-driver/all/test_package/CMakeLists.txt +++ b/recipes/mongo-cxx-driver/all/test_package/CMakeLists.txt @@ -1,23 +1,20 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) find_package(mongocxx REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) if(${MONGO-CXX-DRIVER_POLYFILL} STREQUAL "std") - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) elseif(${MONGO-CXX-DRIVER_POLYFILL} STREQUAL "experimental") - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) else() - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) endif() if(TARGET mongo::mongocxx_shared) - target_link_libraries(${PROJECT_NAME} mongo::mongocxx_shared mongo::bsoncxx_shared) + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongocxx_shared mongo::bsoncxx_shared) else() - target_link_libraries(${PROJECT_NAME} mongo::mongocxx_static mongo::bsoncxx_static) + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongocxx_static mongo::bsoncxx_static) endif() diff --git a/recipes/mongo-cxx-driver/all/test_package/conanfile.py b/recipes/mongo-cxx-driver/all/test_package/conanfile.py index 51b7ca5da9cc7..a650aa79a9355 100644 --- a/recipes/mongo-cxx-driver/all/test_package/conanfile.py +++ b/recipes/mongo-cxx-driver/all/test_package/conanfile.py @@ -1,17 +1,30 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["MONGO-CXX-DRIVER_POLYFILL"] = self.dependencies["mongo-cxx-driver"].options.polyfill + tc.generate() def build(self): cmake = CMake(self) - cmake.definitions["MONGO-CXX-DRIVER_POLYFILL"] = self.options["mongo-cxx-driver"].polyfill cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self): - self.run(os.path.join("bin", "test_package"), run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mongo-cxx-driver/all/test_v1_package/CMakeLists.txt b/recipes/mongo-cxx-driver/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..20e6aa5c91caf --- /dev/null +++ b/recipes/mongo-cxx-driver/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(mongocxx REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) + +if(${MONGO-CXX-DRIVER_POLYFILL} STREQUAL "std") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +elseif(${MONGO-CXX-DRIVER_POLYFILL} STREQUAL "experimental") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +else() + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +endif() + +if(TARGET mongo::mongocxx_shared) + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongocxx_shared mongo::bsoncxx_shared) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE mongo::mongocxx_static mongo::bsoncxx_static) +endif() diff --git a/recipes/mongo-cxx-driver/all/test_v1_package/conanfile.py b/recipes/mongo-cxx-driver/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..51b7ca5da9cc7 --- /dev/null +++ b/recipes/mongo-cxx-driver/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["MONGO-CXX-DRIVER_POLYFILL"] = self.options["mongo-cxx-driver"].polyfill + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/mpir/all/conanfile.py b/recipes/mpir/all/conanfile.py index 992889b82232d..3c6c16a085f0b 100644 --- a/recipes/mpir/all/conanfile.py +++ b/recipes/mpir/all/conanfile.py @@ -85,7 +85,7 @@ def _dll_or_lib(self): @property def _vcxproj_paths(self): - compiler_version = self.settings.compiler.version if Version(self.settings.compiler.version) <= "16" else "16" + compiler_version = self.settings.compiler.version if Version(self.settings.compiler.version) <= "17" else "17" build_subdir = "build.vc{}".format(compiler_version) vcxproj_paths = [ os.path.join(self._source_subfolder, build_subdir, diff --git a/recipes/msys2/all/conanfile.py b/recipes/msys2/all/conanfile.py index f997748dd0e15..335f7da9b6296 100644 --- a/recipes/msys2/all/conanfile.py +++ b/recipes/msys2/all/conanfile.py @@ -1,5 +1,6 @@ -from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration, ConanException +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration, ConanException +from conan.tools.files import chdir, get, replace_in_file import fnmatch import os import shutil @@ -8,12 +9,14 @@ try: import ctypes - from ctypes import wintypes except ImportError: pass except ValueError: pass +required_conan_version = ">=1.47.0" + + class lock: def __init__(self): self.handle = ctypes.windll.kernel32.CreateMutexA(None, 0, "Global\\ConanMSYS2".encode()) @@ -42,31 +45,39 @@ class MSYS2Conan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "http://www.msys2.org" license = "MSYS license" - topics = ("conan", "msys", "unix", "subsystem") - short_paths = True + topics = ("msys", "unix", "subsystem") + + settings = "os", "arch", "compiler", "build_type" # "exclude_files" "packages" "additional_packages" values are a comma separated list options = { - "exclude_files": "ANY", - "packages": "ANY", - "additional_packages": "ANY" + "exclude_files": ["ANY"], + "packages": ["ANY"], + "additional_packages": ["ANY"], } default_options = { "exclude_files": "*/link.exe", "packages": "base-devel,binutils,gcc", - "additional_packages": None + "additional_packages": None, } - settings = "os", "arch" + short_paths = True + + def package_id(self): + del self.info.settings.compiler + del self.info.settings.build_type def validate(self): - if self.settings.os != "Windows": + if self.info.settings.os != "Windows": raise ConanInvalidConfiguration("Only Windows supported") - if self.settings.arch != "x86_64": + if self.info.settings.arch != "x86_64": raise ConanInvalidConfiguration("Only Windows x64 supported") + def source(self): + # sources are different per configuration - do download in build + pass def _update_pacman(self): - with tools.chdir(os.path.join(self._msys_dir, "usr", "bin")): + with chdir(self, os.path.join(self._msys_dir, "usr", "bin")): try: self._kill_pacman() @@ -95,10 +106,12 @@ def _kill_pacman(self): err = subprocess.PIPE if os.path.exists(taskkill_exe): - taskkill_cmds = [taskkill_exe + " /f /t /im pacman.exe", - taskkill_exe + " /f /im gpg-agent.exe", - taskkill_exe + " /f /im dirmngr.exe", - taskkill_exe + ' /fi "MODULES eq msys-2.0.dll"'] + taskkill_cmds = [ + f"{taskkill_exe} /f /t /im pacman.exe", + f"{taskkill_exe} /f /im gpg-agent.exe", + f"{taskkill_exe} /f /im dirmngr.exe", + f'{taskkill_exe} /fi "MODULES eq msys-2.0.dll"', + ] for taskkill_cmd in taskkill_cmds: try: proc = subprocess.Popen(taskkill_cmd, stdout=out, stderr=err, bufsize=1) @@ -112,13 +125,9 @@ def _msys_dir(self): subdir = "msys64" return os.path.join(self.package_folder, "bin", subdir) - def source(self): - # sources are different per configuration - do download in build - pass - def build(self): - tools.get(**self.conan_data["sources"][self.version], - destination=os.path.join(self.package_folder, "bin")) + get(self, **self.conan_data["sources"][self.version], + destination=os.path.join(self.package_folder, "bin")) with lock(): self._do_build() @@ -131,11 +140,11 @@ def _do_build(self): self._update_pacman() - with tools.chdir(os.path.join(self._msys_dir, "usr", "bin")): + with chdir(self, os.path.join(self._msys_dir, "usr", "bin")): for package in packages: - self.run('bash -l -c "pacman -S %s --noconfirm"' % package) + self.run(f'bash -l -c "pacman -S {package} --noconfirm"') for package in ['pkgconf']: - self.run('bash -l -c "pacman -Rs -d -d $(pacman -Qsq %s) --noconfirm"' % package) + self.run(f'bash -l -c "pacman -Rs -d -d $(pacman -Qsq {package}) --noconfirm"') self._kill_pacman() @@ -149,7 +158,7 @@ def _do_build(self): os.utime(tmp_name, None) # Prepend the PKG_CONFIG_PATH environment variable with an eventual PKG_CONFIG_PATH environment variable - tools.replace_in_file(os.path.join(self._msys_dir, "etc", "profile"), + replace_in_file(self, os.path.join(self._msys_dir, "etc", "profile"), 'PKG_CONFIG_PATH="', 'PKG_CONFIG_PATH="$PKG_CONFIG_PATH:') def package(self): @@ -169,18 +178,23 @@ def package(self): def package_info(self): self.cpp_info.libdirs = [] self.cpp_info.includedirs = [] + self.cpp_info.resdirs = [] msys_root = self._msys_dir msys_bin = os.path.join(msys_root, "usr", "bin") + self.cpp_info.bindirs.append(msys_bin) - self.output.info("Creating MSYS_ROOT env var : %s" % msys_root) - self.env_info.MSYS_ROOT = msys_root + self.output.info(f"Creating MSYS_ROOT env var : {msys_root}") + self.buildenv_info.define_path("MSYS_ROOT", msys_root) - self.output.info("Creating MSYS_BIN env var : %s" % msys_bin) - self.env_info.MSYS_BIN = msys_bin + self.output.info(f"Creating MSYS_BIN env var : {msys_bin}") + self.buildenv_info.define_path("MSYS_BIN", msys_bin) + + self.conf_info.define("tools.microsoft.bash:subsystem", "msys2") + self.conf_info.define("tools.microsoft.bash:path", os.path.join(msys_bin, "bash.exe")) - self.output.info("Appending PATH env var with : " + msys_bin) + # conan v1 specific stuff + self.env_info.MSYS_ROOT = msys_root + self.env_info.MSYS_BIN = msys_bin + self.output.info(f"Appending PATH env var with : {msys_bin}") self.env_info.path.append(msys_bin) - - self.conf_info["tools.microsoft.bash:subsystem"] = "msys2" - self.conf_info["tools.microsoft.bash:path"] = os.path.join(msys_bin, "bash.exe") diff --git a/recipes/msys2/all/test_package/conanfile.py b/recipes/msys2/all/test_package/conanfile.py index eb3a4a0152e23..93ee00629e591 100644 --- a/recipes/msys2/all/test_package/conanfile.py +++ b/recipes/msys2/all/test_package/conanfile.py @@ -1,27 +1,35 @@ -from conans import ConanFile, tools -from conans.errors import ConanException +from conan import ConanFile +from conan.tools.env import Environment from io import StringIO -class TestPackage(ConanFile): - + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "VirtualBuildEnv" + test_type = "explicit" + + def build_requirements(self): + self.tool_requires(self.tested_reference_str) + + @property + def _secret_value(self): + return "SECRET_CONAN_PKG_VARIABLE" + + def generate(self): + env = Environment() + env.define("PKG_CONFIG_PATH", self._secret_value) + envvars = env.vars(self) + envvars.save_script("conanbuildenv_pkg_config_path") + def build(self): pass # nothing to do, skip hook warning def test(self): - bash = tools.which("bash.exe") - - if bash: - self.output.info("using bash.exe from: " + bash) - else: - raise ConanException("No instance of bash.exe could be found on %PATH%") - self.run('bash.exe -c ^"make --version^"') self.run('bash.exe -c ^"! test -f /bin/link^"') self.run('bash.exe -c ^"! test -f /usr/bin/link^"') - secret_value = "SECRET_CONAN_PKG_VARIABLE" - with tools.environment_append({"PKG_CONFIG_PATH": secret_value}): - output = StringIO() - self.run('bash.exe -c "echo $PKG_CONFIG_PATH"', output=output) - print(output.getvalue()) - assert secret_value in output.getvalue() + output = StringIO() + self.run('bash.exe -c "echo $PKG_CONFIG_PATH"', output=output) + print(output.getvalue()) + assert self._secret_value in output.getvalue() diff --git a/recipes/msys2/all/test_v1_package/conanfile.py b/recipes/msys2/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..9278b74eeb27b --- /dev/null +++ b/recipes/msys2/all/test_v1_package/conanfile.py @@ -0,0 +1,29 @@ +from conans import ConanFile, tools +from conans.errors import ConanException +from io import StringIO + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + def build(self): + pass # nothing to do, skip hook warning + + def test(self): + bash = tools.which("bash.exe") + + if bash: + self.output.info("using bash.exe from: " + bash) + else: + raise ConanException("No instance of bash.exe could be found on %PATH%") + + self.run('bash.exe -c ^"make --version^"') + self.run('bash.exe -c ^"! test -f /bin/link^"') + self.run('bash.exe -c ^"! test -f /usr/bin/link^"') + + secret_value = "SECRET_CONAN_PKG_VARIABLE" + with tools.environment_append({"PKG_CONFIG_PATH": secret_value}): + output = StringIO() + self.run('bash.exe -c "echo $PKG_CONFIG_PATH"', output=output) + print(output.getvalue()) + assert secret_value in output.getvalue() diff --git a/recipes/openssl/1.x.x/conanfile.py b/recipes/openssl/1.x.x/conanfile.py index 4002bcc2c4641..8483f75ebb8be 100644 --- a/recipes/openssl/1.x.x/conanfile.py +++ b/recipes/openssl/1.x.x/conanfile.py @@ -1,8 +1,9 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building from conan.tools.files import rename, get, rmdir from conan.tools.microsoft import is_msvc, msvc_runtime_flag -from conan.tools.build import cross_building -from conan.errors import ConanInvalidConfiguration -from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conans import AutoToolsBuildEnvironment, tools from contextlib import contextmanager from functools import total_ordering import fnmatch @@ -823,9 +824,7 @@ def package(self): @staticmethod def _create_cmake_module_variables(module_file): content = textwrap.dedent("""\ - if(DEFINED OpenSSL_FOUND) - set(OPENSSL_FOUND ${OpenSSL_FOUND}) - endif() + set(OPENSSL_FOUND TRUE) if(DEFINED OpenSSL_INCLUDE_DIR) set(OPENSSL_INCLUDE_DIR ${OpenSSL_INCLUDE_DIR}) endif() diff --git a/recipes/openssl/1.x.x/test_package/conanfile.py b/recipes/openssl/1.x.x/test_package/conanfile.py index cb46a8b111c15..13150b440fe8a 100644 --- a/recipes/openssl/1.x.x/test_package/conanfile.py +++ b/recipes/openssl/1.x.x/test_package/conanfile.py @@ -3,6 +3,8 @@ from conan.tools.build import cross_building import os +required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2" + class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" diff --git a/recipes/openssl/3.x.x/conanfile.py b/recipes/openssl/3.x.x/conanfile.py index d5d4f5eaefa64..ee14c8c94d4df 100644 --- a/recipes/openssl/3.x.x/conanfile.py +++ b/recipes/openssl/3.x.x/conanfile.py @@ -1,8 +1,9 @@ -from conan.tools.files import rename -from conan.tools.microsoft import is_msvc, msvc_runtime_flag -from conans import ConanFile, AutoToolsBuildEnvironment, tools +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration from conan.tools.build import cross_building -from conans.errors import ConanInvalidConfiguration +from conan.tools.files import get, rename, rmdir +from conan.tools.microsoft import is_msvc, msvc_runtime_flag +from conans import AutoToolsBuildEnvironment, tools import contextlib import fnmatch import functools @@ -149,8 +150,8 @@ def _use_nmake(self): return self._is_clangcl or is_msvc(self) def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) @property def _target(self): @@ -664,7 +665,7 @@ def package(self): else: self.copy("fips.so", src=provdir,dst="lib/ossl-modules") - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) self._create_cmake_module_variables( os.path.join(self.package_folder, self._module_file_rel_path) @@ -673,9 +674,7 @@ def package(self): @staticmethod def _create_cmake_module_variables(module_file): content = textwrap.dedent("""\ - if(DEFINED OpenSSL_FOUND) - set(OPENSSL_FOUND ${OpenSSL_FOUND}) - endif() + set(OPENSSL_FOUND TRUE) if(DEFINED OpenSSL_INCLUDE_DIR) set(OPENSSL_INCLUDE_DIR ${OpenSSL_INCLUDE_DIR}) endif() diff --git a/recipes/opentdf-client/all/conanfile.py b/recipes/opentdf-client/all/conanfile.py index 6bc8dc1355301..c9196497bfc1a 100644 --- a/recipes/opentdf-client/all/conanfile.py +++ b/recipes/opentdf-client/all/conanfile.py @@ -8,7 +8,7 @@ import functools import os -required_conan_version = ">=1.47.0" +required_conan_version = ">=1.51.3" class OpenTDFConan(ConanFile): @@ -38,8 +38,8 @@ def _minimum_cpp_standard(self): @property def _minimum_compilers_version(self): return { - "Visual Studio": "17" if Version(self.version) < "1.1.5" else "16", - "msvc": "19.22", + "Visual Studio": "17" if Version(self.version) < "1.1.5" else "15", + "msvc": "193" if Version(self.version) < "1.1.5" else "191", "gcc": "7.5.0", "clang": "12", "apple-clang": "12.0.0", @@ -51,17 +51,19 @@ def export_sources(self): self.copy(data["patch_file"]) def validate(self): + # check minimum cpp standard supported by compiler if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, self._minimum_cpp_standard) + # check minimum version of compiler min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) if not min_version: - self.output.warn(f"{self.name} recipe lacks information about the {self.settings.compiler} compiler support.") + self.output.warn(f'{self.name} recipe lacks information about the {self.settings.compiler} compiler support.') else: if Version(self.settings.compiler.version) < min_version: - raise ConanInvalidConfiguration(f"{self.name} requires C++{self._minimum_cpp_standard} support." - "The current compiler {self.settings.compiler} {self.settings.compiler.version} does not support it.") + raise ConanInvalidConfiguration(f'{self.name} requires {self.settings.compiler} {self.settings.compiler.version} but found {min_version}') + # Disallow MT and MTd if is_msvc_static_runtime(self): - raise ConanInvalidConfiguration("this package can not be built with MT or MTd at this time") + raise ConanInvalidConfiguration(f'{self.name} can not be built with MT or MTd at this time') def requirements(self): self.requires("openssl/1.1.1q") diff --git a/recipes/podofo/all/CMakeLists.txt b/recipes/podofo/all/CMakeLists.txt deleted file mode 100644 index 7fe866f8c15f8..0000000000000 --- a/recipes/podofo/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include("conanbuildinfo.cmake") -conan_basic_setup(TARGETS KEEP_RPATHS) - -add_subdirectory(source_subfolder) diff --git a/recipes/podofo/all/conandata.yml b/recipes/podofo/all/conandata.yml index eb9cdf5902a48..2735fdd5d425b 100644 --- a/recipes/podofo/all/conandata.yml +++ b/recipes/podofo/all/conandata.yml @@ -8,7 +8,9 @@ sources: patches: "0.9.7": - patch_file: "patches/0001-fix-cmake-0.9.7.patch" - base_path: "source_subfolder" + patch_description: "Link to conan libs and allow to build the tools without the tests and the examples" + patch_type: "conan" "0.9.6": - patch_file: "patches/0001-fix-cmake-0.9.6.patch" - base_path: "source_subfolder" + patch_description: "Link to conan libs and allow to build the tools without the tests and the examples" + patch_type: "conan" diff --git a/recipes/podofo/all/conanfile.py b/recipes/podofo/all/conanfile.py index 56205ceae3f65..a26c14d06ca68 100644 --- a/recipes/podofo/all/conanfile.py +++ b/recipes/podofo/all/conanfile.py @@ -1,8 +1,13 @@ -from conans import ConanFile, CMake, tools -import functools import os +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version -required_conan_version = ">=1.36.0" +required_conan_version = ">=1.50.0" class PodofoConan(ConanFile): @@ -24,6 +29,7 @@ class PodofoConan(ConanFile): "with_tiff": [True, False], "with_png": [True, False], "with_unistring": [True, False], + "with_tools": [True, False], } default_options = { "shared": False, @@ -35,31 +41,17 @@ class PodofoConan(ConanFile): "with_tiff": True, "with_png": True, "with_unistring": True, + "with_tools": False, } - generators = "cmake", "cmake_find_package" - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - - @property - def _is_msvc(self): - return str(self.settings.compiler) in ["Visual Studio", "msvc"] - def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - if self._is_msvc: + if is_msvc(self): # libunistring recipe raises for Visual Studio # TODO: Enable again when fixed? self.options.with_unistring = False @@ -80,59 +72,68 @@ def requirements(self): if self.options.with_jpeg: self.requires("libjpeg/9d") if self.options.with_tiff: - self.requires("libtiff/4.3.0") + self.requires("libtiff/4.4.0") if self.options.with_png: self.requires("libpng/1.6.37") if self.options.with_unistring: self.requires("libunistring/0.9.10") def validate(self): - if self.settings.compiler.get_safe("cppstd") and tools.Version(self.version) >= "0.9.7": - tools.check_min_cppstd(self, 11) + if self.info.settings.compiler.get_safe("cppstd") and Version(self.version) >= "0.9.7": + check_min_cppstd(self, 11) - def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + def layout(self): + cmake_layout(self, src_folder="src") - @functools.lru_cache(1) - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["PODOFO_BUILD_LIB_ONLY"] = True - cmake.definitions["PODOFO_BUILD_SHARED"] = self.options.shared - cmake.definitions["PODOFO_BUILD_STATIC"] = not self.options.shared + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["PODOFO_BUILD_TOOLS"] = self.options.with_tools + tc.variables["PODOFO_BUILD_SHARED"] = self.options.shared + tc.variables["PODOFO_BUILD_STATIC"] = not self.options.shared if not self.options.threadsafe: - cmake.definitions["PODOFO_NO_MULTITHREAD"] = True - if not tools.valid_min_cppstd(self, 11) and tools.Version(self.version) >= "0.9.7": - cmake.definitions["CMAKE_CXX_STANDARD"] = 11 + tc.variables["PODOFO_NO_MULTITHREAD"] = True + try: + check_min_cppstd(self, 11) + except ConanInvalidConfiguration: + if Version(self.version) >= "0.9.7": + tc.cache_variables["CMAKE_CXX_STANDARD"] = 11 # To install relocatable shared lib on Macos - cmake.definitions["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" # Custom CMake options injected in our patch, required to ensure reproducible builds - cmake.definitions["PODOFO_WITH_OPENSSL"] = self.options.with_openssl - cmake.definitions["PODOFO_WITH_LIBIDN"] = self.options.with_libidn - cmake.definitions["PODOFO_WITH_LIBJPEG"] = self.options.with_jpeg - cmake.definitions["PODOFO_WITH_TIFF"] = self.options.with_tiff - cmake.definitions["PODOFO_WITH_PNG"] = self.options.with_png - cmake.definitions["PODOFO_WITH_UNISTRING"] = self.options.with_unistring - - cmake.configure(build_folder=self._build_subfolder) - return cmake + tc.variables["PODOFO_WITH_OPENSSL"] = self.options.with_openssl + tc.variables["PODOFO_WITH_LIBIDN"] = self.options.with_libidn + tc.variables["PODOFO_WITH_LIBJPEG"] = self.options.with_jpeg + tc.variables["PODOFO_WITH_TIFF"] = self.options.with_tiff + tc.variables["PODOFO_WITH_PNG"] = self.options.with_png + tc.variables["PODOFO_WITH_UNISTRING"] = self.options.with_unistring + tc.variables["PODOFO_HAVE_OPENSSL_1_1"] = Version(self.deps_cpp_info["openssl"].version) >= "1.1" + if self.options.with_openssl and ("no_rc4" in self.options["openssl"]): + tc.variables["PODOFO_HAVE_OPENSSL_NO_RC4"] = self.options["openssl"].no_rc4 + tc.generate() + + deps = CMakeDeps(self) + deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + self.copy("COPYING", src=self.source_folder, dst="licenses") + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): - podofo_version = tools.Version(self.version) + podofo_version = Version(self.version) pkg_config_name = f"libpodofo-{podofo_version.major}" if podofo_version < "0.9.7" else "libpodofo" self.cpp_info.set_property("pkg_config_name", pkg_config_name) self.cpp_info.names["pkg_config"] = pkg_config_name diff --git a/recipes/podofo/all/patches/0001-fix-cmake-0.9.6.patch b/recipes/podofo/all/patches/0001-fix-cmake-0.9.6.patch index b0027af25d31b..a896a6b032b0b 100644 --- a/recipes/podofo/all/patches/0001-fix-cmake-0.9.6.patch +++ b/recipes/podofo/all/patches/0001-fix-cmake-0.9.6.patch @@ -1,6 +1,6 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -37,7 +37,7 @@ CMAKE_POLICY(SET CMP0033 NEW) # https://cmake.org/cmake/help/v3.0/policy/CMP0033 +--- a/CMakeLists.txt 2018-07-08 12:33:27.000000000 +0200 ++++ b/CMakeLists.txt 2022-09-02 09:21:58.513547800 +0200 +@@ -37,7 +37,7 @@ endif() # Load modules from our source tree too @@ -9,7 +9,7 @@ # Builds must use this CMakeLists.txt, not the one in src/ or somewhere else. -@@ -313,73 +313,69 @@ IF(CMAKE_COMPILER_IS_GNUCXX) +@@ -313,73 +313,55 @@ ENDIF(CMAKE_COMPILER_IS_GNUCXX) FIND_PACKAGE(ZLIB REQUIRED) @@ -27,45 +27,32 @@ -ELSE(LIBCRYPTO_FOUND) - MESSAGE("OpenSSL's libCrypto not found. Encryption support will be disabled") -ENDIF(LIBCRYPTO_FOUND) -+ LINK_LIBRARIES(OpenSSL::OpenSSL) +- +-FIND_PACKAGE(LIBIDN) +- +-IF(LIBIDN_FOUND) +- MESSAGE("Found libidn headers in ${LIBIDN_INCLUDE_DIR}, library at ${LIBIDN_LIBRARIES}") +-ENDIF(LIBIDN_FOUND) ++ LINK_LIBRARIES(OpenSSL::SSL OpenSSL::Crypto) + INCLUDE(CheckCSourceCompiles) + + SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + SET(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) -+ -+ CHECK_C_SOURCE_COMPILES("#include -+ #ifndef OPENSSL_VERSION_NUMBER -+ #error No OPENSSL_VERSION_NUMBER defined -+ #endif -+ #if OPENSSL_VERSION_NUMBER < 0x10100000L -+ #error This is not OpenSSL 1.1 or higher -+ #endif -+ int main(void) { return 0; }" PODOFO_HAVE_OPENSSL_1_1) - --FIND_PACKAGE(LIBIDN) -+ CHECK_C_SOURCE_COMPILES("#include -+ #ifndef OPENSSL_NO_RC4 -+ #error No OPENSSL_NO_RC4 defined -+ #endif -+ int main(void) { return 0; }" PODOFO_HAVE_OPENSSL_NO_RC4) -IF(LIBIDN_FOUND) -- MESSAGE("Found libidn headers in ${LIBIDN_INCLUDE_DIR}, library at ${LIBIDN_LIBRARIES}") --ENDIF(LIBIDN_FOUND) + UNSET(CMAKE_REQUIRED_INCLUDES) + UNSET(CMAKE_REQUIRED_LIBRARIES) +ENDIF() + +if(PODOFO_WITH_LIBIDN) - --IF(LIBIDN_FOUND) ++ FIND_PACKAGE(LIBIDN) SET(PODOFO_HAVE_LIBIDN TRUE) - INCLUDE_DIRECTORIES(${LIBIDN_INCLUDE_DIR}) - MESSAGE("Libidn found. AES-256 Encryption support will be enabled") -ELSE(LIBIDN_FOUND) - MESSAGE("Libidn not found. AES-256 Encryption support will be disabled") -ENDIF(LIBIDN_FOUND) -+ LINK_LIBRARIES(CONAN_PKG::libidn) ++ LINK_LIBRARIES(libidn::libidn) +ENDIF() -FIND_PACKAGE(LIBJPEG) @@ -122,12 +109,13 @@ - MESSAGE("LibUnistring not found. Unistring support will be disabled") - SET(UNISTRING_LIBRARY "") -ENDIF(UNISTRING_FOUND) -+ LINK_LIBRARIES(CONAN_PKG::libunistring) ++ FIND_PACKAGE(libunistring REQUIRED) ++ LINK_LIBRARIES(libunistring::libunistring) +ENDIF() IF(NOT PODOFO_BUILD_LIB_ONLY) -@@ -396,11 +392,11 @@ ENDIF(CppUnit_FOUND) +@@ -396,11 +378,11 @@ ENDIF(NOT PODOFO_BUILD_LIB_ONLY) @@ -136,13 +124,13 @@ -FIND_PACKAGE(FREETYPE REQUIRED) -MESSAGE("Found freetype library at ${FREETYPE_LIBRARIES}, headers ${FREETYPE_INCLUDE_DIR}") +FIND_PACKAGE(Freetype REQUIRED) -+LINK_LIBRARIES(Freetype::Freetype) ++LINK_LIBRARIES(freetype) +if(0) FIND_PACKAGE(LIBSTLPORT) SET(stlport_libraries_if_use_stlport) IF(USE_STLPORT) -@@ -415,16 +411,13 @@ IF(USE_STLPORT) +@@ -415,16 +397,13 @@ MESSAGE(FATAL_ERROR "STLPort use requested, but STLPort not found.") ENDIF(LIBSTLPORT_FOUND) ENDIF(USE_STLPORT) @@ -162,3 +150,34 @@ ELSE(WANT_FONTCONFIG) # Might as well look for it anyway. This also sets the appropriate # variables to empty values. +@@ -516,6 +495,7 @@ + INCLUDE_DIRECTORIES(${FONTCONFIG_INCLUDE_DIR}) + ENDIF(FONTCONFIG_FOUND AND WANT_FONTCONFIG) + ++LINK_DIRECTORIES(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + IF(WIN32 OR PODOFO_BUILD_STATIC) + SET(PODOFO_LIB + podofo +@@ -546,10 +526,18 @@ + + ADD_SUBDIRECTORY(src) + IF(NOT PODOFO_BUILD_LIB_ONLY) +-ADD_SUBDIRECTORY(test) +-ADD_SUBDIRECTORY(tools) +-ADD_SUBDIRECTORY(examples) +-ADD_SUBDIRECTORY(man) ++IF(PODOFO_BUILD_TEST) ++ ADD_SUBDIRECTORY(test) ++ENDIF(PODOFO_BUILD_TEST) ++IF(PODOFO_BUILD_TOOLS) ++ ADD_SUBDIRECTORY(tools) ++ENDIF(PODOFO_BUILD_TOOLS) ++IF(PODOFO_BUILD_EXAMPLES) ++ ADD_SUBDIRECTORY(examples) ++ENDIF(PODOFO_BUILD_EXAMPLES) ++IF(PODOFO_BUILD_MAN) ++ ADD_SUBDIRECTORY(man) ++ENDIF(PODOFO_BUILD_MAN) + ENDIF(NOT PODOFO_BUILD_LIB_ONLY) + + # Generate our configure file diff --git a/recipes/podofo/all/patches/0001-fix-cmake-0.9.7.patch b/recipes/podofo/all/patches/0001-fix-cmake-0.9.7.patch index af4ed0f1ebf05..7e3424be58930 100644 --- a/recipes/podofo/all/patches/0001-fix-cmake-0.9.7.patch +++ b/recipes/podofo/all/patches/0001-fix-cmake-0.9.7.patch @@ -1,6 +1,6 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -38,7 +38,7 @@ CMAKE_POLICY(SET CMP0033 NEW) # https://cmake.org/cmake/help/v3.0/policy/CMP0033 +--- a/CMakeLists.txt 2021-01-05 17:56:54.000000000 +0100 ++++ b/CMakeLists.txt 2022-09-02 09:31:40.383547800 +0200 +@@ -38,7 +38,7 @@ endif() # Load modules from our source tree too @@ -9,7 +9,7 @@ # Builds must use this CMakeLists.txt, not the one in src/ or somewhere else. -@@ -322,73 +322,69 @@ IF(CMAKE_COMPILER_IS_GNUCXX) +@@ -322,73 +322,55 @@ ENDIF(CMAKE_COMPILER_IS_GNUCXX) FIND_PACKAGE(ZLIB REQUIRED) @@ -27,45 +27,32 @@ -ELSE(LIBCRYPTO_FOUND) - MESSAGE("OpenSSL's libCrypto not found. Encryption support will be disabled") -ENDIF(LIBCRYPTO_FOUND) -+ LINK_LIBRARIES(OpenSSL::OpenSSL) +- +-FIND_PACKAGE(LIBIDN) +- +-IF(LIBIDN_FOUND) +- MESSAGE("Found libidn headers in ${LIBIDN_INCLUDE_DIR}, library at ${LIBIDN_LIBRARIES}") +-ENDIF(LIBIDN_FOUND) ++ LINK_LIBRARIES(OpenSSL::SSL OpenSSL::Crypto) + INCLUDE(CheckCSourceCompiles) + + SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + SET(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) -+ -+ CHECK_C_SOURCE_COMPILES("#include -+ #ifndef OPENSSL_VERSION_NUMBER -+ #error No OPENSSL_VERSION_NUMBER defined -+ #endif -+ #if OPENSSL_VERSION_NUMBER < 0x10100000L -+ #error This is not OpenSSL 1.1 or higher -+ #endif -+ int main(void) { return 0; }" PODOFO_HAVE_OPENSSL_1_1) - --FIND_PACKAGE(LIBIDN) -+ CHECK_C_SOURCE_COMPILES("#include -+ #ifndef OPENSSL_NO_RC4 -+ #error No OPENSSL_NO_RC4 defined -+ #endif -+ int main(void) { return 0; }" PODOFO_HAVE_OPENSSL_NO_RC4) -IF(LIBIDN_FOUND) -- MESSAGE("Found libidn headers in ${LIBIDN_INCLUDE_DIR}, library at ${LIBIDN_LIBRARIES}") --ENDIF(LIBIDN_FOUND) + UNSET(CMAKE_REQUIRED_INCLUDES) + UNSET(CMAKE_REQUIRED_LIBRARIES) +ENDIF() + +if(PODOFO_WITH_LIBIDN) - --IF(LIBIDN_FOUND) ++ FIND_PACKAGE(LIBIDN) SET(PODOFO_HAVE_LIBIDN TRUE) - INCLUDE_DIRECTORIES(${LIBIDN_INCLUDE_DIR}) - MESSAGE("Libidn found. AES-256 Encryption support will be enabled") -ELSE(LIBIDN_FOUND) - MESSAGE("Libidn not found. AES-256 Encryption support will be disabled") -ENDIF(LIBIDN_FOUND) -+ LINK_LIBRARIES(CONAN_PKG::libidn) ++ LINK_LIBRARIES(libidn::libidn) +ENDIF() -FIND_PACKAGE(LIBJPEG) @@ -122,12 +109,13 @@ - MESSAGE("LibUnistring not found. Unistring support will be disabled") - SET(UNISTRING_LIBRARY "") -ENDIF(UNISTRING_FOUND) -+ LINK_LIBRARIES(CONAN_PKG::libunistring) ++ FIND_PACKAGE(libunistring REQUIRED) ++ LINK_LIBRARIES(libunistring::libunistring) +ENDIF() IF(NOT PODOFO_BUILD_LIB_ONLY) -@@ -405,11 +401,11 @@ ENDIF(CppUnit_FOUND) +@@ -405,11 +387,11 @@ ENDIF(NOT PODOFO_BUILD_LIB_ONLY) @@ -136,13 +124,13 @@ -FIND_PACKAGE(FREETYPE REQUIRED) -MESSAGE("Found freetype library at ${FREETYPE_LIBRARIES}, headers ${FREETYPE_INCLUDE_DIR}") +FIND_PACKAGE(Freetype REQUIRED) -+LINK_LIBRARIES(Freetype::Freetype) ++LINK_LIBRARIES(freetype) +if(0) FIND_PACKAGE(LIBSTLPORT) SET(stlport_libraries_if_use_stlport) IF(USE_STLPORT) -@@ -424,16 +420,13 @@ IF(USE_STLPORT) +@@ -424,16 +406,13 @@ MESSAGE(FATAL_ERROR "STLPort use requested, but STLPort not found.") ENDIF(LIBSTLPORT_FOUND) ENDIF(USE_STLPORT) @@ -162,3 +150,34 @@ ELSE(WANT_FONTCONFIG) # Might as well look for it anyway. This also sets the appropriate # variables to empty values. +@@ -525,6 +504,7 @@ + INCLUDE_DIRECTORIES(${FONTCONFIG_INCLUDE_DIR}) + ENDIF(FONTCONFIG_FOUND AND WANT_FONTCONFIG) + ++LINK_DIRECTORIES(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + IF(WIN32 OR PODOFO_BUILD_STATIC) + SET(PODOFO_LIB + podofo +@@ -555,10 +535,18 @@ + + ADD_SUBDIRECTORY(src/podofo) + IF(NOT PODOFO_BUILD_LIB_ONLY) +-ADD_SUBDIRECTORY(test) +-ADD_SUBDIRECTORY(tools) +-ADD_SUBDIRECTORY(examples) +-ADD_SUBDIRECTORY(man) ++IF(PODOFO_BUILD_TEST) ++ ADD_SUBDIRECTORY(test) ++ENDIF(PODOFO_BUILD_TEST) ++IF(PODOFO_BUILD_TOOLS) ++ ADD_SUBDIRECTORY(tools) ++ENDIF(PODOFO_BUILD_TOOLS) ++IF(PODOFO_BUILD_EXAMPLES) ++ ADD_SUBDIRECTORY(examples) ++ENDIF(PODOFO_BUILD_EXAMPLES) ++IF(PODOFO_BUILD_MAN) ++ ADD_SUBDIRECTORY(man) ++ENDIF(PODOFO_BUILD_MAN) + ENDIF(NOT PODOFO_BUILD_LIB_ONLY) + + # Generate our configure file diff --git a/recipes/pulseaudio/all/conanfile.py b/recipes/pulseaudio/all/conanfile.py index c4210a2820136..8f2092db76bbf 100644 --- a/recipes/pulseaudio/all/conanfile.py +++ b/recipes/pulseaudio/all/conanfile.py @@ -1,8 +1,12 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain, PkgConfigDeps +from conan.tools.layout import basic_layout import os -required_conan_version = ">=1.32.0" +required_conan_version = ">=1.50.0" class PulseAudioConan(ConanFile): @@ -13,7 +17,6 @@ class PulseAudioConan(ConanFile): homepage = "http://pulseaudio.org/" license = "LGPL-2.1" - generators = "pkg_config" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -36,12 +39,6 @@ class PulseAudioConan(ConanFile): "with_dbus": False, } - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -49,20 +46,26 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass if not self.options.with_dbus: del self.options.with_fftw def requirements(self): self.requires("libiconv/1.17") self.requires("libsndfile/1.0.31") - self.requires("libcap/2.62") - self.requires("libtool/2.4.6") + self.requires("libcap/2.65") + self.requires("libtool/2.4.7") if self.options.with_alsa: self.requires("libalsa/1.2.7.2") if self.options.with_glib: - self.requires("glib/2.73.1") + self.requires("glib/2.73.3") if self.options.get_safe("with_fftw"): self.requires("fftw/3.3.9") if self.options.with_x11: @@ -73,63 +76,71 @@ def requirements(self): self.requires("dbus/1.12.20") def validate(self): - if self.settings.os != "Linux": + if self.info.settings.os != "Linux": raise ConanInvalidConfiguration("pulseaudio supports only linux currently") - if self.options.get_safe("with_fftw") and self.options["fftw"].precision != "single": - raise ConanInvalidConfiguration("Pulse audio cannot use fftw %s precision." - "Either set option fftw:precision=single" - "or pulseaudio:with_fftw=False" - % self.options["fftw"].precision) + if self.options.get_safe("with_fftw"): + fftw_precision = self.dependencies["fftw"].options.precision + if fftw_precision != "single": + raise ConanInvalidConfiguration( + f"Pulse audio cannot use fftw {fftw_precision} precision. " + "Either set option fftw:precision=single or pulseaudio:with_fftw=False" + ) def build_requirements(self): - self.build_requires("gettext/0.21") - self.build_requires("libtool/2.4.6") - self.build_requires("pkgconf/1.7.4") + self.tool_requires("gettext/0.21") + self.tool_requires("libtool/2.4.7") + self.tool_requires("pkgconf/1.7.4") + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) - - def _configure_autotools(self): - if not self._autotools: - self._autotools = AutoToolsBuildEnvironment(self) - args=[] - - for lib in ["alsa", "x11", "openssl", "dbus"]: - args.append("--%s-%s" % ("enable" if getattr(self.options, "with_" + lib) else "disable", lib)) - args.append("--%s-glib2" % ("enable" if self.options.with_glib else "disable")) - args.append("--%s-fftw" % ("with" if self.options.get_safe("with_fftw") else "without")) - if self.options.shared: - args.extend(["--enable-shared=yes", "--enable-static=no"]) - else: - args.extend(["--enable-shared=no", "--enable-static=yes"]) - args.append("--with-udev-rules-dir=%s" % os.path.join(self.package_folder, "bin", "udev", "rules.d")) - args.append("--with-systemduserunitdir=%s" % os.path.join(self.build_folder, "ignore")) - self._autotools.configure(args=args, configure_dir=self._source_subfolder) - return self._autotools + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = AutotoolsToolchain(self) + yes_no = lambda v: "yes" if v else "no" + tc.configure_args.extend([ + f"--enable-shared={yes_no(self.options.shared)}", + f"--enable-static={yes_no(not self.options.shared)}", + f"--enable-glib2={yes_no(self.options.with_glib)}", + f"--with-fftw={yes_no(self.options.get_safe('with_fftw'))}", + f"--with-udev-rules-dir={os.path.join(self.package_folder, 'bin', 'udev', 'rules.d')}", + f"--with-systemduserunitdir={os.path.join(self.build_folder, 'ignore')}", + ]) + for lib in ["alsa", "x11", "openssl", "dbus"]: + tc.configure_args.append(f"--enable-{lib}={yes_no(getattr(self.options, 'with_' + lib))}") + # TODO: to remove when automatically handled by AutotoolsToolchain + tc.configure_args.append("--libexecdir=${prefix}/bin") + tc.generate() + deps = AutotoolsDeps(self) + deps.generate() + pkg = PkgConfigDeps(self) + pkg.generate() + env = VirtualBuildEnv(self) + env.generate() def build(self): - with tools.run_environment(self): - autotools = self._configure_autotools() - autotools.make() + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - with tools.run_environment(self): - autotools = self._configure_autotools() - autotools.install() - tools.rmdir(os.path.join(self.package_folder, "etc")) - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(self.package_folder, "*.la") + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install() + rmdir(self, os.path.join(self.package_folder, "etc")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) def package_info(self): - self.cpp_info.components["pulse"].names["pkg_config"] = "libpulse" - self.cpp_info.components["pulse"].libs = ["pulse"] - if not self.options.shared: - self.cpp_info.components["pulse"].libs.append("pulsecommon-%s" % self.version) - self.cpp_info.components["pulse"].libdirs = ["lib", os.path.join("lib", "pulseaudio")] + self.cpp_info.components["pulse"].set_property("pkg_config_name", "libpulse") + self.cpp_info.components["pulse"].libs = ["pulse", f"pulsecommon-{self.version}"] + self.cpp_info.components["pulse"].libdirs.append(os.path.join("lib", "pulseaudio")) self.cpp_info.components["pulse"].requires = ["libiconv::libiconv", "libsndfile::libsndfile", "libcap::libcap", "libtool::libtool"] if self.options.with_alsa: self.cpp_info.components["pulse"].requires.append("libalsa::libalsa") @@ -142,13 +153,13 @@ def package_info(self): if self.options.with_dbus: self.cpp_info.components["pulse"].requires.append("dbus::dbus") - self.cpp_info.components["pulse-simple"].names["pkg_config"] = "libpulse-simple" + self.cpp_info.components["pulse-simple"].set_property("pkg_config_name", "libpulse-simple") self.cpp_info.components["pulse-simple"].libs = ["pulse-simple"] self.cpp_info.components["pulse-simple"].defines.append("_REENTRANT") self.cpp_info.components["pulse-simple"].requires = ["pulse"] if self.options.with_glib: - self.cpp_info.components["pulse-mainloop-glib"].names["pkg_config"] = "libpulse-mainloop-glib" + self.cpp_info.components["pulse-mainloop-glib"].set_property("pkg_config_name", "libpulse-mainloop-glib") self.cpp_info.components["pulse-mainloop-glib"].libs = ["pulse-mainloop-glib"] self.cpp_info.components["pulse-mainloop-glib"].defines.append("_REENTRANT") self.cpp_info.components["pulse-mainloop-glib"].requires = ["pulse", "glib::glib-2.0"] diff --git a/recipes/pulseaudio/all/test_package/CMakeLists.txt b/recipes/pulseaudio/all/test_package/CMakeLists.txt index 3c74484af3150..a9b88d597549a 100644 --- a/recipes/pulseaudio/all/test_package/CMakeLists.txt +++ b/recipes/pulseaudio/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(pulseaudio REQUIRED) +find_package(pulseaudio REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} pulseaudio::pulseaudio) +target_link_libraries(${PROJECT_NAME} PRIVATE pulseaudio::pulseaudio) diff --git a/recipes/pulseaudio/all/test_package/conanfile.py b/recipes/pulseaudio/all/test_package/conanfile.py index 2b9f9be9d851a..d120a992c06a6 100644 --- a/recipes/pulseaudio/all/test_package/conanfile.py +++ b/recipes/pulseaudio/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) - + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/pulseaudio/all/test_v1_package/CMakeLists.txt b/recipes/pulseaudio/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4947b7dda15bc --- /dev/null +++ b/recipes/pulseaudio/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(pulseaudio REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE pulseaudio::pulseaudio) diff --git a/recipes/pulseaudio/all/test_v1_package/conanfile.py b/recipes/pulseaudio/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a691174f8ed16 --- /dev/null +++ b/recipes/pulseaudio/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + diff --git a/recipes/restinio/all/conandata.yml b/recipes/restinio/all/conandata.yml index 89d29b21e05ed..b4a2e1e8e8118 100644 --- a/recipes/restinio/all/conandata.yml +++ b/recipes/restinio/all/conandata.yml @@ -29,3 +29,6 @@ sources: "0.6.16": url: "https://github.com/Stiffstream/restinio/archive/v.0.6.16.tar.gz" sha256: "b3208d746087ba979f51b3a32e08463718c33d58720247d53ffb5bda99f4f92a" + "0.6.17": + url: "https://github.com/Stiffstream/restinio/archive/v.0.6.17.tar.gz" + sha256: "0140b23f50bb964f6917d1f99205476eba92203dc586673bdf2ea48d7406f2c4" diff --git a/recipes/restinio/config.yml b/recipes/restinio/config.yml index ad02d418f25a8..29781bb078232 100644 --- a/recipes/restinio/config.yml +++ b/recipes/restinio/config.yml @@ -19,3 +19,5 @@ versions: folder: all "0.6.16": folder: all + "0.6.17": + folder: all diff --git a/recipes/samarium/all/CMakeLists.txt b/recipes/samarium/all/CMakeLists.txt deleted file mode 100644 index f3a784a246b7f..0000000000000 --- a/recipes/samarium/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.15) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory(source_subfolder/src) diff --git a/recipes/samarium/all/conandata.yml b/recipes/samarium/all/conandata.yml index ba7cb183fbc44..06463f7d62302 100644 --- a/recipes/samarium/all/conandata.yml +++ b/recipes/samarium/all/conandata.yml @@ -2,3 +2,27 @@ sources: "1.0.0": sha256: 943de75803f492f78c5d55fe43be298fbb66156cc22946a3c6cc6b0634efc2e2 url: https://github.com/strangeQuark1041/samarium/archive/refs/tags/v1.0.0.tar.gz + "1.0.1": + sha256: 3748ad1095805338d0d54ca7b60a155520188970946b247d56cc9b5eeb397358 + url: https://github.com/strangeQuark1041/samarium/archive/refs/tags/v1.0.1.tar.gz +patches: + "1.0.0": + - patch_file: "patches/1.0.0-updated-cmake.patch" + patch_description: "Use find_package for CMakeDeps" + patch_type: "conan" + sha256: "2be2eadc468fe676f547793fc7ec48bc38ce6f1daa47a497cd2535aaa493fa9a" + + - patch_file: "patches/1.0.0-Grid.hpp-include-vector.patch" + patch_description: "add missing #include " + patch_type: "portability" + sha256: "0326eb790fc55630efe138bc9b359754d2de23c4aa37179faa04821f83efa9c3" + + - patch_file: "patches/1.0.0-RandomGenerator.hpp-link.patch" + patch_description: "Fix static function linking" + patch_type: "portability" + sha256: "218318c017500ab4c6360dafaf0523736295ddac323c04aaad5fc8a31867b4f0" + + - patch_file: "patches/1.0.0-RandomGenerator.cpp-link.patch" + patch_description: "Fix static function linking" + patch_type: "portability" + sha256: "f5d0cc6a108bb3f5f22a88c29f5eda1ddf73c25720e894e7ac3c67396e687087" diff --git a/recipes/samarium/all/conanfile.py b/recipes/samarium/all/conanfile.py index d199c49320adc..6f1215fe6e6c6 100644 --- a/recipes/samarium/all/conanfile.py +++ b/recipes/samarium/all/conanfile.py @@ -1,8 +1,12 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -import functools +from os import path -required_conan_version = ">=1.43.0" +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.files import patch, copy, get +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.47.0" class SamariumConan(ConanFile): @@ -12,81 +16,71 @@ class SamariumConan(ConanFile): url = "https://github.com/conan-io/conan-center-index/" license = "MIT" topics = ("cpp20", "physics", "2d", "simulation") + generators = "CMakeDeps", "CMakeToolchain" + requires = "fmt/9.0.0", "sfml/2.5.1", "range-v3/0.12.0", "stb/cci.20210910", "tl-expected/20190710" settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False], "fPIC": [True, False]} + options = {"shared": [True, False], "fPIC": [ + True, False]} default_options = {"shared": False, "fPIC": True} - generators = "cmake", "cmake_find_package_multi" - requires = "fmt/8.1.1", "sfml/2.5.1", "range-v3/0.12.0" - - @property - def _min_cppstd(self): - return "20" - @property def _compilers_minimum_version(self): return { "gcc": "11.0", - "Visual Studio": "16.9", + "Visual Studio": "16", "clang": "13", "apple-clang": "13", } - @property - def _source_subfolder(self): - return "source_subfolder" + def source(self): + get(self, **self.conan_data["sources"] + [str(self.version)], strip_root=True) - @property - def _build_subfolder(self): - return "build" + def configure(self): + if self.options.shared: + del self.options.fPIC def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - def configure(self): - if self.options.shared: - del self.options.fPIC - def validate(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, self._min_cppstd) + if self.version == "1.0.0" and self.settings.os == "Macos": + raise ConanInvalidConfiguration("Macos not supported for v1.0.0") compiler = str(self.settings.compiler) if compiler not in self._compilers_minimum_version: - self.output.warn("Unknown compiler, assuming it supports at least C++20") + self.output.warn( + "Unknown compiler, assuming it supports at least C++20") return - version = tools.Version(self.settings.compiler.version) + version = Version(self.settings.compiler.version) if version < self._compilers_minimum_version[compiler]: - raise ConanInvalidConfiguration(f"{self.name} requires a compiler that supports at least C++20") + raise ConanInvalidConfiguration( + f"{self.name} requires a compiler that supports at least C++20") + + def layout(self): + cmake_layout(self, src_folder="src") 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 source(self): - tools.get(**self.conan_data["sources"][self.version], - strip_root=True, destination=self._source_subfolder) + def build(self): + for patch_ in self.conan_data.get("patches", {}).get(self.version, []): + patch(self, **patch_) - @functools.lru_cache(1) - def _configure_cmake(self): cmake = CMake(self) - cmake.configure(build_folder=self._build_subfolder) - return cmake - - def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() + cmake.configure(build_script_folder="src") cmake.build() def package(self): - self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.md", src=self.folders.source_folder, + dst=path.join(self.package_folder, "licenses")) + + cmake = CMake(self) cmake.install() def package_info(self): - self.cpp_info.libs.append("samarium") + self.cpp_info.libs = ["samarium"] diff --git a/recipes/samarium/all/patches/1.0.0-Grid.hpp-include-vector.patch b/recipes/samarium/all/patches/1.0.0-Grid.hpp-include-vector.patch new file mode 100644 index 0000000000000..9ce690f42e82c --- /dev/null +++ b/recipes/samarium/all/patches/1.0.0-Grid.hpp-include-vector.patch @@ -0,0 +1,12 @@ +diff --git a/src/samarium/graphics/Grid.hpp b/src/samarium/graphics/Grid.hpp +index 25ba647..0f0ccac 100644 +--- a/src/samarium/graphics/Grid.hpp ++++ b/src/samarium/graphics/Grid.hpp +@@ -10,6 +10,7 @@ + #include + #include + #include ++#include + + #include "fmt/format.h" + #include "range/v3/algorithm/copy.hpp" diff --git a/recipes/samarium/all/patches/1.0.0-RandomGenerator.cpp-link.patch b/recipes/samarium/all/patches/1.0.0-RandomGenerator.cpp-link.patch new file mode 100644 index 0000000000000..8b951e545c4d1 --- /dev/null +++ b/recipes/samarium/all/patches/1.0.0-RandomGenerator.cpp-link.patch @@ -0,0 +1,22 @@ +diff --git a/src/samarium/util/RandomGenerator.cpp b/src/samarium/util/RandomGenerator.cpp +index d1a17d6..84c964b 100644 +--- a/src/samarium/util/RandomGenerator.cpp ++++ b/src/samarium/util/RandomGenerator.cpp +@@ -75,17 +75,6 @@ void RandomGenerator::reseed(u64 new_seed) + ranges::generate(cache, [this] { return this->next_scaled(); }); + } + +-[[nodiscard]] auto RandomGenerator::next() noexcept -> u64 +-{ +- const auto oldstate = this->state; +- // Advance internal state +- this->state = oldstate * magic_number + (this->inc | 1); +- // Calculate output function (XSH RR), uses old state for max ILP +- const auto xorshifted = static_cast(((oldstate >> 18UL) ^ oldstate) >> 27UL); +- const auto rot = static_cast(oldstate >> 59UL); +- return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); +-} +- + [[nodiscard]] auto RandomGenerator::next_scaled() noexcept -> f64 + { + return static_cast(this->next()) / static_cast(std::numeric_limits::max()); diff --git a/recipes/samarium/all/patches/1.0.0-RandomGenerator.hpp-link.patch b/recipes/samarium/all/patches/1.0.0-RandomGenerator.hpp-link.patch new file mode 100644 index 0000000000000..15444d4236758 --- /dev/null +++ b/recipes/samarium/all/patches/1.0.0-RandomGenerator.hpp-link.patch @@ -0,0 +1,34 @@ +diff --git a/src/samarium/util/RandomGenerator.hpp b/src/samarium/util/RandomGenerator.hpp +index b86224f..4f48424 100644 +--- a/src/samarium/util/RandomGenerator.hpp ++++ b/src/samarium/util/RandomGenerator.hpp +@@ -49,14 +49,27 @@ struct RandomGenerator + } + state = new_state * magic_number + (new_inc | 1); + +- ranges::generate(cache, [this] { return this->next_scaled(); }); ++ ranges::generate(cache, ++ [this] { ++ return static_cast(this->next()) / ++ static_cast(std::numeric_limits::max()); ++ }); + } + + void resize(u64 new_size); + + void reseed(u64 new_seed); + +- [[nodiscard]] auto next() noexcept -> u64; ++ [[nodiscard]] auto next() noexcept -> u64 ++ { ++ const auto oldstate = this->state; ++ // Advance internal state ++ this->state = oldstate * magic_number + (this->inc | 1); ++ // Calculate output function (XSH RR), uses old state for max ILP ++ const auto xorshifted = static_cast(((oldstate >> 18UL) ^ oldstate) >> 27UL); ++ const auto rot = static_cast(oldstate >> 59UL); ++ return (xorshifted >> rot) | (xorshifted << ((-rot) & 31)); ++ } + + [[nodiscard]] auto next_scaled() noexcept -> f64; + diff --git a/recipes/samarium/all/patches/1.0.0-updated-cmake.patch b/recipes/samarium/all/patches/1.0.0-updated-cmake.patch new file mode 100644 index 0000000000000..db7d5eb7a83be --- /dev/null +++ b/recipes/samarium/all/patches/1.0.0-updated-cmake.patch @@ -0,0 +1,39 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 0cc8517..aff82dd 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -42,28 +42,13 @@ if(WARNINGS) + target_compile_options(samarium PUBLIC ${WARNINGS}) + endif() + +-option(SAMARIUM_USE_CONAN "Use Conan to find dependencies" TRUE) +-if(SAMARIUM_USE_CONAN) +- message(STATUS "src/CMakeLists.txt: Using Conan for deps") ++find_package(SFML 2.5 CONFIG REQUIRED) ++find_package(fmt CONFIG REQUIRED) ++find_package(range-v3 CONFIG REQUIRED) + +- include(conanbuildinfo) +- conan_basic_setup(TARGETS) +- +- target_link_libraries(samarium PRIVATE CONAN_PKG::fmt) +- target_link_libraries(samarium PRIVATE CONAN_PKG::sfml) +- target_link_libraries(samarium PRIVATE CONAN_PKG::range-v3) +- +-else() +- find_package( +- SFML 2.5 +- COMPONENTS system window graphics +- REQUIRED +- ) +- +- find_package(fmt REQUIRED) +- target_link_libraries(samarium PRIVATE fmt::fmt) +- target_link_libraries(samarium PRIVATE sfml-system sfml-window sfml-graphics) +-endif() ++target_link_libraries(samarium PRIVATE fmt::fmt) ++target_link_libraries(samarium PRIVATE sfml-system sfml-window sfml-graphics) ++target_link_libraries(samarium PRIVATE range-v3::range-v3) + + install( + TARGETS samarium diff --git a/recipes/samarium/all/test_package/CMakeLists.txt b/recipes/samarium/all/test_package/CMakeLists.txt index 028691a3d0e7f..5223fd5cb739b 100644 --- a/recipes/samarium/all/test_package/CMakeLists.txt +++ b/recipes/samarium/all/test_package/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required(VERSION 3.15) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) find_package(samarium REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) diff --git a/recipes/samarium/all/test_package/conanfile.py b/recipes/samarium/all/test_package/conanfile.py index 49a3a66ea5bad..fd0c8a7b2b6cb 100644 --- a/recipes/samarium/all/test_package/conanfile.py +++ b/recipes/samarium/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -from conans import ConanFile, CMake, tools import os +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import cross_building + class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +22,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/samarium/all/test_package/test_package.cpp b/recipes/samarium/all/test_package/test_package.cpp index 6f22a556097ac..f16dd948c92df 100644 --- a/recipes/samarium/all/test_package/test_package.cpp +++ b/recipes/samarium/all/test_package/test_package.cpp @@ -2,7 +2,7 @@ int main() { - const auto im = sm::Image{}; + const auto im = sm::Image{sm::dimsFHD}; fmt::print(fmt::emphasis::bold, "\nSuccessful installation!\n"); fmt::print(fmt::emphasis::bold, "Welcome to {}\n", sm::version); } diff --git a/recipes/samarium/config.yml b/recipes/samarium/config.yml index 40341aa3db6cd..5e61e3082c4f0 100644 --- a/recipes/samarium/config.yml +++ b/recipes/samarium/config.yml @@ -1,3 +1,5 @@ versions: "1.0.0": folder: all + "1.0.1": + folder: all diff --git a/recipes/sdbus-cpp/all/CMakeLists.txt b/recipes/sdbus-cpp/all/CMakeLists.txt deleted file mode 100644 index d6b9a5f7ad86f..0000000000000 --- a/recipes/sdbus-cpp/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.13) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/sdbus-cpp/all/conandata.yml b/recipes/sdbus-cpp/all/conandata.yml index 85aaa01400bca..4c4e5beb4bad0 100644 --- a/recipes/sdbus-cpp/all/conandata.yml +++ b/recipes/sdbus-cpp/all/conandata.yml @@ -1,21 +1,25 @@ sources: - "0.8.3": - url: "https://github.com/Kistler-Group/sdbus-cpp/archive/v0.8.3.tar.gz" - sha256: "0fd575ae0f463773dd9141242d1133731e2b780fd6526650ce992ba711d88628" - "1.0.0": - url: "https://github.com/Kistler-Group/sdbus-cpp/archive/v1.0.0.tar.gz" - sha256: "3db82112c0d8a171a4115d761e3a592b62091fa7600988736652595178ae4e94" + "1.2.0": + url: "https://github.com/Kistler-Group/sdbus-cpp/archive/v1.2.0.tar.gz" + sha256: "7f7231904abb6a996b8c18ddc5fb50078ef5dff5191649abf9f127aff41d24e9" "1.1.0": url: "https://github.com/Kistler-Group/sdbus-cpp/archive/v1.1.0.tar.gz" sha256: "35e939fdd9c796522702c9c8762dd59b5c47f3440c01ba9feb9921c042780b55" + "1.0.0": + url: "https://github.com/Kistler-Group/sdbus-cpp/archive/v1.0.0.tar.gz" + sha256: "3db82112c0d8a171a4115d761e3a592b62091fa7600988736652595178ae4e94" + "0.8.3": + url: "https://github.com/Kistler-Group/sdbus-cpp/archive/v0.8.3.tar.gz" + sha256: "0fd575ae0f463773dd9141242d1133731e2b780fd6526650ce992ba711d88628" - "1.2.0": - url: "https://github.com/Kistler-Group/sdbus-cpp/archive/v1.2.0.tar.gz" - sha256: "7f7231904abb6a996b8c18ddc5fb50078ef5dff5191649abf9f127aff41d24e9" patches: - "0.8.3": - - base_path: "source_subfolder" - patch_file: "patches/0001-xml2cpp-Add-missing-EXPAT-include-dirs-136.patch" "1.0.0": - - base_path: "source_subfolder" - patch_file: "patches/0002-correct-readme-cpack-resource-path.patch" + - patch_file: "patches/0002-correct-readme-cpack-resource-path.patch" + patch_description: "fix out of tree build by using proper paths in cmake file" + patch_type: "backport" + patch_source: "https://github.com/Kistler-Group/sdbus-cpp/commit/0b8f2d97524f354bcaf816b27b6139a5b0c480ba" + "0.8.3": + - patch_file: "patches/0001-xml2cpp-Add-missing-EXPAT-include-dirs-136.patch" + patch_description: "fix build error by adding missing headers" + patch_type: "backport" + patch_source: "https://github.com/Kistler-Group/sdbus-cpp/commit/fb008445b15b452f461c34667f4991f5ce06e481" diff --git a/recipes/sdbus-cpp/all/conanfile.py b/recipes/sdbus-cpp/all/conanfile.py index 8fe032221633c..c9aa7c7a53b7a 100644 --- a/recipes/sdbus-cpp/all/conanfile.py +++ b/recipes/sdbus-cpp/all/conanfile.py @@ -1,19 +1,23 @@ import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.51.0" class SdbusCppConan(ConanFile): name = "sdbus-cpp" - license = "LGPL-2.1-or-later" + license = "LicenseRef-LGPL-2.1-or-later-WITH-sdbus-cpp-LGPL-exception-1.0" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/Kistler-Group/sdbus-cpp" description = "High-level C++ D-Bus library for Linux designed" \ " to provide easy-to-use yet powerful API in modern C++" - topics = ("conan", "dbus", "sd-bus", "sdbus-c++", "sdbus-cpp") + topics = ("dbus", "sd-bus", "sdbus-c++") settings = "os", "compiler", "build_type", "arch" options = { "shared": [True, False], @@ -25,17 +29,7 @@ class SdbusCppConan(ConanFile): "fPIC": True, "with_code_gen": False, } - exports_sources = ("CMakeLists.txt", "patches/**") - generators = ("cmake", "pkg_config") - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + generators = "PkgConfigDeps", "VirtualBuildEnv" @property def _minimum_cpp_standard(self): @@ -48,74 +42,96 @@ def _minimum_compilers_version(self): "clang": "6", } + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, + self.export_sources_folder) + def configure(self): + if Version(self.version) < "0.9.0": + self.license = "LGPL-2.1-or-later" + if self.options.shared: del self.options.fPIC + def requirements(self): + self.requires("libsystemd/251.4") + def validate(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, self._minimum_cpp_standard) - min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) + if self.info.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._minimum_cpp_standard) + min_version = self._minimum_compilers_version.get(str(self.info.settings.compiler)) if not min_version: self.output.warn("{} recipe lacks information about the {} compiler support.".format( - self.name, self.settings.compiler)) + self.name, self.info.settings.compiler)) else: - if tools.Version(self.settings.compiler.version) < min_version: + if Version(self.info.settings.compiler.version) < min_version: raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( - self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) - if self.settings.os != "Linux": + self.name, self._minimum_cpp_standard, self.info.settings.compiler, self.info.settings.compiler.version)) + if self.info.settings.os != "Linux": raise ConanInvalidConfiguration("Only Linux supported") def build_requirements(self): - self.build_requires("pkgconf/1.7.4") + self.tool_requires("pkgconf/1.7.4") if self.options.with_code_gen: - self.build_requires("expat/2.4.1") + self.tool_requires("expat/2.4.8") - def requirements(self): - self.requires("libsystemd/249.4") + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_CODE_GEN"] = self.options.with_code_gen - self._cmake.definitions["BUILD_DOC"] = False - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.definitions["BUILD_LIBSYSTEMD"] = False - self._cmake.configure() - return self._cmake - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_CODE_GEN"] = self.options.with_code_gen + tc.variables["BUILD_DOC"] = False + tc.variables["BUILD_TESTS"] = False + tc.variables["BUILD_LIBSYSTEMD"] = False + tc.generate() + + # workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/18150 + copy(self, "*.pc", self.generators_folder, + os.path.join(self.generators_folder, "lib", "pkgconfig")) def build(self): - self._patch_sources() - cmake = self._configure_cmake() + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.install() - self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + copy(self, "COPYING*", self.source_folder, + os.path.join(self.package_folder, "licenses")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "sdbus-c++") + self.cpp_info.set_property("cmake_target_name", "SDBusCpp::sdbus-c++") + self.cpp_info.set_property("pkg_config_name", "sdbus-c++") + # TODO: back to root cpp_info in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["sdbus-c++"].libs = ["sdbus-c++"] + self.cpp_info.components["sdbus-c++"].system_libs = ["pthread", "m"] + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.names["cmake_find_package"] = "SDBusCpp" self.cpp_info.names["cmake_find_package_multi"] = "SDBusCpp" self.cpp_info.filenames["cmake_find_package"] = "sdbus-c++" self.cpp_info.filenames["cmake_find_package_multi"] = "sdbus-c++" - self.cpp_info.components["sdbus-c++"].libs = ["sdbus-c++"] - self.cpp_info.components["sdbus-c++"].requires.append("libsystemd::libsystemd") self.cpp_info.components["sdbus-c++"].names["cmake_find_package"] = "sdbus-c++" self.cpp_info.components["sdbus-c++"].names["cmake_find_package_multi"] = "sdbus-c++" self.cpp_info.components["sdbus-c++"].names["pkg_config"] = "sdbus-c++" + self.cpp_info.components["sdbus-c++"].set_property( + "cmake_target_name", "SDBusCpp::sdbus-c++") + self.cpp_info.components["sdbus-c++"].set_property( + "pkg_config_name", "sdbus-c++") + self.cpp_info.components["sdbus-c++"].requires.append( + "libsystemd::libsystemd") if self.options.with_code_gen: bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH env var with : {}".format(bin_path)) + self.output.info(f"Appending PATH env var with : {bin_path}") self.env_info.PATH.append(bin_path) diff --git a/recipes/sdbus-cpp/all/test_package/CMakeLists.txt b/recipes/sdbus-cpp/all/test_package/CMakeLists.txt index d5a1d8588ab69..db5504be46a52 100644 --- a/recipes/sdbus-cpp/all/test_package/CMakeLists.txt +++ b/recipes/sdbus-cpp/all/test_package/CMakeLists.txt @@ -1,8 +1,5 @@ -cmake_minimum_required(VERSION 3.13) -project(PackageTest CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +cmake_minimum_required(VERSION 3.15) +project(PackageTest LANGUAGES CXX) find_package(sdbus-c++ REQUIRED) diff --git a/recipes/sdbus-cpp/all/test_package/conanfile.py b/recipes/sdbus-cpp/all/test_package/conanfile.py index a44e79fe2fa78..1841d8faae767 100644 --- a/recipes/sdbus-cpp/all/test_package/conanfile.py +++ b/recipes/sdbus-cpp/all/test_package/conanfile.py @@ -1,11 +1,20 @@ import os -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout class SdbusCppTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = ("cmake", "cmake_find_package") + generators = "CMakeToolchain", "CMakeDeps", "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) @@ -13,6 +22,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "example") + self.run(bin_path, env="conanrun") diff --git a/recipes/sdbus-cpp/all/test_pkgconf/CMakeLists.txt b/recipes/sdbus-cpp/all/test_pkgconf/CMakeLists.txt new file mode 100644 index 0000000000000..143f93fecde25 --- /dev/null +++ b/recipes/sdbus-cpp/all/test_pkgconf/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(PackageTest LANGUAGES CXX) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(SDBusCpp REQUIRED IMPORTED_TARGET sdbus-c++) + +add_executable(example ../test_package/example.cpp) +target_link_libraries(example PRIVATE PkgConfig::SDBusCpp) diff --git a/recipes/sdbus-cpp/all/test_pkgconf/conanfile.py b/recipes/sdbus-cpp/all/test_pkgconf/conanfile.py new file mode 100644 index 0000000000000..14a7f949ac19a --- /dev/null +++ b/recipes/sdbus-cpp/all/test_pkgconf/conanfile.py @@ -0,0 +1,36 @@ +import os + +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.files import copy + + +class SdbusCppTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeToolchain", "PkgConfigDeps", "VirtualBuildEnv", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def build_requirements(self): + self.tool_requires("pkgconf/1.7.4") + + def layout(self): + cmake_layout(self) + + def generate(self): + # workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/18150 + copy(self, "*.pc", self.generators_folder, + os.path.join(self.generators_folder, "lib", "pkgconfig")) + + 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.bindirs[0], "example") + self.run(bin_path, env="conanrun") diff --git a/recipes/sdbus-cpp/all/test_v1_package/CMakeLists.txt b/recipes/sdbus-cpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..32c1244c3650a --- /dev/null +++ b/recipes/sdbus-cpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.13) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(sdbus-c++ REQUIRED) + +add_executable(example ../test_package/example.cpp) +target_link_libraries(example SDBusCpp::sdbus-c++) diff --git a/recipes/sdbus-cpp/all/test_v1_package/conanfile.py b/recipes/sdbus-cpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..99d76423bd838 --- /dev/null +++ b/recipes/sdbus-cpp/all/test_v1_package/conanfile.py @@ -0,0 +1,21 @@ +import os + +from conan import ConanFile +from conan.tools.build import can_run + +from conans import CMake + + +class SdbusCppTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = ("cmake", "cmake_find_package") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/sdbus-cpp/all/test_v1_pkgconf/CMakeLists.txt b/recipes/sdbus-cpp/all/test_v1_pkgconf/CMakeLists.txt new file mode 100644 index 0000000000000..e9b6fb408f74a --- /dev/null +++ b/recipes/sdbus-cpp/all/test_v1_pkgconf/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.13) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(SDBusCpp REQUIRED IMPORTED_TARGET sdbus-c++) + +add_executable(example ../test_package/example.cpp) +target_link_libraries(example PRIVATE PkgConfig::SDBusCpp) diff --git a/recipes/sdbus-cpp/all/test_v1_pkgconf/conanfile.py b/recipes/sdbus-cpp/all/test_v1_pkgconf/conanfile.py new file mode 100644 index 0000000000000..22690852ece67 --- /dev/null +++ b/recipes/sdbus-cpp/all/test_v1_pkgconf/conanfile.py @@ -0,0 +1,24 @@ +import os + +from conan import ConanFile +from conan.tools.build import can_run + +from conans import CMake + + +class SdbusCppTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = ("cmake", "pkg_config") + + def build_requirements(self): + self.tool_requires("pkgconf/1.7.4") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/sdbus-cpp/config.yml b/recipes/sdbus-cpp/config.yml index a10404a9e4729..027c0dc56075d 100644 --- a/recipes/sdbus-cpp/config.yml +++ b/recipes/sdbus-cpp/config.yml @@ -1,9 +1,9 @@ versions: - "0.8.3": - folder: all - "1.0.0": + "1.2.0": folder: all "1.1.0": folder: all - "1.2.0": + "1.0.0": + folder: all + "0.8.3": folder: all diff --git a/recipes/spirv-tools/all/CMakeLists.txt b/recipes/spirv-tools/all/CMakeLists.txt deleted file mode 100644 index 61f3d3b039e2b..0000000000000 --- a/recipes/spirv-tools/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory("source_subfolder") diff --git a/recipes/spirv-tools/all/conandata.yml b/recipes/spirv-tools/all/conandata.yml index 4995b3e7e428c..803c2f4c4cf9f 100644 --- a/recipes/spirv-tools/all/conandata.yml +++ b/recipes/spirv-tools/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.3.224.0": + url: "https://github.com/KhronosGroup/SPIRV-Tools/archive/refs/tags/sdk-1.3.224.0.tar.gz" + sha256: "428b83f2710c07123cf2ec21934389f893aa0b570d1fe4aba6e38718c9a6ea69" "1.3.216.0": url: "https://github.com/KhronosGroup/SPIRV-Tools/archive/refs/tags/sdk-1.3.216.0.tar.gz" sha256: "b4b9abeb59deda20c41808ac4cd5f9faf6f0a9daa51a8c82e13ca47c045e982f" @@ -29,29 +32,18 @@ sources: patches: "2021.4": - patch_file: "patches/0001-fix-cmake-iOS-tvOS-watchOS-2021.3.patch" - base_path: "source_subfolder" "2021.3": - patch_file: "patches/0001-fix-cmake-iOS-tvOS-watchOS-2021.3.patch" - base_path: "source_subfolder" "2021.2": - patch_file: "patches/0001-fix-cmake-iOS-tvOS-watchOS-2021.2.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-allow-more-platforms-2020.3.patch" - base_path: "source_subfolder" "2020.5": - patch_file: "patches/0001-fix-cmake-iOS-tvOS-watchOS-2020.5.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-allow-more-platforms-2020.3.patch" - base_path: "source_subfolder" - patch_file: "patches/0003-support-SPV_KHR_fragment_shading_rate.patch" - base_path: "source_subfolder" "2020.3": - patch_file: "patches/0001-fix-cmake-iOS-tvOS-watchOS-2020.3.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-allow-more-platforms-2020.3.patch" - base_path: "source_subfolder" "2019.2": - patch_file: "patches/0001-fix-cmake-iOS-tvOS-watchOS-2019.2.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-allow-more-platforms-2019.2.patch" - base_path: "source_subfolder" diff --git a/recipes/spirv-tools/all/conanfile.py b/recipes/spirv-tools/all/conanfile.py index 989792597110b..7f8d2a0bea0dc 100644 --- a/recipes/spirv-tools/all/conanfile.py +++ b/recipes/spirv-tools/all/conanfile.py @@ -1,9 +1,16 @@ -from conans import ConanFile, tools, CMake -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.errors import ConanException +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, replace_in_file, rm, rmdir, save +from conan.tools.scm import Version +from conans import tools as tools_legacy +import functools import os import textwrap +import yaml -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" class SpirvtoolsConan(ConanFile): @@ -28,17 +35,6 @@ class SpirvtoolsConan(ConanFile): short_paths = True - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - @staticmethod def _greater_equal_semver(v1, v2): lv1 = [int(v) for v in v1.split(".")] @@ -50,21 +46,36 @@ def _greater_equal_semver(v1, v2): lv2.extend([0] * -diff_len) return lv1 >= lv2 + @property + def _dependencies_filename(self): + return f"dependencies-{self.version}.yml" + + @property + @functools.lru_cache(1) + def _dependencies_versions(self): + dependencies_filepath = os.path.join(self.recipe_folder, "dependencies", self._dependencies_filename) + if not os.path.isfile(dependencies_filepath): + raise ConanException(f"Cannot find {dependencies_filepath}") + cached_dependencies = yaml.safe_load(open(dependencies_filepath)) + return cached_dependencies + @property def _has_spirv_tools_lint(self): - return (tools.Version(self.version) < "2016.6" or # spirv-tools with vulkan versioning - tools.Version(self.version) >= "2021.3") + return (Version(self.version) < "2016.6" or # spirv-tools with vulkan versioning + Version(self.version) >= "2021.3") @property def _has_spirv_tools_diff(self): # TODO: use tools.Version comparison once https://github.com/conan-io/conan/issues/10000 is fixed - return ((self._greater_equal_semver(self.version, "1.3.211") and tools.Version(self.version) < "2016.6") or # spirv-tools with vulkan versioning - tools.Version(self.version) >= "2022.2") + return ((self._greater_equal_semver(self.version, "1.3.211") and Version(self.version) < "2016.6") or # spirv-tools with vulkan versioning + Version(self.version) >= "2022.2") + + def export(self): + copy(self, f"dependencies/{self._dependencies_filename}", self.recipe_folder, self.export_folder) def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -74,38 +85,27 @@ def configure(self): if self.options.shared: del self.options.fPIC - def requirements(self): - self.requires("spirv-headers/{}".format(self._get_compatible_spirv_headers_version)) + def _require(self, recipe_name): + if recipe_name not in self._dependencies_versions: + raise ConanException(f"{recipe_name} is missing in {self._dependencies_filename}") + return f"{recipe_name}/{self._dependencies_versions[recipe_name]}" - @property - def _get_compatible_spirv_headers_version(self): - return { - "2021.4": "1.2.198.0", - "2021.3": "cci.20210811", - "2021.2": "cci.20210616", - "2020.5": "1.5.4", - "2020.3": "1.5.3", - "2019.2": "1.5.1", - }.get(str(self.version), self.version) + def requirements(self): + self.requires(self._require("spirv-headers")) def validate(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) - def _validate_dependency_graph(self): - if self.deps_cpp_info["spirv-headers"].version != self._get_compatible_spirv_headers_version: - raise ConanInvalidConfiguration("spirv-tools {0} requires spirv-headers {1}" - .format(self.version, self._get_compatible_spirv_headers_version)) + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - - cmake = CMake(self) + def generate(self): + tc = CMakeToolchain(self) #==================== # Shared libs mess in Spirv-Tools (see https://github.com/KhronosGroup/SPIRV-Tools/issues/3909) @@ -121,71 +121,69 @@ def _configure_cmake(self): # - Before 2020.5, the shared lib is always built, but static libs might be built as shared # with BUILD_SHARED_LIBS injection (which doesn't work due to symbols visibility, at least for msvc) # - From 2020.5, static and shared libs are fully controlled by upstream CMakeLists.txt - if tools.Version(self.version) >= "2016.6" and tools.Version(self.version) < "2020.5": - cmake.definitions["BUILD_SHARED_LIBS"] = False + if Version(self.version) >= "2016.6" and Version(self.version) < "2020.5": + tc.blocks.remove("shared") + tc.variables["BUILD_SHARED_LIBS"] = False # From 2020.6, same behavior than above but through a weird combination # of SPIRV_TOOLS_BUILD_STATIC and BUILD_SHARED_LIBS. - if tools.Version(self.version) < "2016.6" or tools.Version(self.version) >= "2020.6": - cmake.definitions["SPIRV_TOOLS_BUILD_STATIC"] = True + if Version(self.version) < "2016.6" or Version(self.version) >= "2020.6": + tc.variables["SPIRV_TOOLS_BUILD_STATIC"] = True #============ # Required by the project's CMakeLists.txt - cmake.definitions["SPIRV-Headers_SOURCE_DIR"] = self.deps_cpp_info["spirv-headers"].rootpath.replace("\\", "/") + tc.variables["SPIRV-Headers_SOURCE_DIR"] = self.dependencies["spirv-headers"].package_folder.replace("\\", "/") # There are some switch( ) statements that are causing errors # need to turn this off - cmake.definitions["SPIRV_WERROR"] = False - - cmake.definitions["SKIP_SPIRV_TOOLS_INSTALL"] = False - cmake.definitions["SPIRV_LOG_DEBUG"] = False - cmake.definitions["SPIRV_SKIP_TESTS"] = True - cmake.definitions["SPIRV_CHECK_CONTEXT"] = False - cmake.definitions["SPIRV_BUILD_FUZZER"] = False - cmake.definitions["SPIRV_SKIP_EXECUTABLES"] = not self.options.build_executables + tc.variables["SPIRV_WERROR"] = False + + tc.variables["SKIP_SPIRV_TOOLS_INSTALL"] = False + tc.variables["SPIRV_LOG_DEBUG"] = False + tc.variables["SPIRV_SKIP_TESTS"] = True + tc.variables["SPIRV_CHECK_CONTEXT"] = False + tc.variables["SPIRV_BUILD_FUZZER"] = False + tc.variables["SPIRV_SKIP_EXECUTABLES"] = not self.options.build_executables # To install relocatable shared libs on Macos - cmake.definitions["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" - cmake.configure(build_folder=self._build_subfolder) - self._cmake = cmake - return self._cmake - - def build(self): - self._validate_dependency_graph() - self._patch_sources() - cmake = self._configure_cmake() - cmake.build() + tc.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) # CMAKE_POSITION_INDEPENDENT_CODE was set ON for the entire # project in the lists file. - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "") + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + def package(self): - self.copy(pattern="LICENSE*", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "SPIRV-Tools")) - tools.rmdir(os.path.join(self.package_folder, "SPIRV-Tools-link")) - tools.rmdir(os.path.join(self.package_folder, "SPIRV-Tools-opt")) - tools.rmdir(os.path.join(self.package_folder, "SPIRV-Tools-reduce")) - tools.rmdir(os.path.join(self.package_folder, "SPIRV-Tools-lint")) - tools.rmdir(os.path.join(self.package_folder, "SPIRV-Tools-diff")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "SPIRV-Tools")) + rmdir(self, os.path.join(self.package_folder, "SPIRV-Tools-link")) + rmdir(self, os.path.join(self.package_folder, "SPIRV-Tools-opt")) + rmdir(self, os.path.join(self.package_folder, "SPIRV-Tools-reduce")) + rmdir(self, os.path.join(self.package_folder, "SPIRV-Tools-lint")) + rmdir(self, os.path.join(self.package_folder, "SPIRV-Tools-diff")) if self.options.shared: for file_name in [ "*SPIRV-Tools", "*SPIRV-Tools-opt", "*SPIRV-Tools-link", "*SPIRV-Tools-reduce", "*SPIRV-Tools-lint", ]: for ext in [".a", ".lib"]: - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), file_name + ext) + rm(self, f"{file_name}{ext}", os.path.join(self.package_folder, "lib")) else: - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*SPIRV-Tools-shared.dll") - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*SPIRV-Tools-shared*") + rm(self, "*SPIRV-Tools-shared.dll", os.path.join(self.package_folder, "bin")) + rm(self, "*SPIRV-Tools-shared*", os.path.join(self.package_folder, "lib")) # TODO: to remove in conan v2 once cmake_find_package* generators removed if self.options.shared: @@ -207,21 +205,20 @@ def package(self): targets, ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) + """) + save(self, module_file, content) @property def _module_file_rel_path(self): - return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") def package_info(self): self.cpp_info.set_property("cmake_file_name", "SPIRV-Tools") @@ -239,8 +236,10 @@ def package_info(self): self.cpp_info.components["spirv-tools-core"].defines = ["SPIRV_TOOLS_SHAREDLIB"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["spirv-tools-core"].system_libs.extend(["m", "rt"]) - if not self.options.shared and tools.stdcpp_library(self): - self.cpp_info.components["spirv-tools-core"].system_libs.append(tools.stdcpp_library(self)) + if not self.options.shared: + libcxx = tools_legacy.stdcpp_library(self) + if libcxx: + self.cpp_info.components["spirv-tools-core"].system_libs.append(libcxx) # FIXME: others components should have their own CMake config file if not self.options.shared: @@ -275,7 +274,7 @@ def package_info(self): if self.options.build_executables: bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.output.info(f"Appending PATH environment variable: {bin_path}") self.env_info.path.append(bin_path) # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed diff --git a/recipes/spirv-tools/all/dependencies/dependencies-1.3.204.0.yml b/recipes/spirv-tools/all/dependencies/dependencies-1.3.204.0.yml new file mode 100644 index 0000000000000..43572f8e0b17d --- /dev/null +++ b/recipes/spirv-tools/all/dependencies/dependencies-1.3.204.0.yml @@ -0,0 +1 @@ +spirv-headers: "1.3.204.0" diff --git a/recipes/spirv-tools/all/dependencies/dependencies-1.3.211.0.yml b/recipes/spirv-tools/all/dependencies/dependencies-1.3.211.0.yml new file mode 100644 index 0000000000000..9f7968c50691a --- /dev/null +++ b/recipes/spirv-tools/all/dependencies/dependencies-1.3.211.0.yml @@ -0,0 +1 @@ +spirv-headers: "1.3.211.0" diff --git a/recipes/spirv-tools/all/dependencies/dependencies-1.3.216.0.yml b/recipes/spirv-tools/all/dependencies/dependencies-1.3.216.0.yml new file mode 100644 index 0000000000000..08fc67132f957 --- /dev/null +++ b/recipes/spirv-tools/all/dependencies/dependencies-1.3.216.0.yml @@ -0,0 +1 @@ +spirv-headers: "1.3.216.0" diff --git a/recipes/spirv-tools/all/dependencies/dependencies-1.3.224.0.yml b/recipes/spirv-tools/all/dependencies/dependencies-1.3.224.0.yml new file mode 100644 index 0000000000000..fbe7be91a9a03 --- /dev/null +++ b/recipes/spirv-tools/all/dependencies/dependencies-1.3.224.0.yml @@ -0,0 +1 @@ +spirv-headers: "1.3.224.0" diff --git a/recipes/spirv-tools/all/dependencies/dependencies-2019.2.yml b/recipes/spirv-tools/all/dependencies/dependencies-2019.2.yml new file mode 100644 index 0000000000000..65a98f17df9ed --- /dev/null +++ b/recipes/spirv-tools/all/dependencies/dependencies-2019.2.yml @@ -0,0 +1 @@ +spirv-headers: "1.5.1" diff --git a/recipes/spirv-tools/all/dependencies/dependencies-2020.3.yml b/recipes/spirv-tools/all/dependencies/dependencies-2020.3.yml new file mode 100644 index 0000000000000..66b9ce2858da6 --- /dev/null +++ b/recipes/spirv-tools/all/dependencies/dependencies-2020.3.yml @@ -0,0 +1 @@ +spirv-headers: "1.5.3" diff --git a/recipes/spirv-tools/all/dependencies/dependencies-2020.5.yml b/recipes/spirv-tools/all/dependencies/dependencies-2020.5.yml new file mode 100644 index 0000000000000..c1d1a00b17b22 --- /dev/null +++ b/recipes/spirv-tools/all/dependencies/dependencies-2020.5.yml @@ -0,0 +1 @@ +spirv-headers: "1.5.4" diff --git a/recipes/spirv-tools/all/dependencies/dependencies-2021.2.yml b/recipes/spirv-tools/all/dependencies/dependencies-2021.2.yml new file mode 100644 index 0000000000000..65339a051aa56 --- /dev/null +++ b/recipes/spirv-tools/all/dependencies/dependencies-2021.2.yml @@ -0,0 +1 @@ +spirv-headers: "cci.20210616" diff --git a/recipes/spirv-tools/all/dependencies/dependencies-2021.3.yml b/recipes/spirv-tools/all/dependencies/dependencies-2021.3.yml new file mode 100644 index 0000000000000..c2baefe5349ed --- /dev/null +++ b/recipes/spirv-tools/all/dependencies/dependencies-2021.3.yml @@ -0,0 +1 @@ +spirv-headers: "cci.20210811" diff --git a/recipes/spirv-tools/all/dependencies/dependencies-2021.4.yml b/recipes/spirv-tools/all/dependencies/dependencies-2021.4.yml new file mode 100644 index 0000000000000..2657ddb54c2ee --- /dev/null +++ b/recipes/spirv-tools/all/dependencies/dependencies-2021.4.yml @@ -0,0 +1 @@ +spirv-headers: "1.2.198.0" diff --git a/recipes/spirv-tools/all/test_package/CMakeLists.txt b/recipes/spirv-tools/all/test_package/CMakeLists.txt index a50bbef408527..cd25f7b050b0e 100644 --- a/recipes/spirv-tools/all/test_package/CMakeLists.txt +++ b/recipes/spirv-tools/all/test_package/CMakeLists.txt @@ -1,23 +1,20 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - find_package(SPIRV-Tools REQUIRED CONFIG) add_executable(${PROJECT_NAME}_c test_package.c) if(TARGET SPIRV-Tools-shared) - target_link_libraries(${PROJECT_NAME}_c SPIRV-Tools-shared) + target_link_libraries(${PROJECT_NAME}_c PRIVATE SPIRV-Tools-shared) elseif(TARGET SPIRV-Tools-static) - target_link_libraries(${PROJECT_NAME}_c SPIRV-Tools-static) + target_link_libraries(${PROJECT_NAME}_c PRIVATE SPIRV-Tools-static) else() - target_link_libraries(${PROJECT_NAME}_c SPIRV-Tools) + target_link_libraries(${PROJECT_NAME}_c PRIVATE SPIRV-Tools) endif() # TODO: we should call find_package(SPIRV-Tools-opt REQUIRED CONFIG), but not modeled right now if(TARGET SPIRV-Tools-opt) add_executable(${PROJECT_NAME}_cpp test_package.cpp) - target_link_libraries(${PROJECT_NAME}_cpp SPIRV-Tools-opt) - set_property(TARGET ${PROJECT_NAME}_cpp PROPERTY CXX_STANDARD 11) + target_link_libraries(${PROJECT_NAME}_cpp PRIVATE SPIRV-Tools-opt) + target_compile_features(${PROJECT_NAME}_cpp PRIVATE cxx_std_11) endif() diff --git a/recipes/spirv-tools/all/test_package/conanfile.py b/recipes/spirv-tools/all/test_package/conanfile.py index 0244d69a545f1..1235aa2253cef 100644 --- a/recipes/spirv-tools/all/test_package/conanfile.py +++ b/recipes/spirv-tools/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,9 +20,9 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path_c = os.path.join("bin", "test_package_c") - self.run(bin_path_c, run_environment=True) - if not self.options["spirv-tools"].shared: - bin_path_cpp = os.path.join("bin", "test_package_cpp") - self.run(bin_path_cpp, run_environment=True) + if can_run(self): + bin_path_c = os.path.join(self.cpp.build.bindirs[0], "test_package_c") + self.run(bin_path_c, env="conanrun") + bin_path_cpp = os.path.join(self.cpp.build.bindirs[0], "test_package_cpp") + if os.path.exists(bin_path_cpp): + self.run(bin_path_cpp, env="conanrun") diff --git a/recipes/spirv-tools/all/test_v1_package/CMakeLists.txt b/recipes/spirv-tools/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..28cb54d7435c5 --- /dev/null +++ b/recipes/spirv-tools/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(SPIRV-Tools REQUIRED CONFIG) + +add_executable(${PROJECT_NAME}_c ../test_package/test_package.c) +if(TARGET SPIRV-Tools-shared) + target_link_libraries(${PROJECT_NAME}_c PRIVATE SPIRV-Tools-shared) +elseif(TARGET SPIRV-Tools-static) + target_link_libraries(${PROJECT_NAME}_c PRIVATE SPIRV-Tools-static) +else() + target_link_libraries(${PROJECT_NAME}_c PRIVATE SPIRV-Tools) +endif() + +# TODO: we should call find_package(SPIRV-Tools-opt REQUIRED CONFIG), but not modeled right now +if(TARGET SPIRV-Tools-opt) + add_executable(${PROJECT_NAME}_cpp ../test_package/test_package.cpp) + target_link_libraries(${PROJECT_NAME}_cpp PRIVATE SPIRV-Tools-opt) + target_compile_features(${PROJECT_NAME}_cpp PRIVATE cxx_std_11) +endif() diff --git a/recipes/spirv-tools/all/test_v1_package/conanfile.py b/recipes/spirv-tools/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..0244d69a545f1 --- /dev/null +++ b/recipes/spirv-tools/all/test_v1_package/conanfile.py @@ -0,0 +1,20 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path_c = os.path.join("bin", "test_package_c") + self.run(bin_path_c, run_environment=True) + if not self.options["spirv-tools"].shared: + bin_path_cpp = os.path.join("bin", "test_package_cpp") + self.run(bin_path_cpp, run_environment=True) diff --git a/recipes/spirv-tools/config.yml b/recipes/spirv-tools/config.yml index b42e0238c0475..0b673c62a4f58 100644 --- a/recipes/spirv-tools/config.yml +++ b/recipes/spirv-tools/config.yml @@ -1,4 +1,6 @@ versions: + "1.3.224.0": + folder: all "1.3.216.0": folder: all "1.3.211.0": diff --git a/recipes/tgc/all/CMakeLists.txt b/recipes/tgc/all/CMakeLists.txt index c823108682b01..8f1121172b940 100644 --- a/recipes/tgc/all/CMakeLists.txt +++ b/recipes/tgc/all/CMakeLists.txt @@ -1,15 +1,13 @@ cmake_minimum_required(VERSION 3.4) -project(tgc C) +project(tgc LANGUAGES C) -include(conanbuildinfo.cmake) -conan_basic_setup() +add_library(tgc ${TGC_SRC_DIR}/tgc.c) +set_property(TARGET tgc PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS TRUE) -add_library(${PROJECT_NAME} source_subfolder/tgc.c) -set_property(TARGET ${PROJECT_NAME} PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - -install(TARGETS ${PROJECT_NAME} +include(GNUInstallDirs) +install(TARGETS tgc RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(FILES source_subfolder/tgc.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${TGC_SRC_DIR}/tgc.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/tgc/all/conanfile.py b/recipes/tgc/all/conanfile.py index 147124ae8a37e..a608a5953817a 100644 --- a/recipes/tgc/all/conanfile.py +++ b/recipes/tgc/all/conanfile.py @@ -1,13 +1,16 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.46.0" class TgcConan(ConanFile): name = "tgc" description = "A Tiny Garbage Collector for C." license = "BSD-2-Clause" - topics = ("conan", "tgc", "garbage-collector") + topics = ("tgc", "garbage-collector") homepage = "https://github.com/orangeduck/tgc" url = "https://github.com/conan-io/conan-center-index" @@ -22,12 +25,6 @@ class TgcConan(ConanFile): } exports_sources = "CMakeLists.txt" - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" def config_options(self): if self.settings.os == "Windows": @@ -36,27 +33,35 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure() - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["TGC_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) cmake.build() def package(self): - self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): diff --git a/recipes/tgc/all/test_package/CMakeLists.txt b/recipes/tgc/all/test_package/CMakeLists.txt index 7b9b613cbb24a..c3e8ecbc7e427 100644 --- a/recipes/tgc/all/test_package/CMakeLists.txt +++ b/recipes/tgc/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(tgc REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE tgc::tgc) diff --git a/recipes/tgc/all/test_package/conanfile.py b/recipes/tgc/all/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/tgc/all/test_package/conanfile.py +++ b/recipes/tgc/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/tgc/all/test_v1_package/CMakeLists.txt b/recipes/tgc/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..3c18b56dfcebf --- /dev/null +++ b/recipes/tgc/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(tgc REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE tgc::tgc) diff --git a/recipes/tgc/all/test_v1_package/conanfile.py b/recipes/tgc/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/tgc/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/transwarp/all/conanfile.py b/recipes/transwarp/all/conanfile.py index 8dc43532fab61..7f3db7cd491f8 100644 --- a/recipes/transwarp/all/conanfile.py +++ b/recipes/transwarp/all/conanfile.py @@ -1,7 +1,10 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" class TranswarpConan(ConanFile): @@ -11,28 +14,34 @@ class TranswarpConan(ConanFile): topics = ("transwarp", "concurrency", "asynchronous") homepage = "https://github.com/bloomen/transwarp" url = "https://github.com/conan-io/conan-center-index" - settings = "os", "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" + def package_id(self): + self.info.clear() def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) + check_min_cppstd(self, 11) - def package_id(self): - self.info.header_only() + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) - self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("pthread") diff --git a/recipes/transwarp/all/test_package/CMakeLists.txt b/recipes/transwarp/all/test_package/CMakeLists.txt index a640b0ed63892..eb80581dc80e9 100644 --- a/recipes/transwarp/all/test_package/CMakeLists.txt +++ b/recipes/transwarp/all/test_package/CMakeLists.txt @@ -1,10 +1,9 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(transwarp REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE transwarp::transwarp) target_compile_definitions(${PROJECT_NAME} PRIVATE TRANSWARP_CPP11) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/transwarp/all/test_package/conanfile.py b/recipes/transwarp/all/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/transwarp/all/test_package/conanfile.py +++ b/recipes/transwarp/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/transwarp/all/test_v1_package/CMakeLists.txt b/recipes/transwarp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f5ef1888af073 --- /dev/null +++ b/recipes/transwarp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(transwarp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE transwarp::transwarp) +target_compile_definitions(${PROJECT_NAME} PRIVATE TRANSWARP_CPP11) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/transwarp/all/test_v1_package/conanfile.py b/recipes/transwarp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/transwarp/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/vectorial/all/conanfile.py b/recipes/vectorial/all/conanfile.py index 50dc70b526193..fd7818ff4d997 100644 --- a/recipes/vectorial/all/conanfile.py +++ b/recipes/vectorial/all/conanfile.py @@ -1,34 +1,42 @@ -from conans import ConanFile, tools -import glob +from conan import ConanFile +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout import os +required_conan_version = ">=1.50.0" + class VectorialConan(ConanFile): name = "vectorial" description = "Vector math library with NEON/SSE support" - topics = ("conan", "vectorial", "math", "vector") + topics = ("vectorial", "math", "vector") license = "BSD-2-Clause" homepage = "https://github.com/scoopr/vectorial" url = "https://github.com/conan-io/conan-center-index" - settings = "os" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return "source_subfolder" - def package_id(self): - self.info.header_only() + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob.glob("vectorial-*")[0] - os.rename(extracted_dir, self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) def package_info(self): - if self.settings.os == "Linux": + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] diff --git a/recipes/vectorial/all/test_package/CMakeLists.txt b/recipes/vectorial/all/test_package/CMakeLists.txt index 196188113685c..ed8a803f47fad 100644 --- a/recipes/vectorial/all/test_package/CMakeLists.txt +++ b/recipes/vectorial/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(vectorial REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE vectorial::vectorial) diff --git a/recipes/vectorial/all/test_package/conanfile.py b/recipes/vectorial/all/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/vectorial/all/test_package/conanfile.py +++ b/recipes/vectorial/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/vectorial/all/test_v1_package/CMakeLists.txt b/recipes/vectorial/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..394022f35f7ca --- /dev/null +++ b/recipes/vectorial/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(vectorial REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE vectorial::vectorial) diff --git a/recipes/vectorial/all/test_v1_package/conanfile.py b/recipes/vectorial/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/vectorial/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/xkbcommon/all/conanfile.py b/recipes/xkbcommon/all/conanfile.py index 19621077451e7..069c77a267a91 100644 --- a/recipes/xkbcommon/all/conanfile.py +++ b/recipes/xkbcommon/all/conanfile.py @@ -1,7 +1,11 @@ +import os + from conan import ConanFile -from conan.tools import scm, files +from conan.tools.files import copy, get, replace_in_file, rmdir +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.scm import Version from conan.errors import ConanInvalidConfiguration -from conans import Meson, tools required_conan_version = ">=1.50.0" @@ -30,20 +34,11 @@ class XkbcommonConan(ConanFile): "xkbregistry": True, } - generators = "pkg_config" - _meson = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + generators = "PkgConfigDeps", "VirtualBuildEnv", "VirtualRunEnv" @property def _has_xkbregistry_option(self): - return scm.Version(self.version) >= "1.0.0" + return Version(self.version) >= "1.0.0" def config_options(self): if not self._has_xkbregistry_option: @@ -70,80 +65,97 @@ def validate(self): raise ConanInvalidConfiguration("This library is only compatible with Linux or FreeBSD") def build_requirements(self): - self.build_requires("meson/0.63.1") - self.build_requires("bison/3.7.6") - if hasattr(self, "settings_build") and self.options.get_safe("wayland"): - self.build_requires("wayland/1.21.0") + self.tool_requires("meson/0.63.1") + self.tool_requires("bison/3.7.6") + self.tool_requires("pkgconf/1.7.4") + if self.options.get_safe("with_wayland"): + self.tool_requires("wayland/1.21.0") + + def layout(self): + basic_layout(self, src_folder="src") def source(self): - files.get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], strip_root=True) - # Conan doesn't provide a `wayland-scanner.pc` file for the package in the _build_ context - files.replace_in_file(self, f"{self._source_subfolder}/meson.build", - "wayland_scanner_dep = dependency('wayland-scanner', required: false, native: true)", - "# wayland_scanner_dep = dependency('wayland-scanner', required: false, native: true)") - - files.replace_in_file(self, f"{self._source_subfolder}/meson.build", - "if not wayland_client_dep.found() or not wayland_protocols_dep.found() or not wayland_scanner_dep.found()", - "if not wayland_client_dep.found() or not wayland_protocols_dep.found()") - - files.replace_in_file(self, f"{self._source_subfolder}/meson.build", - "wayland_scanner = find_program(wayland_scanner_dep.get_pkgconfig_variable('wayland_scanner'))", - "wayland_scanner = find_program('wayland-scanner')") - - def _configure_meson(self): - if self._meson: - return self._meson - defs={ - "enable-wayland": self.options.get_safe("with_wayland", False), - "enable-docs": False, - "enable-x11": self.options.with_x11, - "libdir": f"{self.package_folder}/lib", - "default_library": ("shared" if self.options.shared else "static")} - if self._has_xkbregistry_option: - defs["enable-xkbregistry"] = self.options.xkbregistry + def generate(self): + tc = MesonToolchain(self) + + tc.project_options["libexecdir"] = "bin" + tc.project_options["libdir"] = "lib" + tc.project_options["datadir"] = "res" - self._meson = Meson(self) - self._meson.configure( - defs=defs, - source_folder=self._source_subfolder, - build_folder=self._build_subfolder, - pkg_config_paths=self.build_folder) - return self._meson + tc.project_options["enable-docs"] = False + tc.project_options["enable-wayland"] = self.options.get_safe("with_wayland", False) + tc.project_options["enable-x11"] = self.options.with_x11 + + if self._has_xkbregistry_option: + tc.project_options["enable-xkbregistry"] = self.options.xkbregistry + tc.generate() def build(self): - with tools.run_environment(self): - meson = self._configure_meson() - meson.build() + # Conan doesn't provide a `wayland-scanner.pc` file for the package in the _build_ context + meson_build_file = os.path.join(self.source_folder, "meson.build") + replace_in_file(self, meson_build_file, + "wayland_scanner_dep = dependency('wayland-scanner', required: false, native: true)", + "# wayland_scanner_dep = dependency('wayland-scanner', required: false, native: true)") + + replace_in_file(self, meson_build_file, + "if not wayland_client_dep.found() or not wayland_protocols_dep.found() or not wayland_scanner_dep.found()", + "if not wayland_client_dep.found() or not wayland_protocols_dep.found()") + + replace_in_file(self, meson_build_file, + "wayland_scanner = find_program(wayland_scanner_dep.get_pkgconfig_variable('wayland_scanner'))", + "wayland_scanner = find_program('wayland-scanner')") + + meson = Meson(self) + meson.configure() + meson.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - meson = self._configure_meson() + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + meson = Meson(self) meson.install() - files.rmdir(self, f"{self.package_folder}/lib/pkgconfig") - files.rmdir(self, f"{self.package_folder}/share") + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): self.cpp_info.components["libxkbcommon"].set_property("pkg_config_name", "xkbcommon") self.cpp_info.components["libxkbcommon"].libs = ["xkbcommon"] self.cpp_info.components["libxkbcommon"].requires = ["xorg::xkeyboard-config"] + self.cpp_info.components["libxkbcommon"].resdirs = ["res"] + + # todo Remove in Conan version 1.50.0 where these are set by default for the PkgConfigDeps generator. + self.cpp_info.components["libxkbcommon"].includedirs = ["include"] + self.cpp_info.components["libxkbcommon"].libdirs = ["lib"] + if self.options.with_x11: self.cpp_info.components["libxkbcommon-x11"].set_property("pkg_config_name", "xkbcommon-x11") self.cpp_info.components["libxkbcommon-x11"].libs = ["xkbcommon-x11"] self.cpp_info.components["libxkbcommon-x11"].requires = ["libxkbcommon", "xorg::xcb", "xorg::xcb-xkb"] + + # todo Remove in Conan version 1.50.0 where these are set by default for the PkgConfigDeps generator. + self.cpp_info.components["libxkbcommon-x11"].includedirs = ["include"] + self.cpp_info.components["libxkbcommon-x11"].libdirs = ["lib"] if self.options.get_safe("xkbregistry"): self.cpp_info.components["libxkbregistry"].set_property("pkg_config_name", "xkbregistry") self.cpp_info.components["libxkbregistry"].libs = ["xkbregistry"] self.cpp_info.components["libxkbregistry"].requires = ["libxml2::libxml2"] + + # todo Remove in Conan version 1.50.0 where these are set by default for the PkgConfigDeps generator. + self.cpp_info.components["libxkbregistry"].includedirs = ["include"] + self.cpp_info.components["libxkbregistry"].libdirs = ["lib"] if self.options.get_safe("with_wayland", False): # FIXME: This generates just executable, but I need to use the requirements to pass Conan checks self.cpp_info.components["xkbcli-interactive-wayland"].libs = [] + self.cpp_info.components["xkbcli-interactive-wayland"].includedirs = [] self.cpp_info.components["xkbcli-interactive-wayland"].requires = ["wayland::wayland", "wayland-protocols::wayland-protocols"] - if scm.Version(self.version) >= "1.0.0": - bin_path = f"{self.package_folder}/bin" - self.output.info(f"Appending PATH environment variable: {bin_path}") - self.env_info.PATH.append(bin_path) + if Version(self.version) >= "1.0.0": + bindir = os.path.join(self.package_folder, "bin") + self.buildenv_info.prepend_path("PATH", bindir) + self.runenv_info.prepend_path("PATH", bindir) + self.output.info(f"Appending PATH environment variable: {bindir}") + self.env_info.PATH.append(bindir) # unofficial, but required to avoid side effects (libxkbcommon component # "steals" the default global pkg_config name) diff --git a/recipes/xkbcommon/all/test_package/CMakeLists.txt b/recipes/xkbcommon/all/test_package/CMakeLists.txt index 196188113685c..0b0b6cb9fe82d 100644 --- a/recipes/xkbcommon/all/test_package/CMakeLists.txt +++ b/recipes/xkbcommon/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(xkbcommon REQUIRED COMPONENTS libxkbcommon) -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(test_package test_package.cpp) +target_link_libraries(test_package PRIVATE xkbcommon::libxkbcommon) diff --git a/recipes/xkbcommon/all/test_package/conanfile.py b/recipes/xkbcommon/all/test_package/conanfile.py index 5c09494bc67c0..eecad0444878e 100644 --- a/recipes/xkbcommon/all/test_package/conanfile.py +++ b/recipes/xkbcommon/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -from conans import ConanFile, CMake, tools import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake +from conan.tools.layout import cmake_layout + class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +22,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + cmd = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(cmd, env="conanrun") diff --git a/recipes/xkbcommon/all/test_v1_package/CMakeLists.txt b/recipes/xkbcommon/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..578486105d7d3 --- /dev/null +++ b/recipes/xkbcommon/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/xkbcommon/all/test_v1_package/conanfile.py b/recipes/xkbcommon/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..e49d2fb75e704 --- /dev/null +++ b/recipes/xkbcommon/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +import os + +from conans import ConanFile, CMake +from conan.tools.build import cross_building + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/zstd/all/CMakeLists.txt b/recipes/zstd/all/CMakeLists.txt deleted file mode 100644 index 61bd2fed4ac50..0000000000000 --- a/recipes/zstd/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.0) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory(source_subfolder/build/cmake) diff --git a/recipes/zstd/all/conandata.yml b/recipes/zstd/all/conandata.yml index 4883b93777781..9c8ee8682a9a5 100644 --- a/recipes/zstd/all/conandata.yml +++ b/recipes/zstd/all/conandata.yml @@ -33,12 +33,11 @@ sources: sha256: f7de13462f7a82c29ab865820149e778cbfe01087b3a55b5332707abf9db4a6e url: https://github.com/facebook/zstd/archive/v1.5.2.tar.gz patches: + "1.3.5": + - patch_file: "patches/1.3.5-cmake-project.patch" "1.4.5": - - base_path: "source_subfolder" - patch_file: "patches/1.4.5-cmake-install-dll.patch" + - patch_file: "patches/1.4.5-cmake-install-dll.patch" "1.5.1": - - base_path: "source_subfolder" - patch_file: "patches/1.5.1-cmake-remove-asm-except-x86_64.patch" + - patch_file: "patches/1.5.1-cmake-remove-asm-except-x86_64.patch" "1.5.2": - - base_path: "source_subfolder" - patch_file: "patches/1.5.2-cmake-remove-asm-except-x86_64.patch" + - patch_file: "patches/1.5.2-cmake-remove-asm-except-x86_64.patch" diff --git a/recipes/zstd/all/conanfile.py b/recipes/zstd/all/conanfile.py index eb822dc4996e2..e3a3712bb2cbe 100644 --- a/recipes/zstd/all/conanfile.py +++ b/recipes/zstd/all/conanfile.py @@ -1,7 +1,10 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, get, replace_in_file, rmdir +from conan.tools.scm import Version import os -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" class ZstdConan(ConanFile): @@ -24,21 +27,9 @@ class ZstdConan(ConanFile): "threading": True, } - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def export_sources(self): - self.copy("CMakeLists.txt") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -47,55 +38,62 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["ZSTD_BUILD_PROGRAMS"] = False - self._cmake.definitions["ZSTD_BUILD_STATIC"] = not self.options.shared - self._cmake.definitions["ZSTD_BUILD_SHARED"] = self.options.shared - self._cmake.definitions["ZSTD_MULTITHREAD_SUPPORT"] = self.options.threading - if tools.Version(self.version) < "1.4.3": + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["ZSTD_BUILD_PROGRAMS"] = False + tc.variables["ZSTD_BUILD_STATIC"] = not self.options.shared + tc.variables["ZSTD_BUILD_SHARED"] = self.options.shared + tc.variables["ZSTD_MULTITHREAD_SUPPORT"] = self.options.threading + if Version(self.version) < "1.4.3": # Generate a relocatable shared lib on Macos - self._cmake.definitions["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) # Don't force PIC - if tools.Version(self.version) >= "1.4.5": - tools.replace_in_file(os.path.join(self._source_subfolder, "build", "cmake", "lib", "CMakeLists.txt"), + if Version(self.version) >= "1.4.5": + replace_in_file(self, os.path.join(self.source_folder, "build", "cmake", "lib", "CMakeLists.txt"), "POSITION_INDEPENDENT_CODE On", "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "build", "cmake")) cmake.build() def package(self): - self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): zstd_cmake = "libzstd_shared" if self.options.shared else "libzstd_static" self.cpp_info.set_property("cmake_file_name", "zstd") - self.cpp_info.set_property("cmake_target_name", "zstd::{}".format(zstd_cmake)) + self.cpp_info.set_property("cmake_target_name", f"zstd::{zstd_cmake}") self.cpp_info.set_property("pkg_config_name", "libzstd") self.cpp_info.components["zstdlib"].set_property("pkg_config_name", "libzstd") self.cpp_info.components["zstdlib"].names["cmake_find_package"] = zstd_cmake self.cpp_info.components["zstdlib"].names["cmake_find_package_multi"] = zstd_cmake - self.cpp_info.components["zstdlib"].set_property("cmake_target_name", "zstd::{}".format(zstd_cmake)) - self.cpp_info.components["zstdlib"].libs = tools.collect_libs(self) + self.cpp_info.components["zstdlib"].set_property("cmake_target_name", f"zstd::{zstd_cmake}") + self.cpp_info.components["zstdlib"].libs = collect_libs(self) if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["zstdlib"].system_libs.append("pthread") diff --git a/recipes/zstd/all/patches/1.3.5-cmake-project.patch b/recipes/zstd/all/patches/1.3.5-cmake-project.patch new file mode 100644 index 0000000000000..c8c9479c8ede1 --- /dev/null +++ b/recipes/zstd/all/patches/1.3.5-cmake-project.patch @@ -0,0 +1,12 @@ +--- a/build/cmake/CMakeLists.txt ++++ b/build/cmake/CMakeLists.txt +@@ -7,8 +7,8 @@ + # in the COPYING file in the root directory of this source tree). + # ################################################################ + +-PROJECT(zstd) + CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9) ++PROJECT(zstd) + SET(ZSTD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..") + LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") + INCLUDE(GNUInstallDirs) diff --git a/recipes/zstd/all/test_package/CMakeLists.txt b/recipes/zstd/all/test_package/CMakeLists.txt index ff04507eac6bf..57a72caf9ad65 100644 --- a/recipes/zstd/all/test_package/CMakeLists.txt +++ b/recipes/zstd/all/test_package/CMakeLists.txt @@ -1,17 +1,11 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package LANGUAGES C) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/logo.png - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(zstd REQUIRED) +find_package(zstd REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) if (TARGET zstd::libzstd_shared) - target_link_libraries(${PROJECT_NAME} zstd::libzstd_shared) + target_link_libraries(${PROJECT_NAME} PRIVATE zstd::libzstd_shared) else() - target_link_libraries(${PROJECT_NAME} zstd::libzstd_static) + target_link_libraries(${PROJECT_NAME} PRIVATE zstd::libzstd_static) endif() diff --git a/recipes/zstd/all/test_package/conanfile.py b/recipes/zstd/all/test_package/conanfile.py index cb4e2b3389e8f..6220cddeb6ff4 100644 --- a/recipes/zstd/all/test_package/conanfile.py +++ b/recipes/zstd/all/test_package/conanfile.py @@ -1,10 +1,18 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os -from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + png_file = os.path.join(self.source_folder, "logo.png") + self.run(f"{bin_path} {png_file}", env="conanrun") diff --git a/recipes/zstd/all/test_package/test_package.c b/recipes/zstd/all/test_package/test_package.c index e4e3dc1955889..6ef7323d43a0d 100644 --- a/recipes/zstd/all/test_package/test_package.c +++ b/recipes/zstd/all/test_package/test_package.c @@ -113,9 +113,13 @@ static const char* createOutFilename_orDie(const char* filename) int main(int argc, const char** argv) { - const char* const inFilename = "logo.png"; + if (argc < 2) { + fprintf(stderr, "Need at least one argument\n"); + return 1; + } + const char* const inFilename = argv[1]; - const char* const outFilename = createOutFilename_orDie(inFilename); + const char* const outFilename = createOutFilename_orDie("logo.png"); compressFile_orDie(inFilename, outFilename, 1); return 0; diff --git a/recipes/zstd/all/test_v1_package/CMakeLists.txt b/recipes/zstd/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..62ad23c5ae022 --- /dev/null +++ b/recipes/zstd/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(zstd REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +if (TARGET zstd::libzstd_shared) + target_link_libraries(${PROJECT_NAME} PRIVATE zstd::libzstd_shared) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE zstd::libzstd_static) +endif() diff --git a/recipes/zstd/all/test_v1_package/conanfile.py b/recipes/zstd/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c6bf65d610aa1 --- /dev/null +++ b/recipes/zstd/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + png_file = os.path.join(self.source_folder, os.pardir, "test_package", "logo.png") + self.run(f"{bin_path} {png_file}", run_environment=True)