From 6605d2c96800d0c0e12fc94b5bf319bf03a930c7 Mon Sep 17 00:00:00 2001 From: Morwenn Date: Fri, 11 Aug 2023 22:33:13 +0200 Subject: [PATCH] Change Conan stuff: it now (only) works with Conan 2.X --- README.md | 2 +- conanfile.py | 4 ++-- docs/Tooling.md | 10 ++++++---- test_package/CMakeLists.txt | 5 +---- test_package/conanfile.py | 20 ++++++++++++++------ 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c35f8e37..4ab53896 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![cpp-sort logo](docs/images/cpp-sort-logo.svg) [![Latest Release](https://img.shields.io/badge/release-1.15.0-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.15.0) -[![Conan Package](https://img.shields.io/badge/conan-cpp--sort%2F1.15.0-blue.svg)](https://conan.io/center/cpp-sort?version=1.15.0) +[![Conan Package](https://img.shields.io/badge/conan-cpp--sort%2F1.15.0-blue.svg)](https://conan.io/center/recipes/cpp-sort?version=1.15.0) [![Code Coverage](https://codecov.io/gh/Morwenn/cpp-sort/branch/develop/graph/badge.svg)](https://codecov.io/gh/Morwenn/cpp-sort) [![Pitchfork Layout](https://img.shields.io/badge/standard-PFL-orange.svg)](https://github.com/vector-of-bool/pitchfork) diff --git a/conanfile.py b/conanfile.py index 29292930..6eee043e 100644 --- a/conanfile.py +++ b/conanfile.py @@ -58,12 +58,12 @@ def package(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "cpp-sort") - self.cpp_info.set_property("cmake_target_name", "cpp-sort") + self.cpp_info.set_property("cmake_target_name", "cpp-sort::cpp-sort") self.cpp_info.bindirs = [] self.cpp_info.libdirs = [] if is_msvc(self): - self.cpp_info.cxxflags = ["/permissive-"] + self.cpp_info.cxxflags = ["/permissive-", "/Zc:preprocessor"] def package_id(self): self.info.clear() # Header-only diff --git a/docs/Tooling.md b/docs/Tooling.md index 4fc5c48b..e3c7918d 100644 --- a/docs/Tooling.md +++ b/docs/Tooling.md @@ -60,16 +60,18 @@ Note: when `CPPSORT_ENABLE_AUDITS` is `ON`, assertions in the library are enable **cpp-sort** is available directly on [Conan Center][conan-center]. You can find the different versions available with the following command: ```sh -conan search cpp-sort --remote=conan-center +conan search cpp-sort --remote=conancenter ``` And then install any version to your local cache as follows (here with version 1.15.0): ```sh -conan install cpp-sort/1.15.0 +conan install --requires=cpp-sort/1.15.0 ``` -The packages downloaded from conan-center are minimal and only contain the files required to use **cpp-sort** as a library: the headers, CMake files and licensing information. If you need anything else you have to build your own package with the `conanfile.py` available in this repository. +The packages downloaded from conan-center are minimal and only contain the files required to use **cpp-sort** as a library: the headers, CMake files and licensing information. If you need anything else you have to create your own package with the `conanfile.py` available in this repository. + +*Changed in version 1.15.0:* the recipes now only target conan 2.X. ## Gollum @@ -88,6 +90,6 @@ Due to slight markup differences, some pages might not fully render correctly bu [catch2]: https://github.com/catchorg/Catch2 [cmake]: https://cmake.org/ [conan]: https://conan.io/ - [conan-center]: https://conan.io/center/cpp-sort + [conan-center]: https://conan.io/center/recipes/cpp-sort [gollum]: https://github.com/gollum/gollum [libassert]: https://github.com/jeremy-rifkin/libassert diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 161b6eb7..f0c546bc 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -1,13 +1,10 @@ -# Copyright (c) 2018-2021 Morwenn +# Copyright (c) 2018-2023 Morwenn # SPDX-License-Identifier: MIT cmake_minimum_required(VERSION 2.8.11) project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - find_package(cpp-sort REQUIRED CONFIG) add_executable(${PROJECT_NAME} cpp-sort-integrity.cpp) diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 932df7bb..30aa65dd 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -1,24 +1,32 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (c) 2018-2021 Morwenn +# Copyright (c) 2018-2023 Morwenn # SPDX-License-Identifier: MIT import os.path -from conans import CMake, ConanFile, tools +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run class CppsortTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain" + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) cmake.configure() cmake.build() + def layout(self): + cmake_layout(self) + 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): + cmd = os.path.join(self.cpp.build.bindir, "test_package") + self.run(cmd, env="conanrun")