From ef2ae81ddf20c44e5d4ac50d8082cfca87ace342 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 3 Jul 2024 17:02:15 +0300 Subject: [PATCH] (#18820) pagmo2: migrate to Conan v2 * pagmo2: migrate to Conan v2 * pagmo2: require boost::boost as a fix for MSVC linker issues * pagmo2: tweak compiler validation * pagmo2: add v2.19.0, disable MSVC shared build * pagmo2: MSVC shared builds are broken * pagmo2: bump boost and onetbb versions --- recipes/pagmo2/all/CMakeLists.txt | 7 - recipes/pagmo2/all/conandata.yml | 3 + recipes/pagmo2/all/conanfile.py | 160 ++++++++++-------- .../pagmo2/all/test_package/CMakeLists.txt | 9 +- recipes/pagmo2/all/test_package/conanfile.py | 19 ++- .../pagmo2/all/test_v1_package/CMakeLists.txt | 8 + .../pagmo2/all/test_v1_package/conanfile.py | 17 ++ recipes/pagmo2/config.yml | 2 + recipes/pagmo2/pre_2.11/CMakeLists.txt | 7 - recipes/pagmo2/pre_2.11/conandata.yml | 1 - recipes/pagmo2/pre_2.11/conanfile.py | 112 ++++++------ .../pre_2.11/test_package/CMakeLists.txt | 7 +- .../pagmo2/pre_2.11/test_package/conanfile.py | 19 ++- .../pre_2.11/test_v1_package/CMakeLists.txt | 8 + .../pre_2.11/test_v1_package/conanfile.py | 17 ++ 15 files changed, 235 insertions(+), 161 deletions(-) delete mode 100644 recipes/pagmo2/all/CMakeLists.txt create mode 100644 recipes/pagmo2/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/pagmo2/all/test_v1_package/conanfile.py delete mode 100644 recipes/pagmo2/pre_2.11/CMakeLists.txt create mode 100644 recipes/pagmo2/pre_2.11/test_v1_package/CMakeLists.txt create mode 100644 recipes/pagmo2/pre_2.11/test_v1_package/conanfile.py diff --git a/recipes/pagmo2/all/CMakeLists.txt b/recipes/pagmo2/all/CMakeLists.txt deleted file mode 100644 index b71c882d9d33f..0000000000000 --- a/recipes/pagmo2/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/pagmo2/all/conandata.yml b/recipes/pagmo2/all/conandata.yml index a610a9ffc5a7b..26d2bd85a3ccc 100644 --- a/recipes/pagmo2/all/conandata.yml +++ b/recipes/pagmo2/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "2.19.0": + url: "https://github.com/esa/pagmo2/archive/refs/tags/v2.19.0.tar.gz" + sha256: "701ada528de7d454201e92a5d88903dd1c22ea64f43861d9694195ddfef82a70" "2.17.0": url: "https://github.com/esa/pagmo2/archive/refs/tags/v2.17.0.tar.gz" sha256: "1b95b036f75e6fa0b21082ab228dbd63cd18ca10d9622ac53629245e0f95c35c" diff --git a/recipes/pagmo2/all/conanfile.py b/recipes/pagmo2/all/conanfile.py index 08b268962bb1c..b0c859b99c54f 100644 --- a/recipes/pagmo2/all/conanfile.py +++ b/recipes/pagmo2/all/conanfile.py @@ -1,19 +1,25 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration -import functools import os -required_conan_version = ">=1.43.0" +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 copy, get, replace_in_file, rmdir +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version + +required_conan_version = ">=1.53.0" class Pagmo2Conan(ConanFile): name = "pagmo2" description = "pagmo is a C++ scientific library for massively parallel optimization." license = ("LGPL-3.0-or-later", "GPL-3.0-or-later") - topics = ("pagmo", "optimization", "parallel-computing", "genetic-algorithm", "metaheuristics") - homepage = "https://esa.github.io/pagmo2" url = "https://github.com/conan-io/conan-center-index" + homepage = "https://esa.github.io/pagmo2" + topics = ("pagmo", "optimization", "parallel-computing", "genetic-algorithm", "metaheuristics") + package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -30,12 +36,15 @@ class Pagmo2Conan(ConanFile): "with_ipopt": False, } - exports_sources = "CMakeLists.txt" - generators = "cmake", "cmake_find_package", "cmake_find_package_multi" - @property - def _source_subfolder(self): - return "source_subfolder" + def _compilers_minimum_version(self): + return { + "Visual Studio": "15.7", + "msvc": "191", + "gcc": "7", + "clang": "5.0", + "apple-clang": "9", + } def config_options(self): if self.settings.os == "Windows": @@ -43,24 +52,18 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("boost/1.78.0") - self.requires("onetbb/2020.3") + self.requires("boost/1.85.0", transitive_headers=True) + self.requires("onetbb/2021.12.0") if self.options.with_eigen: - self.requires("eigen/3.4.0") + self.requires("eigen/3.4.0", transitive_headers=True) if self.options.with_nlopt: - self.requires("nlopt/2.7.1") - - @property - def _compilers_minimum_version(self): - return { - "Visual Studio": "15.7", - "gcc": "7", - "clang": "5.0", - "apple-clang": "9.1" - } + self.requires("nlopt/2.7.1", transitive_headers=True, transitive_libs=True) @property def _required_boost_components(self): @@ -68,86 +71,95 @@ def _required_boost_components(self): def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 17) - - def lazy_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] + check_min_cppstd(self, 17) minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if not minimum_version: - self.output.warn("{} {} requires C++17. Your compiler is unknown. Assuming it supports C++17.".format(self.name, self.version)) - elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version): - raise ConanInvalidConfiguration("{} {} requires C++17, which your compiler does not support.".format(self.name, self.version)) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.name} {self.version} requires C++17, which your compiler does not support." + ) # TODO: add ipopt support if self.options.with_ipopt: raise ConanInvalidConfiguration("ipopt recipe not available yet in CCI") - 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))) + miss_boost_required_comp = any( + self.dependencies["boost"].options.get_safe(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( + "{0} requires non header-only boost with these components: {1}".format( + self.name, ", ".join(self._required_boost_components) + ) + ) + + if is_msvc(self) and self.options.shared: + # test_package.obj : error LNK2019: unresolved external symbol "public: __cdecl boost::archive::codecvt_null::codecvt_null(unsigned __int64)" + # https://github.com/boostorg/serialization/issues/232 + # https://github.com/conda-forge/scipoptsuite-feedstock/pull/44 + raise ConanInvalidConfiguration("Shared builds are currently broken on MSVC") 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], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["PAGMO_BUILD_TESTS"] = False + tc.variables["PAGMO_BUILD_BENCHMARKS"] = False + tc.variables["PAGMO_BUILD_TUTORIALS"] = False + tc.variables["PAGMO_WITH_EIGEN3"] = self.options.with_eigen + tc.variables["PAGMO_WITH_NLOPT"] = self.options.with_nlopt + tc.variables["PAGMO_WITH_IPOPT"] = self.options.with_ipopt + tc.variables["PAGMO_ENABLE_IPO"] = False + tc.variables["PAGMO_BUILD_STATIC_LIBRARY"] = not self.options.shared + tc.generate() + tc = CMakeDeps(self) + tc.generate() def _patch_sources(self): # do not force MT runtime for static lib - tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), - "if(YACMA_COMPILER_IS_MSVC AND PAGMO_BUILD_STATIC_LIBRARY)", - "if(0)") + if Version(self.version) < "2.18": + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "if(YACMA_COMPILER_IS_MSVC AND PAGMO_BUILD_STATIC_LIBRARY)", "if(0)") # No warnings as errors - yacma_cmake = os.path.join(self._source_subfolder, "cmake_modules", "yacma", "YACMACompilerLinkerSettings.cmake") - tools.replace_in_file(yacma_cmake, "list(APPEND _YACMA_CXX_FLAGS_DEBUG \"-Werror\")", "") - tools.replace_in_file(yacma_cmake, "_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(/W4)", "") - tools.replace_in_file(yacma_cmake, "_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(/WX)", "") - - @functools.lru_cache(1) - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["PAGMO_BUILD_TESTS"] = False - cmake.definitions["PAGMO_BUILD_BENCHMARKS"] = False - cmake.definitions["PAGMO_BUILD_TUTORIALS"] = False - cmake.definitions["PAGMO_WITH_EIGEN3"] = self.options.with_eigen - cmake.definitions["PAGMO_WITH_NLOPT"] = self.options.with_nlopt - cmake.definitions["PAGMO_WITH_IPOPT"] = self.options.with_ipopt - cmake.definitions["PAGMO_ENABLE_IPO"] = False - cmake.definitions["PAGMO_BUILD_STATIC_LIBRARY"] = not self.options.shared - cmake.configure() - return cmake + yacma_cmake = os.path.join(self.source_folder, "cmake_modules", "yacma", "YACMACompilerLinkerSettings.cmake") + replace_in_file(self, yacma_cmake, 'list(APPEND _YACMA_CXX_FLAGS_DEBUG "-Werror")', "") + replace_in_file(self, yacma_cmake, "_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(/W4)", "") + replace_in_file(self, yacma_cmake, "_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(/WX)", "") def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="COPYING.*", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "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")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.set_property("cmake_file_name", "pagmo") + # https://esa.github.io/pagmo2/quickstart.html#using-pagmo-with-cmake + self.cpp_info.set_property("cmake_file_name", "Pagmo") self.cpp_info.set_property("cmake_target_name", "Pagmo::pagmo") - # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["_pagmo"].libs = ["pagmo"] - self.cpp_info.components["_pagmo"].requires = ["boost::headers", "boost::serialization", "onetbb::onetbb"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["_pagmo"].system_libs.append("pthread") + + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["_pagmo"].requires = ["boost::boost", "onetbb::onetbb"] if self.options.with_eigen: self.cpp_info.components["_pagmo"].requires.append("eigen::eigen") if self.options.with_nlopt: self.cpp_info.components["_pagmo"].requires.append("nlopt::nlopt") - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["_pagmo"].system_libs.append("pthread") - - # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.filenames["cmake_find_package"] = "pagmo" self.cpp_info.filenames["cmake_find_package_multi"] = "pagmo" self.cpp_info.names["cmake_find_package"] = "Pagmo" self.cpp_info.names["cmake_find_package_multi"] = "Pagmo" self.cpp_info.components["_pagmo"].names["cmake_find_package"] = "pagmo" self.cpp_info.components["_pagmo"].names["cmake_find_package_multi"] = "pagmo" - self.cpp_info.components["_pagmo"].set_property("cmake_target_name", "Pagmo::pagmo") diff --git a/recipes/pagmo2/all/test_package/CMakeLists.txt b/recipes/pagmo2/all/test_package/CMakeLists.txt index e512e2207b158..73aa85822f44b 100644 --- a/recipes/pagmo2/all/test_package/CMakeLists.txt +++ b/recipes/pagmo2/all/test_package/CMakeLists.txt @@ -1,10 +1,7 @@ -cmake_minimum_required(VERSION 3.8) -project(test_package) +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -find_package(pagmo REQUIRED CONFIG) +find_package(Pagmo REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} Pagmo::pagmo) diff --git a/recipes/pagmo2/all/test_package/conanfile.py b/recipes/pagmo2/all/test_package/conanfile.py index 38f4483872d47..ef5d7042163ec 100644 --- a/recipes/pagmo2/all/test_package/conanfile.py +++ b/recipes/pagmo2/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_layout, CMake import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -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.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/pagmo2/all/test_v1_package/CMakeLists.txt b/recipes/pagmo2/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..91630d79f4abb --- /dev/null +++ b/recipes/pagmo2/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/pagmo2/all/test_v1_package/conanfile.py b/recipes/pagmo2/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/pagmo2/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/pagmo2/config.yml b/recipes/pagmo2/config.yml index 0daf1d812658e..4d9124762cc74 100644 --- a/recipes/pagmo2/config.yml +++ b/recipes/pagmo2/config.yml @@ -1,4 +1,6 @@ versions: + "2.19.0": + folder: all "2.17.0": folder: all "2.10": diff --git a/recipes/pagmo2/pre_2.11/CMakeLists.txt b/recipes/pagmo2/pre_2.11/CMakeLists.txt deleted file mode 100644 index 361b35d4c17d9..0000000000000 --- a/recipes/pagmo2/pre_2.11/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/pagmo2/pre_2.11/conandata.yml b/recipes/pagmo2/pre_2.11/conandata.yml index fb48c3245b653..9bb70cc4e5a27 100644 --- a/recipes/pagmo2/pre_2.11/conandata.yml +++ b/recipes/pagmo2/pre_2.11/conandata.yml @@ -5,4 +5,3 @@ sources: patches: "2.10": - patch_file: "patches/0001-fix-cmake-module-path-2-10.patch" - base_path: "source_subfolder" diff --git a/recipes/pagmo2/pre_2.11/conanfile.py b/recipes/pagmo2/pre_2.11/conanfile.py index eeacc0b3752d5..485b29614940a 100644 --- a/recipes/pagmo2/pre_2.11/conanfile.py +++ b/recipes/pagmo2/pre_2.11/conanfile.py @@ -1,18 +1,23 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration import os -required_conan_version = ">=1.43.0" +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, export_conandata_patches, get, rmdir + +required_conan_version = ">=1.53.0" class Pagmo2Conan(ConanFile): name = "pagmo2" description = "pagmo is a C++ scientific library for massively parallel optimization." license = ("LGPL-3.0-or-later", "GPL-3.0-or-later") - topics = ("pagmo", "optimization", "parallel-computing", "genetic-algorithm", "metaheuristics") - homepage = "https://esa.github.io/pagmo2" url = "https://github.com/conan-io/conan-center-index" + homepage = "https://esa.github.io/pagmo2" + topics = ("pagmo", "optimization", "parallel-computing", "genetic-algorithm", "metaheuristics", "header-only") + package_type = "header-library" settings = "os", "arch", "compiler", "build_type" options = { "with_eigen": [True, False], @@ -25,25 +30,22 @@ class Pagmo2Conan(ConanFile): "with_ipopt": False, } - generators = "cmake", "cmake_find_package", "cmake_find_package_multi" - _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"]) + export_conandata_patches(self) + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("boost/1.78.0") - self.requires("onetbb/2020.3") + self.requires("boost/1.83.0", transitive_headers=True) + self.requires("onetbb/2021.10.0") if self.options.with_eigen: - self.requires("eigen/3.4.0") + self.requires("eigen/3.4.0", transitive_headers=True) if self.options.with_nlopt: - self.requires("nlopt/2.7.1") + self.requires("nlopt/2.7.1", transitive_headers=True, transitive_libs=True) + + def package_id(self): + self.info.settings.clear() @property def _required_boost_components(self): @@ -51,61 +53,69 @@ def _required_boost_components(self): def validate(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, 11) + check_min_cppstd(self, 11) # TODO: add ipopt support if self.options.with_ipopt: raise ConanInvalidConfiguration("ipopt recipe not available yet in CCI") - 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))) - - def package_id(self): - self.info.settings.clear() + miss_boost_required_comp = any( + self.dependencies["boost"].options.get_safe(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( + "{0} requires non header-only boost with these components: {1}".format( + self.name, ", ".join(self._required_boost_components) + ) + ) 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["PAGMO_BUILD_TESTS"] = False - self._cmake.definitions["PAGMO_BUILD_TUTORIALS"] = False - self._cmake.definitions["PAGMO_WITH_EIGEN3"] = self.options.with_eigen - self._cmake.definitions["PAGMO_WITH_NLOPT"] = self.options.with_nlopt - self._cmake.definitions["PAGMO_WITH_IPOPT"] = self.options.with_ipopt - 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["PAGMO_BUILD_TESTS"] = False + tc.variables["PAGMO_BUILD_TUTORIALS"] = False + tc.variables["PAGMO_WITH_EIGEN3"] = self.options.with_eigen + tc.variables["PAGMO_WITH_NLOPT"] = self.options.with_nlopt + tc.variables["PAGMO_WITH_IPOPT"] = self.options.with_ipopt + tc.generate() + tc = CMakeDeps(self) + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() def package(self): - self.copy(pattern="COPYING.*", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy( + self, + pattern="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")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): self.cpp_info.set_property("cmake_file_name", "pagmo") self.cpp_info.set_property("cmake_target_name", "Pagmo::pagmo") + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["_pagmo"].system_libs.append("pthread") + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed - self.cpp_info.components["_pagmo"].requires = ["boost::headers", "boost::serialization", "onetbb::onetbb"] + self.cpp_info.components["_pagmo"].requires = ["boost::boost", "onetbb::onetbb"] if self.options.with_eigen: self.cpp_info.components["_pagmo"].requires.append("eigen::eigen") if self.options.with_nlopt: self.cpp_info.components["_pagmo"].requires.append("nlopt::nlopt") - if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["_pagmo"].system_libs.append("pthread") - - # TODO: to remove in conan v2 once cmake_find_package_* generators removed self.cpp_info.filenames["cmake_find_package"] = "pagmo" self.cpp_info.filenames["cmake_find_package_multi"] = "pagmo" self.cpp_info.names["cmake_find_package"] = "Pagmo" self.cpp_info.names["cmake_find_package_multi"] = "Pagmo" self.cpp_info.components["_pagmo"].names["cmake_find_package"] = "pagmo" self.cpp_info.components["_pagmo"].names["cmake_find_package_multi"] = "pagmo" - self.cpp_info.components["_pagmo"].set_property("cmake_target_name", "Pagmo::pagmo") diff --git a/recipes/pagmo2/pre_2.11/test_package/CMakeLists.txt b/recipes/pagmo2/pre_2.11/test_package/CMakeLists.txt index 7439694a33876..de018735ec0b2 100644 --- a/recipes/pagmo2/pre_2.11/test_package/CMakeLists.txt +++ b/recipes/pagmo2/pre_2.11/test_package/CMakeLists.txt @@ -1,8 +1,5 @@ -cmake_minimum_required(VERSION 3.8) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) find_package(pagmo REQUIRED CONFIG) diff --git a/recipes/pagmo2/pre_2.11/test_package/conanfile.py b/recipes/pagmo2/pre_2.11/test_package/conanfile.py index 38f4483872d47..ef5d7042163ec 100644 --- a/recipes/pagmo2/pre_2.11/test_package/conanfile.py +++ b/recipes/pagmo2/pre_2.11/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_layout, CMake import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -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.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/pagmo2/pre_2.11/test_v1_package/CMakeLists.txt b/recipes/pagmo2/pre_2.11/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..91630d79f4abb --- /dev/null +++ b/recipes/pagmo2/pre_2.11/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/pagmo2/pre_2.11/test_v1_package/conanfile.py b/recipes/pagmo2/pre_2.11/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/pagmo2/pre_2.11/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)