From e8ff226812156603d481654422b0b2ff297cb83e Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Sat, 25 Feb 2023 16:25:24 +0100 Subject: [PATCH 01/14] compatability of cubic_interpolation with Conan 2.0 --- recipes/cubicinterpolation/all/conanfile.py | 60 +++++++++---------- .../all/test_package/CMakeLists.txt | 5 +- .../all/test_package/conanfile.py | 19 ++++-- .../all/test_v1_package/CMakeLists.txt | 11 ++++ .../all/test_v1_package/conanfile.py | 17 ++++++ .../all/test_v1_package/test_package.cpp | 22 +++++++ 6 files changed, 92 insertions(+), 42 deletions(-) create mode 100644 recipes/cubicinterpolation/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/cubicinterpolation/all/test_v1_package/conanfile.py create mode 100644 recipes/cubicinterpolation/all/test_v1_package/test_package.cpp diff --git a/recipes/cubicinterpolation/all/conanfile.py b/recipes/cubicinterpolation/all/conanfile.py index 5ab5b03d47a69..cd4fec5c8e6fe 100644 --- a/recipes/cubicinterpolation/all/conanfile.py +++ b/recipes/cubicinterpolation/all/conanfile.py @@ -1,5 +1,8 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile, tools +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.files import get, copy, rmdir +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain import os required_conan_version = ">=1.43.0" @@ -23,7 +26,6 @@ class CubicInterpolationConan(ConanFile): "fPIC": True, } - generators = "cmake", "cmake_find_package" _cmake = None @property @@ -61,53 +63,45 @@ def _required_boost_components(self): return ["filesystem", "math", "serialization"] def validate(self): - miss_boost_required_comp = any(getattr(self.options["boost"], "without_{}".format(boost_comp), True) for boost_comp in self._required_boost_components) - if self.options["boost"].header_only or miss_boost_required_comp: - raise ConanInvalidConfiguration("{0} requires non header-only boost with these components: {1}".format(self.name, ", ".join(self._required_boost_components))) - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, "14") - - minimum_version = self._minimum_compilers_version.get( - str(self.settings.compiler), False - ) - if not minimum_version: - self.output.warn( - "CubicInterpolation requires C++14. Your compiler is unknown. Assuming it supports C++14." - ) - elif tools.Version(self.settings.compiler.version) < minimum_version: + miss_boost_required_comp = any(getattr(self.dependencies["boost"].options, f"without_{boost_comp}", True) for boost_comp in self._required_boost_components) + if self.dependencies["boost"].options.header_only or miss_boost_required_comp: raise ConanInvalidConfiguration( - "CubicInterpolation requires C++14, which your compiler does not support." + f"{self.ref} requires non header-only boost with these components: " + f"{', '.join(self._required_boost_components)}", ) + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, "14") + if self._is_msvc and self.options.shared: raise ConanInvalidConfiguration("cubicinterpolation shared is not supported with Visual Studio") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_EXAMPLE"] = False - self._cmake.definitions["BUILD_DOCUMENTATION"] = False - self._cmake.configure() - return self._cmake + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_EXAMPLE"] = False + tc.variables["BUILD_DOCUMENTATION"] = False + tc.generate() + + deps = CMakeDeps(self) + deps.generate() def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - cmake = self._configure_cmake() + 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")) def package_info(self): self.cpp_info.set_property("cmake_file_name", "CubicInterpolation") diff --git a/recipes/cubicinterpolation/all/test_package/CMakeLists.txt b/recipes/cubicinterpolation/all/test_package/CMakeLists.txt index f0da4436b7927..b98fa443a5368 100644 --- a/recipes/cubicinterpolation/all/test_package/CMakeLists.txt +++ b/recipes/cubicinterpolation/all/test_package/CMakeLists.txt @@ -1,8 +1,5 @@ cmake_minimum_required(VERSION 3.1) -project(test_package CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +project(test_package LANGUAGES CXX) find_package(CubicInterpolation REQUIRED CONFIG) diff --git a/recipes/cubicinterpolation/all/test_package/conanfile.py b/recipes/cubicinterpolation/all/test_package/conanfile.py index 38f4483872d47..5357702ccd250 100644 --- a/recipes/cubicinterpolation/all/test_package/conanfile.py +++ b/recipes/cubicinterpolation/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") \ No newline at end of file diff --git a/recipes/cubicinterpolation/all/test_v1_package/CMakeLists.txt b/recipes/cubicinterpolation/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..f0da4436b7927 --- /dev/null +++ b/recipes/cubicinterpolation/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(CubicInterpolation REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} CubicInterpolation::CubicInterpolation) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) diff --git a/recipes/cubicinterpolation/all/test_v1_package/conanfile.py b/recipes/cubicinterpolation/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cubicinterpolation/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/cubicinterpolation/all/test_v1_package/test_package.cpp b/recipes/cubicinterpolation/all/test_v1_package/test_package.cpp new file mode 100644 index 0000000000000..ab848742d9391 --- /dev/null +++ b/recipes/cubicinterpolation/all/test_v1_package/test_package.cpp @@ -0,0 +1,22 @@ +#include "CubicInterpolation/Axis.h" +#include "CubicInterpolation/CubicSplines.h" +#include "CubicInterpolation/Interpolant.h" + +double func(double x) { return x * x + x; } + +int main(int argc, char* argv[]) +{ + + auto def = cubic_splines::CubicSplines::Definition(); + def.f = func; + def.axis = std::make_unique>( + -2.f, 2.f, (size_t)10); + + auto inter + = cubic_splines::Interpolant>( + std::move(def), "", ""); + + auto res = inter.evaluate(1.2345f); + + return 0; +} From bb074edf473f416e2f4a5a101dd11befa91e2cc3 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Tue, 7 Mar 2023 10:33:39 +0100 Subject: [PATCH 02/14] missing newline --- recipes/cubicinterpolation/all/test_package/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cubicinterpolation/all/test_package/conanfile.py b/recipes/cubicinterpolation/all/test_package/conanfile.py index 5357702ccd250..0a6bc68712d90 100644 --- a/recipes/cubicinterpolation/all/test_package/conanfile.py +++ b/recipes/cubicinterpolation/all/test_package/conanfile.py @@ -23,4 +23,4 @@ def build(self): 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") \ No newline at end of file + self.run(bin_path, env="conanrun") From cdb23df910e9880a871cf58de74506b539fceb34 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Tue, 7 Mar 2023 10:38:18 +0100 Subject: [PATCH 03/14] use patch from new resource --- recipes/cubicinterpolation/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/cubicinterpolation/all/conanfile.py b/recipes/cubicinterpolation/all/conanfile.py index cd4fec5c8e6fe..40f9c7aca7cae 100644 --- a/recipes/cubicinterpolation/all/conanfile.py +++ b/recipes/cubicinterpolation/all/conanfile.py @@ -1,7 +1,7 @@ -from conan import ConanFile, tools +from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd -from conan.tools.files import get, copy, rmdir +from conan.tools.files import get, copy, rmdir, patch from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain import os @@ -91,7 +91,7 @@ def generate(self): def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + patch(**patch) cmake = CMake(self) cmake.configure() From 1186db11200699e1ca4538ffe20ce7450cb2ab9d Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Tue, 7 Mar 2023 12:46:20 +0100 Subject: [PATCH 04/14] invalid use of patch --- recipes/cubicinterpolation/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/cubicinterpolation/all/conanfile.py b/recipes/cubicinterpolation/all/conanfile.py index 40f9c7aca7cae..667e4385a09bc 100644 --- a/recipes/cubicinterpolation/all/conanfile.py +++ b/recipes/cubicinterpolation/all/conanfile.py @@ -90,8 +90,8 @@ def generate(self): deps.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - patch(**patch) + for p in self.conan_data.get("patches", {}).get(self.version, []): + patch(**p) cmake = CMake(self) cmake.configure() From 3d6b63dcbbc9df822f952c50a9ddc068bfb02f1f Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Tue, 7 Mar 2023 15:06:11 +0100 Subject: [PATCH 05/14] adapt structure for patch --- recipes/cubicinterpolation/all/conandata.yml | 4 ++-- recipes/cubicinterpolation/all/conanfile.py | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/recipes/cubicinterpolation/all/conandata.yml b/recipes/cubicinterpolation/all/conandata.yml index 21963599ee1f4..254d60b99c48b 100644 --- a/recipes/cubicinterpolation/all/conandata.yml +++ b/recipes/cubicinterpolation/all/conandata.yml @@ -11,7 +11,7 @@ sources: patches: "0.1.4": - patch_file: "patches/patch_conanbuildinfo.txt" - base_path: "source_subfolder" + patch_type: "conan" "0.1.3": - patch_file: "patches/patch_conanbuildinfo.txt" - base_path: "source_subfolder" + patch_type: "conan" diff --git a/recipes/cubicinterpolation/all/conanfile.py b/recipes/cubicinterpolation/all/conanfile.py index 667e4385a09bc..96763ad3757b0 100644 --- a/recipes/cubicinterpolation/all/conanfile.py +++ b/recipes/cubicinterpolation/all/conanfile.py @@ -1,8 +1,8 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd -from conan.tools.files import get, copy, rmdir, patch -from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain +from conan.tools.files import get, copy, rmdir, patch, apply_conandata_patches, export_conandata_patches +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout import os required_conan_version = ">=1.43.0" @@ -15,7 +15,6 @@ class CubicInterpolationConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" description = "Leightweight interpolation library based on boost and eigen." topics = ("interpolation", "splines", "cubic", "bicubic", "boost", "eigen3") - exports_sources = ["CMakeLists.txt", "patches/**"] settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -28,14 +27,14 @@ class CubicInterpolationConan(ConanFile): _cmake = None - @property - def _source_subfolder(self): - return "source_subfolder" - @property def _is_msvc(self): return str(self.settings.compiler) in ["Visual Studio", "msvc"] + def export_sources(self): + #self.copy("CMakeLists.txt") + export_conandata_patches(self) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -44,6 +43,9 @@ def configure(self): if self.options.shared: del self.options.fPIC + def layout(self): + cmake_layout(self, src_folder="src") + def requirements(self): # TODO: update boost dependency as soon as issue #11207 is fixed self.requires("boost/1.75.0") @@ -90,8 +92,7 @@ def generate(self): deps.generate() def build(self): - for p in self.conan_data.get("patches", {}).get(self.version, []): - patch(**p) + apply_conandata_patches(self) cmake = CMake(self) cmake.configure() From 5fdb7ad47f277188da1557c45747cf9160fd3cf1 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Fri, 24 Mar 2023 15:26:21 +0100 Subject: [PATCH 06/14] add patch for older version of package --- recipes/cubicinterpolation/all/conandata.yml | 4 ++++ .../all/patches/patch_conan_basic_setup.txt | 15 +++++++++++++++ .../all/patches/patch_conanbuildinfo.txt | 17 +++++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 recipes/cubicinterpolation/all/patches/patch_conan_basic_setup.txt diff --git a/recipes/cubicinterpolation/all/conandata.yml b/recipes/cubicinterpolation/all/conandata.yml index 254d60b99c48b..44db45fa98223 100644 --- a/recipes/cubicinterpolation/all/conandata.yml +++ b/recipes/cubicinterpolation/all/conandata.yml @@ -12,6 +12,10 @@ patches: "0.1.4": - patch_file: "patches/patch_conanbuildinfo.txt" patch_type: "conan" + - patch_file: "patches/patch_conan_basic_setup.txt" + patch_type: "conan" "0.1.3": - patch_file: "patches/patch_conanbuildinfo.txt" patch_type: "conan" + - patch_file: "patches/patch_conan_basic_setup.txt" + patch_type: "conan" diff --git a/recipes/cubicinterpolation/all/patches/patch_conan_basic_setup.txt b/recipes/cubicinterpolation/all/patches/patch_conan_basic_setup.txt new file mode 100644 index 0000000000000..6bc1808f2d777 --- /dev/null +++ b/recipes/cubicinterpolation/all/patches/patch_conan_basic_setup.txt @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index db6eb04..b319d33 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -9,8 +9,8 @@ set(CubicInterpolation_VERSION ${CubicInterpolation_VERSION_MAJOR}.${CubicInterp + + set(CMAKE_CXX_STANDARD 14) + +-include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +-conan_basic_setup(TARGETS) ++find_package(Eigen3 REQUIRED) ++find_package(Boost COMPONENTS filesystem serialization REQUIRED) + + add_subdirectory(src) + diff --git a/recipes/cubicinterpolation/all/patches/patch_conanbuildinfo.txt b/recipes/cubicinterpolation/all/patches/patch_conanbuildinfo.txt index 614a14be9b7ed..a97479b5d1290 100644 --- a/recipes/cubicinterpolation/all/patches/patch_conanbuildinfo.txt +++ b/recipes/cubicinterpolation/all/patches/patch_conanbuildinfo.txt @@ -1,8 +1,21 @@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 0199a76..1b0a2b4 100644 +index 0199a76..b7cd42c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt -@@ -46,6 +46,3 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in +@@ -11,8 +11,10 @@ add_subdirectory(CubicInterpolation) + add_subdirectory(detail) + + target_link_libraries(CubicInterpolation +- CONAN_PKG::eigen +- CONAN_PKG::boost ++ Eigen3::Eigen ++ Boost::boost ++ Boost::filesystem ++ Boost::serialization + ) + + target_include_directories(CubicInterpolation PUBLIC +@@ -46,6 +48,3 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CubicInterpolationConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CubicInterpolation ) From ee8e04190054483cd6081379bb8bde4ac0c81984 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Mon, 27 Mar 2023 14:38:25 +0200 Subject: [PATCH 07/14] safe delete of fPIC --- recipes/cubicinterpolation/all/conanfile.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/recipes/cubicinterpolation/all/conanfile.py b/recipes/cubicinterpolation/all/conanfile.py index 96763ad3757b0..e32f4461d5695 100644 --- a/recipes/cubicinterpolation/all/conanfile.py +++ b/recipes/cubicinterpolation/all/conanfile.py @@ -37,11 +37,17 @@ def export_sources(self): def config_options(self): if self.settings.os == "Windows": - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass def configure(self): if self.options.shared: - del self.options.fPIC + try: + del self.options.fPIC + except Exception: + pass def layout(self): cmake_layout(self, src_folder="src") From 7cc494853ee0a42a8cd21529b0fe72093d54ecca Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Mon, 27 Mar 2023 16:53:36 +0200 Subject: [PATCH 08/14] disable VS<16 --- recipes/cubicinterpolation/all/conanfile.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/recipes/cubicinterpolation/all/conanfile.py b/recipes/cubicinterpolation/all/conanfile.py index e32f4461d5695..405828758e98c 100644 --- a/recipes/cubicinterpolation/all/conanfile.py +++ b/recipes/cubicinterpolation/all/conanfile.py @@ -57,15 +57,6 @@ def requirements(self): self.requires("boost/1.75.0") self.requires("eigen/3.3.9") - @property - def _minimum_compilers_version(self): - return { - "Visual Studio": "16", - "gcc": "5", - "clang": "5", - "apple-clang": "5.1", - } - @property def _required_boost_components(self): return ["filesystem", "math", "serialization"] @@ -82,6 +73,9 @@ def validate(self): if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, "14") + if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < "16": + raise ConanInvalidConfiguration("Visual Studio < 2019 not yet supported in this recipe") + if self._is_msvc and self.options.shared: raise ConanInvalidConfiguration("cubicinterpolation shared is not supported with Visual Studio") From a6f7b407c23b54150543b6752da08139c7d203aa Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Mon, 27 Mar 2023 17:02:22 +0200 Subject: [PATCH 09/14] fix VS check --- recipes/cubicinterpolation/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/cubicinterpolation/all/conanfile.py b/recipes/cubicinterpolation/all/conanfile.py index 405828758e98c..8511230752b72 100644 --- a/recipes/cubicinterpolation/all/conanfile.py +++ b/recipes/cubicinterpolation/all/conanfile.py @@ -3,6 +3,7 @@ from conan.tools.build import check_min_cppstd from conan.tools.files import get, copy, rmdir, patch, apply_conandata_patches, export_conandata_patches from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.scm import Version import os required_conan_version = ">=1.43.0" @@ -73,7 +74,7 @@ def validate(self): if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, "14") - if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < "16": + if str(self.settings.compiler) == "Visual Studio" and Version(self.settings.compiler.version) < "16": raise ConanInvalidConfiguration("Visual Studio < 2019 not yet supported in this recipe") if self._is_msvc and self.options.shared: From ede44c0e10d1b432fa3c3228e7b9c188f7c705d2 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Tue, 4 Apr 2023 15:29:57 +0200 Subject: [PATCH 10/14] add suggestions by @prince-chrismc --- recipes/cubicinterpolation/all/conanfile.py | 25 ++++++------------- .../all/test_v1_package/CMakeLists.txt | 7 ++---- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/recipes/cubicinterpolation/all/conanfile.py b/recipes/cubicinterpolation/all/conanfile.py index 8511230752b72..f82da27649845 100644 --- a/recipes/cubicinterpolation/all/conanfile.py +++ b/recipes/cubicinterpolation/all/conanfile.py @@ -4,9 +4,10 @@ from conan.tools.files import get, copy, rmdir, patch, apply_conandata_patches, export_conandata_patches from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.scm import Version +from conan.tools.microsoft import is_msvc, check_min_vs import os -required_conan_version = ">=1.43.0" +required_conan_version = ">=1.53.0" class CubicInterpolationConan(ConanFile): @@ -16,6 +17,7 @@ class CubicInterpolationConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" description = "Leightweight interpolation library based on boost and eigen." topics = ("interpolation", "splines", "cubic", "bicubic", "boost", "eigen3") + package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -28,27 +30,16 @@ class CubicInterpolationConan(ConanFile): _cmake = None - @property - def _is_msvc(self): - return str(self.settings.compiler) in ["Visual Studio", "msvc"] - def export_sources(self): - #self.copy("CMakeLists.txt") export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": - try: - del self.options.fPIC - except Exception: - pass + self.options.rm_safe("fPIC") def configure(self): if self.options.shared: - try: - del self.options.fPIC - except Exception: - pass + self.options.rm_safe("fPIC") def layout(self): cmake_layout(self, src_folder="src") @@ -74,10 +65,10 @@ def validate(self): if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, "14") - if str(self.settings.compiler) == "Visual Studio" and Version(self.settings.compiler.version) < "16": - raise ConanInvalidConfiguration("Visual Studio < 2019 not yet supported in this recipe") + if not check_min_vs(self, 192, raise_invalid=False): + raise ConanInvalidConfiguration(f"{self.ref} currently Visual Studio < 2019 not yet supported in this recipe. Contributions are welcome") - if self._is_msvc and self.options.shared: + if is_msvc(self) and self.options.shared: raise ConanInvalidConfiguration("cubicinterpolation shared is not supported with Visual Studio") def source(self): diff --git a/recipes/cubicinterpolation/all/test_v1_package/CMakeLists.txt b/recipes/cubicinterpolation/all/test_v1_package/CMakeLists.txt index f0da4436b7927..7ea0378c83fe1 100644 --- a/recipes/cubicinterpolation/all/test_v1_package/CMakeLists.txt +++ b/recipes/cubicinterpolation/all/test_v1_package/CMakeLists.txt @@ -4,8 +4,5 @@ project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) -find_package(CubicInterpolation REQUIRED CONFIG) - -add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} CubicInterpolation::CubicInterpolation) -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) From 51f4f56273b6de1770b339aab1dfb67617704cbd Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Tue, 4 Apr 2023 15:30:13 +0200 Subject: [PATCH 11/14] update organization name --- recipes/cubicinterpolation/all/conandata.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/cubicinterpolation/all/conandata.yml b/recipes/cubicinterpolation/all/conandata.yml index 44db45fa98223..f3cd9388847cf 100644 --- a/recipes/cubicinterpolation/all/conandata.yml +++ b/recipes/cubicinterpolation/all/conandata.yml @@ -1,12 +1,12 @@ sources: "0.1.5": - url: "https://github.com/MaxSac/cubic_interpolation/archive/v0.1.5.tar.gz" + url: "https://github.com/tudo-astroparticlephysics/cubic_interpolation/archive/v0.1.5.tar.gz" sha256: "fc34de15c9dd9e651728c9e0eee5528ee9636e41a3d8aa6f41735018810afd59" "0.1.4": - url: "https://github.com/MaxSac/cubic_interpolation/archive/v0.1.4.tar.gz" + url: "https://github.com/tudo-astroparticlephysics/cubic_interpolation/archive/v0.1.4.tar.gz" sha256: "38bb8fe46b19b135bfcba79e098c5d90284f0bc02f42f86118aefcb63aed7668" "0.1.3": - url: "https://github.com/MaxSac/cubic_interpolation/archive/v0.1.3.tar.gz" + url: "https://github.com/tudo-astroparticlephysics/cubic_interpolation/archive/v0.1.3.tar.gz" sha256: "3151d99ecbbddd4e57605ff1919bdf234d08336b47d369b9dc562acff780aaf7" patches: "0.1.4": From 5bcdbca50290bbe6494789d4bfabd795dde1cff1 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Tue, 4 Apr 2023 15:42:58 +0200 Subject: [PATCH 12/14] clarify TODO in comment --- recipes/cubicinterpolation/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cubicinterpolation/all/conanfile.py b/recipes/cubicinterpolation/all/conanfile.py index f82da27649845..5bbc29f8723b1 100644 --- a/recipes/cubicinterpolation/all/conanfile.py +++ b/recipes/cubicinterpolation/all/conanfile.py @@ -45,7 +45,7 @@ def layout(self): cmake_layout(self, src_folder="src") def requirements(self): - # TODO: update boost dependency as soon as issue #11207 is fixed + # TODO: update boost dependency as soon as we deprecate conan1.x (see discussion in #11207) self.requires("boost/1.75.0") self.requires("eigen/3.3.9") From fda45b286ce0a808f279ebdaefbc3ed10cbd8ef1 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 5 Apr 2023 09:52:21 +0200 Subject: [PATCH 13/14] rename patch files and remove duplicate cpp file --- recipes/cubicinterpolation/all/conandata.yml | 8 +++---- ...uildinfo.txt => patch_conanbuildinfo.diff} | 0 ...ic_setup.txt => rm_conan_basic_setup.diff} | 0 .../all/test_v1_package/test_package.cpp | 22 ------------------- 4 files changed, 4 insertions(+), 26 deletions(-) rename recipes/cubicinterpolation/all/patches/{patch_conanbuildinfo.txt => patch_conanbuildinfo.diff} (100%) rename recipes/cubicinterpolation/all/patches/{patch_conan_basic_setup.txt => rm_conan_basic_setup.diff} (100%) delete mode 100644 recipes/cubicinterpolation/all/test_v1_package/test_package.cpp diff --git a/recipes/cubicinterpolation/all/conandata.yml b/recipes/cubicinterpolation/all/conandata.yml index f3cd9388847cf..7a7f4164cb542 100644 --- a/recipes/cubicinterpolation/all/conandata.yml +++ b/recipes/cubicinterpolation/all/conandata.yml @@ -10,12 +10,12 @@ sources: sha256: "3151d99ecbbddd4e57605ff1919bdf234d08336b47d369b9dc562acff780aaf7" patches: "0.1.4": - - patch_file: "patches/patch_conanbuildinfo.txt" + - patch_file: "patches/patch_conanbuildinfo.diff" patch_type: "conan" - - patch_file: "patches/patch_conan_basic_setup.txt" + - patch_file: "patches/rm_conan_basic_setup.diff" patch_type: "conan" "0.1.3": - - patch_file: "patches/patch_conanbuildinfo.txt" + - patch_file: "patches/patch_conanbuildinfo.diff" patch_type: "conan" - - patch_file: "patches/patch_conan_basic_setup.txt" + - patch_file: "patches/rm_conan_basic_setup.diff" patch_type: "conan" diff --git a/recipes/cubicinterpolation/all/patches/patch_conanbuildinfo.txt b/recipes/cubicinterpolation/all/patches/patch_conanbuildinfo.diff similarity index 100% rename from recipes/cubicinterpolation/all/patches/patch_conanbuildinfo.txt rename to recipes/cubicinterpolation/all/patches/patch_conanbuildinfo.diff diff --git a/recipes/cubicinterpolation/all/patches/patch_conan_basic_setup.txt b/recipes/cubicinterpolation/all/patches/rm_conan_basic_setup.diff similarity index 100% rename from recipes/cubicinterpolation/all/patches/patch_conan_basic_setup.txt rename to recipes/cubicinterpolation/all/patches/rm_conan_basic_setup.diff diff --git a/recipes/cubicinterpolation/all/test_v1_package/test_package.cpp b/recipes/cubicinterpolation/all/test_v1_package/test_package.cpp deleted file mode 100644 index ab848742d9391..0000000000000 --- a/recipes/cubicinterpolation/all/test_v1_package/test_package.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "CubicInterpolation/Axis.h" -#include "CubicInterpolation/CubicSplines.h" -#include "CubicInterpolation/Interpolant.h" - -double func(double x) { return x * x + x; } - -int main(int argc, char* argv[]) -{ - - auto def = cubic_splines::CubicSplines::Definition(); - def.f = func; - def.axis = std::make_unique>( - -2.f, 2.f, (size_t)10); - - auto inter - = cubic_splines::Interpolant>( - std::move(def), "", ""); - - auto res = inter.evaluate(1.2345f); - - return 0; -} From a548b73486e0a0307f06fbdc660c238f06f475c7 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Thu, 6 Apr 2023 20:29:19 -0700 Subject: [PATCH 14/14] Apply suggestions from code review --- recipes/cubicinterpolation/all/conanfile.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/recipes/cubicinterpolation/all/conanfile.py b/recipes/cubicinterpolation/all/conanfile.py index 5bbc29f8723b1..722cbaa5424a1 100644 --- a/recipes/cubicinterpolation/all/conanfile.py +++ b/recipes/cubicinterpolation/all/conanfile.py @@ -1,13 +1,12 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd -from conan.tools.files import get, copy, rmdir, patch, apply_conandata_patches, export_conandata_patches +from conan.tools.files import get, copy, rmdir, apply_conandata_patches, export_conandata_patches from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.scm import Version from conan.tools.microsoft import is_msvc, check_min_vs import os -required_conan_version = ">=1.53.0" +required_conan_version = ">=1.57.0" class CubicInterpolationConan(ConanFile): @@ -69,7 +68,7 @@ def validate(self): raise ConanInvalidConfiguration(f"{self.ref} currently Visual Studio < 2019 not yet supported in this recipe. Contributions are welcome") if is_msvc(self) and self.options.shared: - raise ConanInvalidConfiguration("cubicinterpolation shared is not supported with Visual Studio") + raise ConanInvalidConfiguration(f"{self.ref} shared is not supported with Visual Studio") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True)