From 80515f300071e21580cdefcc4331c3ee53e3ddd6 Mon Sep 17 00:00:00 2001 From: ericLemanissier Date: Thu, 30 May 2024 17:21:05 +0200 Subject: [PATCH 01/38] (#24165) remove ericLemanissier from the authorized_users and reviewers --- .c3i/authorized_users.yml | 1 - .c3i/reviewers.yml | 3 --- docs/community_resources.md | 7 ------- 3 files changed, 11 deletions(-) diff --git a/.c3i/authorized_users.yml b/.c3i/authorized_users.yml index b28163cd32993..7e3133f2e97a7 100644 --- a/.c3i/authorized_users.yml +++ b/.c3i/authorized_users.yml @@ -7,7 +7,6 @@ authorized_users: - Croydon - Johnnyxy - solvingj -- ericLemanissier - tru - sztomi - theodelrieu diff --git a/.c3i/reviewers.yml b/.c3i/reviewers.yml index 1baa71f59b325..53227574b6679 100644 --- a/.c3i/reviewers.yml +++ b/.c3i/reviewers.yml @@ -33,9 +33,6 @@ reviewers: - user: "theirix" type: "community" request_reviews: false - - user: "ericLemanissier" - type: "community" - request_reviews: false - user: "prince-chrismc" type: "community" request_reviews: false diff --git a/docs/community_resources.md b/docs/community_resources.md index 06aa0558a52f3..4600ca89ac451 100644 --- a/docs/community_resources.md +++ b/docs/community_resources.md @@ -19,19 +19,12 @@ If you are looking to stay up to date with the last Conan news, follow us on Twi - [Updatable Recipes](https://github.com/qchateau/conan-center-bot): Automatically scans available recipes and checked for new upstream releases and tests one configuration - The results can be found here: https://qchateau.github.io/conan-center-bot/#/updatable -- [Conflicting Pull Requests](https://github.com/ericLemanissier/conan-center-conflicting-prs): Checks all the open pull requests for those which edit the same -recipe files and posts a message. - - The results can be found here: https://ericlemanissier.github.io/conan-center-conflicting-prs/ - [Pending Review](https://github.com/prince-chrismc/conan-center-index-pending-review) - The results can be found here: https://prince-chrismc.github.io/conan-center-index-pending-review/ -- [Pull Request In Progress Status](https://ericlemanissier.github.io/conan-center-pr-status/in_progress_jobs) - [System Package Checks](https://github.com/bincrafters/system-packages-checks): Builds automatically all `system` versions of recipes merged on CCI and being pull requested on a selection of Linux distributions and FreeBSD - The results can be found here: https://bincrafters.github.io/system-packages-checks/ ## Tools -- [FreeBSD Testing](https://github.com/ericLemanissier/conan-center-index/tree/freebsd): Detects pull requests with `FreeBSD` in the description and runs a test for -one configuration on that platform - - The results can be found here: https://github.com/ericLemanissier/conan-center-index/actions?query=workflow%3ACI - [Bincrafters Conventions](https://github.com/bincrafters/bincrafters-conventions): Automatically updates Conan recipes to the latest conventions and rules From a29853aa3062e161899ef8b15196c2061138b4e2 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 30 May 2024 20:45:08 +0200 Subject: [PATCH 02/38] (#24163) [libprotobuf-mutator] Compatible with Conan 2.x * Protobug mutator compatible with Conan 2.x Signed-off-by: Uilian Ries * Add version 1.3 Signed-off-by: Uilian Ries * Enforce protobuf link Signed-off-by: Uilian Ries * update abseil usage Signed-off-by: Uilian Ries * consume all libs in tests Signed-off-by: Uilian Ries * define cxx language in cmakelists Signed-off-by: Uilian Ries * static-library on Windows Signed-off-by: Uilian Ries * Exclude examples from CMakeLists.txt The upstream uses EXCLUDE_FROM_ALL CMake feature to avoid building examples by default, however, CMake still parses the example cmake file and requires more external dependencies like expat. Signed-off-by: Uilian Ries * Do not build shared on Windows Signed-off-by: Uilian Ries --------- Signed-off-by: Uilian Ries --- .../libprotobuf-mutator/all/CMakeLists.txt | 16 +- recipes/libprotobuf-mutator/all/conandata.yml | 6 +- recipes/libprotobuf-mutator/all/conanfile.py | 159 ++++++++++++------ .../all/test_package/CMakeLists.txt | 21 +-- .../all/test_package/conanfile.py | 19 ++- .../all/test_package/msg.proto | 11 -- .../all/test_package/test_package.cpp | 24 +-- recipes/libprotobuf-mutator/config.yml | 2 +- 8 files changed, 138 insertions(+), 120 deletions(-) delete mode 100644 recipes/libprotobuf-mutator/all/test_package/msg.proto diff --git a/recipes/libprotobuf-mutator/all/CMakeLists.txt b/recipes/libprotobuf-mutator/all/CMakeLists.txt index 694038520f556..54f184da6c63a 100644 --- a/recipes/libprotobuf-mutator/all/CMakeLists.txt +++ b/recipes/libprotobuf-mutator/all/CMakeLists.txt @@ -1,13 +1,9 @@ -cmake_minimum_required(VERSION 2.8.11) -project(cmake_wrapper) +cmake_minimum_required(VERSION 3.15) +project(cmake_wrapper CXX) -include(conanbuildinfo.cmake) -conan_basic_setup() +find_package(Protobuf REQUIRED) +find_package(absl CONFIG REQUIRED) -add_subdirectory(source_subfolder) +add_subdirectory(src) -if(MSVC) - # Should be added because of - # https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-initonceexecuteonce - add_definitions(-D_WIN32_WINNT=0x0600) -endif() +target_link_libraries(protobuf-mutator PUBLIC protobuf::libprotobuf absl::strings) diff --git a/recipes/libprotobuf-mutator/all/conandata.yml b/recipes/libprotobuf-mutator/all/conandata.yml index 813688d3f74a5..1152bb8579584 100644 --- a/recipes/libprotobuf-mutator/all/conandata.yml +++ b/recipes/libprotobuf-mutator/all/conandata.yml @@ -1,4 +1,4 @@ sources: - "cci.20210831": - url: "https://github.com/google/libprotobuf-mutator/archive/ffd86a32874e5c08a143019aad1aaf0907294c9f.zip" - sha256: "14f595863452808483776ce1964209db00cdac79e649b31eb4d4b06ca72912d8" + "1.3": + url: "https://github.com/google/libprotobuf-mutator/archive/refs/tags/v1.3.tar.gz" + sha256: "1ee3473a6b0274494fce599539605bb19305c0efadc62b58d645812132c31baa" diff --git a/recipes/libprotobuf-mutator/all/conanfile.py b/recipes/libprotobuf-mutator/all/conanfile.py index f0419a2397845..b03de6dbf5696 100644 --- a/recipes/libprotobuf-mutator/all/conanfile.py +++ b/recipes/libprotobuf-mutator/all/conanfile.py @@ -1,8 +1,14 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, replace_in_file, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.env import VirtualBuildEnv +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.54.0" class LibProtobufMutatorConan(ConanFile): @@ -13,76 +19,117 @@ class LibProtobufMutatorConan(ConanFile): description = "A library to randomly mutate protobuffers." topics = ("test", "fuzzing", "protobuf") settings = "os", "compiler", "build_type", "arch" - generators = "cmake" - exports_sources = ["CMakeLists.txt"] - - _cmake = None + package_type = "library" + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } @property - def _source_subfolder(self): - return "source_subfolder" + def _min_cppstd(self): + return 14 @property - def _build_subfolder(self): - return "build_subfolder" + def _compilers_minimum_version(self): + return { + "apple-clang": "10", + "clang": "7", + "gcc": "5", + "msvc": "191", + "Visual Studio": "15", + } + + def export_sources(self): + copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.get_safe("shared"): + self.options.rm_safe("fPIC") + if is_msvc(self): + self.options.rm_safe("shared") + self.package_type = "static-library" + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): - self.requires("protobuf/3.17.1") - - def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + # Protobuf headers are required by public src/binary_format.h and + self.requires("protobuf/4.25.3", transitive_headers=True) + # Abseil headers are required by public src/field_instance.h + self.requires("abseil/20240116.2") def validate(self): - if self.settings.compiler != "clang": - raise ConanInvalidConfiguration("Only clang allowed") - if self.settings.compiler.libcxx != "libstdc++11": - raise ConanInvalidConfiguration("Requires either compiler.libcxx=libstdc++11") if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, 11) + 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.ref} requires C++{self._min_cppstd}, which your compiler does not support.") + + def build_requirements(self): + self.tool_requires("cmake/[>=3.24 <4]") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) def _patch_sources(self): - tools.replace_in_file( - os.path.join(self._source_subfolder, 'CMakeLists.txt'), - """include_directories(${PROTOBUF_INCLUDE_DIRS})""", - """include_directories(${protobuf_INCLUDE_DIRS})""") - tools.replace_in_file( - os.path.join(self._source_subfolder, 'CMakeLists.txt'), - """set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/external)""", - """# (disabled by conan) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/external)""") - tools.replace_in_file( - os.path.join(self._source_subfolder, 'CMakeLists.txt'), - """add_subdirectory(examples EXCLUDE_FROM_ALL)""", - """# (disabled by conan) add_subdirectory(examples EXCLUDE_FROM_ALL)""") - - def _configure_cmake(self): - if self._cmake: - return self._cmake - - self._cmake = CMake(self) - self._cmake.definitions["LIB_PROTO_MUTATOR_TESTING"] = "OFF" - self._cmake.definitions["LIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF"] = "OFF" - self._cmake.definitions["LIB_PROTO_MUTATOR_WITH_ASAN"] = "OFF" - self._cmake.definitions["LIB_PROTO_MUTATOR_FUZZER_LIBRARIES"] = "" - # todo: check option(LIB_PROTO_MUTATOR_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + # Preserves Conan as dependency manager + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/external)", + "", + ) + # Fix libprotobuf-mutator.pc installation origin path + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "${CMAKE_BINARY_DIR}/libprotobuf-mutator.pc", + "${CMAKE_CURRENT_BINARY_DIR}/libprotobuf-mutator.pc", + ) + # Do not include examples when running CMake configure to avoid more dependencies + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "add_subdirectory(examples EXCLUDE_FROM_ALL)", + "", + ) + + def generate(self): + tc = VirtualBuildEnv(self) + tc.generate() + tc = CMakeToolchain(self) + tc.variables["LIB_PROTO_MUTATOR_TESTING"] = False + tc.variables["LIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF"] = False + tc.variables["LIB_PROTO_MUTATOR_WITH_ASAN"] = False + tc.variables["PKG_CONFIG_PATH"] = "share" + if is_msvc(self): + tc.variables["LIB_PROTO_MUTATOR_MSVC_STATIC_RUNTIME"] = is_msvc_static_runtime(self) + tc.generate() + tc = CMakeDeps(self) + tc.generate() 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(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, pattern="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, "OFF")) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "libprotobuf-mutator" - self.cpp_info.names["cmake_find_package_multi"] = "libprotobuf-mutator" - - self.cpp_info.libs = ['protobuf-mutator-libfuzzer', 'protobuf-mutator'] - self.cpp_info.includedirs.append(os.path.join("include", "libprotobuf-mutator")) + self.cpp_info.components["mutator"].libs = ["protobuf-mutator"] + self.cpp_info.components["mutator"].set_property("cmake_target_name", "libprotobuf-mutator::protobuf-mutator") + self.cpp_info.components["mutator"].includedirs.append("include/libprotobuf-mutator") + self.cpp_info.components["mutator"].requires = ["protobuf::libprotobuf", "abseil::absl_strings"] + + self.cpp_info.components["fuzzer"].libs = ['protobuf-mutator-libfuzzer'] + self.cpp_info.components["fuzzer"].set_property("cmake_target_name", "libprotobuf-mutator::protobuf-mutator-libfuzzer") + self.cpp_info.components["fuzzer"].includedirs.append("include/libprotobuf-mutator") + self.cpp_info.components["fuzzer"].requires = ["mutator", "protobuf::libprotobuf"] diff --git a/recipes/libprotobuf-mutator/all/test_package/CMakeLists.txt b/recipes/libprotobuf-mutator/all/test_package/CMakeLists.txt index 00520b9489805..70a0e97ac972f 100644 --- a/recipes/libprotobuf-mutator/all/test_package/CMakeLists.txt +++ b/recipes/libprotobuf-mutator/all/test_package/CMakeLists.txt @@ -1,19 +1,8 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package CXX) +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) find_package(libprotobuf-mutator REQUIRED CONFIG) - -protobuf_generate_cpp( - MSG_PROTO_SRCS - MSG_PROTO_HDRS - msg.proto -) - - -add_executable(${PROJECT_NAME} ${MSG_PROTO_SRCS} test_package.cpp) -target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(${PROJECT_NAME} libprotobuf-mutator::libprotobuf-mutator) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libprotobuf-mutator::protobuf-mutator libprotobuf-mutator::protobuf-mutator-libfuzzer) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/libprotobuf-mutator/all/test_package/conanfile.py b/recipes/libprotobuf-mutator/all/test_package/conanfile.py index 38f4483872d47..ef5d7042163ec 100644 --- a/recipes/libprotobuf-mutator/all/test_package/conanfile.py +++ b/recipes/libprotobuf-mutator/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/libprotobuf-mutator/all/test_package/msg.proto b/recipes/libprotobuf-mutator/all/test_package/msg.proto deleted file mode 100644 index cb25c9d008352..0000000000000 --- a/recipes/libprotobuf-mutator/all/test_package/msg.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto2"; -package libfuzzer_example; - -import "google/protobuf/any.proto"; - -message Msg { - optional float optional_float = 1; - optional uint64 optional_uint64 = 2; - optional string optional_string = 3; - optional google.protobuf.Any any = 4; -} diff --git a/recipes/libprotobuf-mutator/all/test_package/test_package.cpp b/recipes/libprotobuf-mutator/all/test_package/test_package.cpp index c169f66031176..f7273ed21de60 100644 --- a/recipes/libprotobuf-mutator/all/test_package/test_package.cpp +++ b/recipes/libprotobuf-mutator/all/test_package/test_package.cpp @@ -1,23 +1,11 @@ -#include -#include +#include -#include "msg.pb.h" -#include +#include -DEFINE_PROTO_FUZZER(const libfuzzer_example::Msg& message) { - protobuf_mutator::protobuf::FileDescriptorProto file; - - // Emulate a bug. - if (message.optional_uint64() == std::hash{}(message.optional_string()) && - message.optional_string() == "abcdefghijklmnopqrstuvwxyz" && - !std::isnan(message.optional_float()) && - std::fabs(message.optional_float()) > 1000 && - message.any().UnpackTo(&file) && !file.name().empty()) - { - std::cerr << message.DebugString() << "\n"; - } -} int main() { - return 0; + protobuf_mutator::Mutator mutator{}; + const auto seed_value{42}; + mutator.Seed(seed_value); + return EXIT_SUCCESS; } diff --git a/recipes/libprotobuf-mutator/config.yml b/recipes/libprotobuf-mutator/config.yml index 9d5b0e4c50569..d2eb4ed4a511f 100644 --- a/recipes/libprotobuf-mutator/config.yml +++ b/recipes/libprotobuf-mutator/config.yml @@ -1,3 +1,3 @@ versions: - "cci.20210831": + "1.3": folder: all From 0198bb0e90fee20e57c154498778f3c674d74239 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 30 May 2024 14:53:09 -0500 Subject: [PATCH 03/38] (#24060) elfutils: Bump gettext to version 0.22.5 to support GCC 14 --- recipes/elfutils/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/elfutils/all/conanfile.py b/recipes/elfutils/all/conanfile.py index 759afadd553ee..df45185883fb0 100644 --- a/recipes/elfutils/all/conanfile.py +++ b/recipes/elfutils/all/conanfile.py @@ -82,7 +82,7 @@ def requirements(self): self.requires("libmicrohttpd/0.9.75") def build_requirements(self): - self.tool_requires("gettext/0.21") + self.tool_requires("gettext/0.22.5") self.tool_requires("automake/1.16.5") self.build_requires("m4/1.4.19") self.build_requires("flex/2.6.4") From ab5c6020d95c48c8bb2de36b7015685638e9a5c6 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 31 May 2024 11:01:49 +0200 Subject: [PATCH 04/38] (#24176) [sioclient] Build static libraries in Windows Signed-off-by: Uilian Ries --- recipes/sioclient/all/conanfile.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/recipes/sioclient/all/conanfile.py b/recipes/sioclient/all/conanfile.py index 4af93cba3d64c..28f6a1a4ad91a 100644 --- a/recipes/sioclient/all/conanfile.py +++ b/recipes/sioclient/all/conanfile.py @@ -5,6 +5,7 @@ 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.microsoft import is_msvc from conan.tools.files import copy, get, replace_in_file, rm, rmdir, save required_conan_version = ">=1.53.0" @@ -38,6 +39,9 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") + if is_msvc(self): + self.options.rm_safe("shared") + self.package_type = "static-library" def layout(self): cmake_layout(self, src_folder="src") @@ -52,8 +56,6 @@ def requirements(self): def validate(self): if self.settings.compiler.cppstd: check_min_cppstd(self, 11) - if self.settings.os == "Windows": - raise ConanInvalidConfiguration("Shared builds on Windows are not supported") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -61,17 +63,16 @@ def source(self): def generate(self): tc = CMakeToolchain(self) tc.variables["USE_SUBMODULES"] = False + tc.variables["BUILD_UNIT_TESTS"] = False + tc.variables["BUILD_TESTING"] = False tc.generate() deps = CMakeDeps(self) deps.generate() - VirtualBuildEnv(self).generate() - def _patch_sources(self): replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "asio asio::asio", "asio::asio") - save(self, os.path.join(self.source_folder, "test", "CMakeLists.txt"), "") def build(self): self._patch_sources() @@ -84,7 +85,6 @@ def package(self): cmake = CMake(self) cmake.install() rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) - rm(self, "*.pdb", self.package_folder, recursive=True) def package_info(self): self.cpp_info.set_property("cmake_file_name", "sioclient") From 79f3dda4229489db529367ccaef085d969fb4000 Mon Sep 17 00:00:00 2001 From: toge Date: Fri, 31 May 2024 18:32:29 +0900 Subject: [PATCH 05/38] (#24174) meson: add version 1.4.1 --- recipes/meson/all/conandata.yml | 3 +++ recipes/meson/config.yml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/recipes/meson/all/conandata.yml b/recipes/meson/all/conandata.yml index f567bf8d56087..57f4fedf15a32 100644 --- a/recipes/meson/all/conandata.yml +++ b/recipes/meson/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.4.1": + url: "https://github.com/mesonbuild/meson/archive/1.4.1.tar.gz" + sha256: "a7efc72ecb873c5a62031ade1921a7177b67cfdcb2e9410a7ab023f9e8192f4b" "1.4.0": url: "https://github.com/mesonbuild/meson/archive/1.4.0.tar.gz" sha256: "61382f295378bddcd9bebb3a9a9065b1cbc671fa41b80964ab02726f9a5f3a88" diff --git a/recipes/meson/config.yml b/recipes/meson/config.yml index 2b56413242adf..7d388efa3e5ae 100644 --- a/recipes/meson/config.yml +++ b/recipes/meson/config.yml @@ -1,4 +1,6 @@ versions: + "1.4.1": + folder: all "1.4.0": folder: all "1.3.2": From 91724e6415bb32799d1a3338e5e2a7b04aefcfbc Mon Sep 17 00:00:00 2001 From: toge Date: Fri, 31 May 2024 18:52:27 +0900 Subject: [PATCH 06/38] (#24175) ada: add version 2.8.0 --- recipes/ada/all/conandata.yml | 3 +++ recipes/ada/config.yml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/recipes/ada/all/conandata.yml b/recipes/ada/all/conandata.yml index 235136d4b7acf..ce7f88f9c21c4 100644 --- a/recipes/ada/all/conandata.yml +++ b/recipes/ada/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "2.8.0": + url: "https://github.com/ada-url/ada/archive/v2.8.0.tar.gz" + sha256: "83b77fb53d1a9eea22b1484472cea0215c50478c9ea2b4b44b0ba3b52e07c139" "2.7.8": url: "https://github.com/ada-url/ada/archive/v2.7.8.tar.gz" sha256: "8de067b7cb3da1808bf5439279aee6048d761ba246bf8a854c2af73b16b41c75" diff --git a/recipes/ada/config.yml b/recipes/ada/config.yml index 50d72ec6cb8b6..65b7e7769826f 100644 --- a/recipes/ada/config.yml +++ b/recipes/ada/config.yml @@ -1,4 +1,6 @@ versions: + "2.8.0": + folder: all "2.7.8": folder: all "2.7.7": From bb9710d7c0bea799817b68667f89762b515dc511 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Fri, 31 May 2024 18:11:51 +0800 Subject: [PATCH 07/38] (#24057) add extra-cmake-modules 6.2.0 --- recipes/extra-cmake-modules/all/conandata.yml | 3 +++ recipes/extra-cmake-modules/config.yml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/recipes/extra-cmake-modules/all/conandata.yml b/recipes/extra-cmake-modules/all/conandata.yml index 1879a975409f5..f556f71e55d06 100644 --- a/recipes/extra-cmake-modules/all/conandata.yml +++ b/recipes/extra-cmake-modules/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "6.2.0": + url: "https://download.kde.org/stable/frameworks/6.2/extra-cmake-modules-6.2.0.tar.xz" + sha256: "6374bfa0dded8be265c702acd5de11eecd2851c625b93e1c87d8d0f5f1a8ebe1" "5.113.0": url: "https://download.kde.org/stable/frameworks/5.113/extra-cmake-modules-5.113.0.tar.xz" sha256: "265e5440eebeca07351a469e617a4bf35748927bd907b00ace9c018392bb3bc4" diff --git a/recipes/extra-cmake-modules/config.yml b/recipes/extra-cmake-modules/config.yml index 789c28809f9ae..101fb016a65c8 100644 --- a/recipes/extra-cmake-modules/config.yml +++ b/recipes/extra-cmake-modules/config.yml @@ -1,4 +1,6 @@ versions: + "6.2.0": + folder: "all" "5.113.0": folder: "all" "5.111.0": From 70c7b7b1fef1886bcdfc29c447dbf174ac34e170 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 07:38:29 +0200 Subject: [PATCH 08/38] add cmaes --- recipes/cmaes/all/conandata.yml | 4 + recipes/cmaes/all/conanfile.py | 84 +++++++++++++++++++ recipes/cmaes/all/test_package/CMakeLists.txt | 7 ++ recipes/cmaes/all/test_package/conanfile.py | 27 ++++++ .../cmaes/all/test_package/src/example.cpp | 26 ++++++ recipes/cmaes/config.yml | 3 + recipes/cyclonedds/config.yml | 7 +- 7 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 recipes/cmaes/all/conandata.yml create mode 100644 recipes/cmaes/all/conanfile.py create mode 100644 recipes/cmaes/all/test_package/CMakeLists.txt create mode 100644 recipes/cmaes/all/test_package/conanfile.py create mode 100644 recipes/cmaes/all/test_package/src/example.cpp create mode 100644 recipes/cmaes/config.yml diff --git a/recipes/cmaes/all/conandata.yml b/recipes/cmaes/all/conandata.yml new file mode 100644 index 0000000000000..8f778fa4a74e9 --- /dev/null +++ b/recipes/cmaes/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.10.0": + url: "https://github.com/CMA-ES/libcmaes/archive/refs/tags/v0.10.tar.gz" + sha256: "a77fb892654356c5657dd677161b7c67b196dc732cfb77eaca6708abc4f6cffc" \ No newline at end of file diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py new file mode 100644 index 0000000000000..90034d719a999 --- /dev/null +++ b/recipes/cmaes/all/conanfile.py @@ -0,0 +1,84 @@ +import re, os, functools + +from conan import ConanFile, tools +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout +from conan.tools.files import load, export_conandata_patches, get +from conan.tools.env import Environment + +from conan.tools.scm import Git + + +class CmaesConan(ConanFile): + name = "libcmaes" + + generators = "CMakeDeps" + + # Optional metadata + license = "MIT" + author = "Philipp Basler" + url = "https://github.com/CMA-ES/libcmaes" + description = "libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy" + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + "openmp": [True, False], + "surrog": [True, False], + } + default_options = { + "shared": True, + "fPIC": True, + "openmp": True, + "surrog": True, + } + + short_paths = True + + def export_sources(self): + export_conandata_patches(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def build_requirements(self): + pass + + def requirements(self): + self.requires("eigen/3.4.0", transitive_headers=True) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIBCMAES_BUILD_EXAMPLES"] = False + tc.variables["LIBCMAES_BUILD_SHARED_LIBS"] = self.options.shared + tc.variables["LIBCMAES_USE_OPENMP"] = self.options.openmp + tc.variables["LIBCMAES_ENABLE_SURROG"] = self.options.surrog + tc.variables["LIBCMAES_BUILD_PYTHON"] = False + tc.variables["LIBCMAES_BUILD_TESTS"] = False + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["cmaes"] + self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") diff --git a/recipes/cmaes/all/test_package/CMakeLists.txt b/recipes/cmaes/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..65a1c3af9be1b --- /dev/null +++ b/recipes/cmaes/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(PackageTest CXX) + +find_package(libcmaes CONFIG REQUIRED) + +add_executable(example src/example.cpp) +target_link_libraries(example libcmaes::cmaes) diff --git a/recipes/cmaes/all/test_package/conanfile.py b/recipes/cmaes/all/test_package/conanfile.py new file mode 100644 index 0000000000000..2037d777edea2 --- /dev/null +++ b/recipes/cmaes/all/test_package/conanfile.py @@ -0,0 +1,27 @@ +import os + +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run + + +class helloTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + 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 can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "example") + self.run(cmd, env="conanrun") + diff --git a/recipes/cmaes/all/test_package/src/example.cpp b/recipes/cmaes/all/test_package/src/example.cpp new file mode 100644 index 0000000000000..8d7db54680bc0 --- /dev/null +++ b/recipes/cmaes/all/test_package/src/example.cpp @@ -0,0 +1,26 @@ +#include +#include + +using namespace libcmaes; + +FitFunc fsphere = [](const double *x, const int N) +{ + double val = 0.0; + for (int i=0;i x0(dim,10.0); + double sigma = 0.1; + //int lambda = 100; // offsprings at each generation. + CMAParameters<> cmaparams(x0,sigma); + //cmaparams._algo = BIPOP_CMAES; + CMASolutions cmasols = cmaes<>(fsphere,cmaparams); + std::cout << "best solution: " << cmasols << std::endl; + std::cout << "optimization took " << cmasols.elapsed_time() / 1000.0 << " seconds\n"; + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/recipes/cmaes/config.yml b/recipes/cmaes/config.yml new file mode 100644 index 0000000000000..fffebf2eddbdf --- /dev/null +++ b/recipes/cmaes/config.yml @@ -0,0 +1,3 @@ +versions: + "0.10.0": + folder: all \ No newline at end of file diff --git a/recipes/cyclonedds/config.yml b/recipes/cyclonedds/config.yml index b770b06071265..458ccaa3ed0ee 100644 --- a/recipes/cyclonedds/config.yml +++ b/recipes/cyclonedds/config.yml @@ -1,7 +1,4 @@ versions: - "0.10.4": - folder: all - "0.10.3": - folder: all - "0.10.2": + "0.10.0": folder: all + From 62b1cea8bb0bc1ce296e28085e181a6655182c7f Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 08:15:24 +0200 Subject: [PATCH 09/38] Update config.yml --- recipes/cmaes/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/cmaes/config.yml b/recipes/cmaes/config.yml index fffebf2eddbdf..558825c3387f3 100644 --- a/recipes/cmaes/config.yml +++ b/recipes/cmaes/config.yml @@ -1,3 +1,4 @@ versions: "0.10.0": - folder: all \ No newline at end of file + folder: all + From e45bbab5bed9e44940c58dcb49e33e28d563a863 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 08:51:03 +0200 Subject: [PATCH 10/38] Remove trailing whitespace --- recipes/cmaes/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/cmaes/config.yml b/recipes/cmaes/config.yml index 558825c3387f3..1b582dcf6716b 100644 --- a/recipes/cmaes/config.yml +++ b/recipes/cmaes/config.yml @@ -1,4 +1,3 @@ versions: "0.10.0": folder: all - From 2c1c3ab63d5aa386b134e7a283462ff5379faa0c Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 21:49:23 +0200 Subject: [PATCH 11/38] Apply linter comments --- recipes/cmaes/all/conandata.yml | 2 +- recipes/cmaes/config.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/cmaes/all/conandata.yml b/recipes/cmaes/all/conandata.yml index 8f778fa4a74e9..191b7b47616e8 100644 --- a/recipes/cmaes/all/conandata.yml +++ b/recipes/cmaes/all/conandata.yml @@ -1,4 +1,4 @@ sources: "0.10.0": url: "https://github.com/CMA-ES/libcmaes/archive/refs/tags/v0.10.tar.gz" - sha256: "a77fb892654356c5657dd677161b7c67b196dc732cfb77eaca6708abc4f6cffc" \ No newline at end of file + sha256: "a77fb892654356c5657dd677161b7c67b196dc732cfb77eaca6708abc4f6cffc" diff --git a/recipes/cmaes/config.yml b/recipes/cmaes/config.yml index 1b582dcf6716b..fffebf2eddbdf 100644 --- a/recipes/cmaes/config.yml +++ b/recipes/cmaes/config.yml @@ -1,3 +1,3 @@ versions: "0.10.0": - folder: all + folder: all \ No newline at end of file From 7f4c46b819a52817f1f2f77180ef3753b44970a5 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 21:51:45 +0200 Subject: [PATCH 12/38] undo copy paste error --- recipes/cyclonedds/config.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/recipes/cyclonedds/config.yml b/recipes/cyclonedds/config.yml index 458ccaa3ed0ee..b770b06071265 100644 --- a/recipes/cyclonedds/config.yml +++ b/recipes/cyclonedds/config.yml @@ -1,4 +1,7 @@ versions: - "0.10.0": + "0.10.4": + folder: all + "0.10.3": + folder: all + "0.10.2": folder: all - From 6dd4404d38f0097848bdc2d145067a31367b7cb6 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 21:53:48 +0200 Subject: [PATCH 13/38] Remove unused imports --- recipes/cmaes/all/conanfile.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 90034d719a999..4f63299ad7f8d 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -1,12 +1,7 @@ -import re, os, functools - -from conan import ConanFile, tools from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout -from conan.tools.files import load, export_conandata_patches, get -from conan.tools.env import Environment +from conan.tools.files import export_conandata_patches, get -from conan.tools.scm import Git class CmaesConan(ConanFile): @@ -39,7 +34,7 @@ class CmaesConan(ConanFile): def export_sources(self): export_conandata_patches(self) - + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) From cff6a8ba5508e42fc814109282ee5627b06baf4e Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 21:54:47 +0200 Subject: [PATCH 14/38] change name --- recipes/cmaes/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 4f63299ad7f8d..fd0cb0d67a524 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -5,7 +5,7 @@ class CmaesConan(ConanFile): - name = "libcmaes" + name = "cmaes" generators = "CMakeDeps" From 1cc89e851a4bf75b539c696b32695dbe3f625c91 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 21:55:20 +0200 Subject: [PATCH 15/38] add line break --- recipes/cmaes/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cmaes/config.yml b/recipes/cmaes/config.yml index fffebf2eddbdf..1b582dcf6716b 100644 --- a/recipes/cmaes/config.yml +++ b/recipes/cmaes/config.yml @@ -1,3 +1,3 @@ versions: "0.10.0": - folder: all \ No newline at end of file + folder: all From 171eccc6e50b5576f875e77494b3cd651e132af9 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 21:57:30 +0200 Subject: [PATCH 16/38] Set layout src_folder arg --- recipes/cmaes/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index fd0cb0d67a524..e9e9cc8aaebc5 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -53,7 +53,7 @@ def configure(self): self.options.rm_safe("fPIC") def layout(self): - cmake_layout(self) + cmake_layout(self,src_folder="src") def generate(self): tc = CMakeToolchain(self) From d27837b8c897df7d90785cfa8468d675d19faf33 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:22:14 +0200 Subject: [PATCH 17/38] Adjust hook warnings and fix find_package --- recipes/cmaes/all/conanfile.py | 5 +++-- recipes/cmaes/all/test_package/CMakeLists.txt | 2 +- recipes/cmaes/all/test_package/src/example.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index e9e9cc8aaebc5..bf1d1852a53f6 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -11,9 +11,10 @@ class CmaesConan(ConanFile): # Optional metadata license = "MIT" - author = "Philipp Basler" - url = "https://github.com/CMA-ES/libcmaes" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/CMA-ES/libcmaes" description = "libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy" + topics = ("cmaes", "minimization") # Binary configuration settings = "os", "compiler", "build_type", "arch" diff --git a/recipes/cmaes/all/test_package/CMakeLists.txt b/recipes/cmaes/all/test_package/CMakeLists.txt index 65a1c3af9be1b..6927b26e2dc88 100644 --- a/recipes/cmaes/all/test_package/CMakeLists.txt +++ b/recipes/cmaes/all/test_package/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.15) project(PackageTest CXX) -find_package(libcmaes CONFIG REQUIRED) +find_package(cmaes CONFIG REQUIRED) add_executable(example src/example.cpp) target_link_libraries(example libcmaes::cmaes) diff --git a/recipes/cmaes/all/test_package/src/example.cpp b/recipes/cmaes/all/test_package/src/example.cpp index 8d7db54680bc0..1835813f2705d 100644 --- a/recipes/cmaes/all/test_package/src/example.cpp +++ b/recipes/cmaes/all/test_package/src/example.cpp @@ -23,4 +23,4 @@ int main() std::cout << "best solution: " << cmasols << std::endl; std::cout << "optimization took " << cmasols.elapsed_time() / 1000.0 << " seconds\n"; return EXIT_SUCCESS; -} \ No newline at end of file +} From 95a1ca664769d5ee6938b9376e2db07e8b89134e Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:56:24 +0200 Subject: [PATCH 18/38] fix missing requirement --- recipes/cmaes/all/conanfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index bf1d1852a53f6..43747e1f9c58b 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -25,7 +25,7 @@ class CmaesConan(ConanFile): "surrog": [True, False], } default_options = { - "shared": True, + "shared": False, "fPIC": True, "openmp": True, "surrog": True, @@ -44,6 +44,8 @@ def build_requirements(self): def requirements(self): self.requires("eigen/3.4.0", transitive_headers=True) + if self.options.openmp: + self.requires("llvm-openmp/17.0.6", transitive_headers=True) def config_options(self): if self.settings.os == "Windows": From 6ca7bc77ac97e2903616b4611920c0cea467532f Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 23:23:22 +0200 Subject: [PATCH 19/38] Set minimum conan version to 2 --- recipes/cmaes/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 43747e1f9c58b..e938df0ba333c 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -2,7 +2,7 @@ from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout from conan.tools.files import export_conandata_patches, get - +required_conan_version = ">=2.0.0" class CmaesConan(ConanFile): name = "cmaes" From 4f7ea35f40cb461fa6c336ce626f8bef5593ec5b Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 23:38:08 +0200 Subject: [PATCH 20/38] Undo conan minimum requirement --- recipes/cmaes/all/conanfile.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index e938df0ba333c..5b0dd3f2add69 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -2,8 +2,6 @@ from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout from conan.tools.files import export_conandata_patches, get -required_conan_version = ">=2.0.0" - class CmaesConan(ConanFile): name = "cmaes" From 87239b4504d326ba365715db3c18c6536afa5da7 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 3 Jun 2024 23:47:22 +0200 Subject: [PATCH 21/38] Add patch to remove pc and exports --- .../all/patches/removePCAndExports.patch | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 recipes/cmaes/all/patches/removePCAndExports.patch diff --git a/recipes/cmaes/all/patches/removePCAndExports.patch b/recipes/cmaes/all/patches/removePCAndExports.patch new file mode 100644 index 0000000000000..36f409d3f4ff5 --- /dev/null +++ b/recipes/cmaes/all/patches/removePCAndExports.patch @@ -0,0 +1,40 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4a38212..bb851de 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -152,9 +152,7 @@ if (NOT MSVC) + set (libdir ${INSTALL_LIB_DIR}) + set (includedir ${INSTALL_INCLUDE_DIR}) + set (VERSION ${LIBCMAES_VERSION_STRING}) +- configure_file (libcmaes.pc.in libcmaes.pc @ONLY) +- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmaes.pc +- DESTINATION ${RELATIVE_INSTALL_LIB_DIR}/pkgconfig) ++ + endif () + + # ---------- subdirectories ---------- +@@ -174,23 +172,4 @@ endif () + # ------------ export ------------ + add_library (libcmaes::cmaes ALIAS cmaes) + +-include (CMakePackageConfigHelpers) +-write_basic_package_version_file ( +- libcmaesConfigVersion.cmake VERSION ${PACKAGE_VERSION} +- COMPATIBILITY AnyNewerVersion) +- +-# export target to build directory +-export (TARGETS cmaes NAMESPACE libcmaes:: FILE libcmaesTargets.cmake) +-# export target on install +-install ( +- EXPORT libcmaesTargets +- FILE libcmaesTargets.cmake +- NAMESPACE libcmaes:: +- DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR}) +- +-configure_file (libcmaesConfig.cmake.in libcmaesConfig.cmake @ONLY) +-install ( +- FILES "${CMAKE_CURRENT_BINARY_DIR}/libcmaesConfig.cmake" +- "${CMAKE_CURRENT_BINARY_DIR}/libcmaesConfigVersion.cmake" +- "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindEigen3.cmake" +- DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR}) ++ From 209d577670abeda41396131be2a31b37e112b85c Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Tue, 4 Jun 2024 00:20:15 +0200 Subject: [PATCH 22/38] Remove patch, remove cmake and pc through conanfile --- recipes/cmaes/all/conanfile.py | 10 ++++- .../all/patches/removePCAndExports.patch | 40 ------------------- 2 files changed, 8 insertions(+), 42 deletions(-) delete mode 100644 recipes/cmaes/all/patches/removePCAndExports.patch diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 5b0dd3f2add69..546ede9daf7a0 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -1,6 +1,7 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout -from conan.tools.files import export_conandata_patches, get +from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy +import os class CmaesConan(ConanFile): name = "cmaes" @@ -8,7 +9,7 @@ class CmaesConan(ConanFile): generators = "CMakeDeps" # Optional metadata - license = "MIT" + license = "LGPLv3" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/CMA-ES/libcmaes" description = "libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy" @@ -67,6 +68,7 @@ def generate(self): tc.generate() def build(self): + #apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() @@ -75,6 +77,10 @@ def package(self): cmake = CMake(self) cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib","pkgconfig")) + rm(self, "*.cmake", os.path.join(self.package_folder, "lib", "cmake", "libcmaes")) + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + def package_info(self): self.cpp_info.libs = ["cmaes"] self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") diff --git a/recipes/cmaes/all/patches/removePCAndExports.patch b/recipes/cmaes/all/patches/removePCAndExports.patch deleted file mode 100644 index 36f409d3f4ff5..0000000000000 --- a/recipes/cmaes/all/patches/removePCAndExports.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 4a38212..bb851de 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -152,9 +152,7 @@ if (NOT MSVC) - set (libdir ${INSTALL_LIB_DIR}) - set (includedir ${INSTALL_INCLUDE_DIR}) - set (VERSION ${LIBCMAES_VERSION_STRING}) -- configure_file (libcmaes.pc.in libcmaes.pc @ONLY) -- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmaes.pc -- DESTINATION ${RELATIVE_INSTALL_LIB_DIR}/pkgconfig) -+ - endif () - - # ---------- subdirectories ---------- -@@ -174,23 +172,4 @@ endif () - # ------------ export ------------ - add_library (libcmaes::cmaes ALIAS cmaes) - --include (CMakePackageConfigHelpers) --write_basic_package_version_file ( -- libcmaesConfigVersion.cmake VERSION ${PACKAGE_VERSION} -- COMPATIBILITY AnyNewerVersion) -- --# export target to build directory --export (TARGETS cmaes NAMESPACE libcmaes:: FILE libcmaesTargets.cmake) --# export target on install --install ( -- EXPORT libcmaesTargets -- FILE libcmaesTargets.cmake -- NAMESPACE libcmaes:: -- DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR}) -- --configure_file (libcmaesConfig.cmake.in libcmaesConfig.cmake @ONLY) --install ( -- FILES "${CMAKE_CURRENT_BINARY_DIR}/libcmaesConfig.cmake" -- "${CMAKE_CURRENT_BINARY_DIR}/libcmaesConfigVersion.cmake" -- "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindEigen3.cmake" -- DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR}) -+ From 1fa1468ac73b5b6d1c6532da5e377a42fb3cd43d Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Tue, 4 Jun 2024 06:51:33 +0200 Subject: [PATCH 23/38] only get openmp on mac and linux --- recipes/cmaes/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 546ede9daf7a0..e5036246f13b8 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -43,7 +43,7 @@ def build_requirements(self): def requirements(self): self.requires("eigen/3.4.0", transitive_headers=True) - if self.options.openmp: + if self.options.openmp and self.settings.os != "Windows": self.requires("llvm-openmp/17.0.6", transitive_headers=True) def config_options(self): From 2b34d0f90fef793a48181e94bca9fe6dc7125066 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Tue, 4 Jun 2024 08:22:05 +0200 Subject: [PATCH 24/38] disable openmp on windows for now --- recipes/cmaes/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index e5036246f13b8..546ede9daf7a0 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -43,7 +43,7 @@ def build_requirements(self): def requirements(self): self.requires("eigen/3.4.0", transitive_headers=True) - if self.options.openmp and self.settings.os != "Windows": + if self.options.openmp: self.requires("llvm-openmp/17.0.6", transitive_headers=True) def config_options(self): From eb34bdc732bb060a004bde8d12050c3ccda3946f Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 9 Jun 2024 09:19:25 +0200 Subject: [PATCH 25/38] Add test workflow --- .github/workflows/cmaes-test-conan1.yml | 14 ++++++++++++++ recipes/cmaes/all/profiles/clang-libc++-release | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .github/workflows/cmaes-test-conan1.yml create mode 100644 recipes/cmaes/all/profiles/clang-libc++-release diff --git a/.github/workflows/cmaes-test-conan1.yml b/.github/workflows/cmaes-test-conan1.yml new file mode 100644 index 0000000000000..e2b51623b8f8e --- /dev/null +++ b/.github/workflows/cmaes-test-conan1.yml @@ -0,0 +1,14 @@ +name: test-conan1 +on: + push: + +jobs: + conan1: + runs-on: ubuntu-latest + steps: + - run: pip3 install "conan<2" + - run: | + cd recipes/cmaes/all + cp profiles/clang-libc++-release ~/.conan/profiles + conan create --profile clang-libc++-release . 0.10.0@ + diff --git a/recipes/cmaes/all/profiles/clang-libc++-release b/recipes/cmaes/all/profiles/clang-libc++-release new file mode 100644 index 0000000000000..8f6b4cde8d821 --- /dev/null +++ b/recipes/cmaes/all/profiles/clang-libc++-release @@ -0,0 +1,13 @@ +[settings] +arch=x86_64 +build_type=Release +compiler=clang +compiler.libcxx=libc++ +compiler.version=13 +os=Linux +[options] +cmaes:shared=False +[build_requires] +[env] +CC=clang-13 +CXX=clang++-13 \ No newline at end of file From b102d9ee0d369051c9795a8074b09b83d8230a5f Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Sun, 9 Jun 2024 09:20:51 +0200 Subject: [PATCH 26/38] Revert "Add test workflow" This reverts commit eb34bdc732bb060a004bde8d12050c3ccda3946f. --- .github/workflows/cmaes-test-conan1.yml | 14 -------------- recipes/cmaes/all/profiles/clang-libc++-release | 13 ------------- 2 files changed, 27 deletions(-) delete mode 100644 .github/workflows/cmaes-test-conan1.yml delete mode 100644 recipes/cmaes/all/profiles/clang-libc++-release diff --git a/.github/workflows/cmaes-test-conan1.yml b/.github/workflows/cmaes-test-conan1.yml deleted file mode 100644 index e2b51623b8f8e..0000000000000 --- a/.github/workflows/cmaes-test-conan1.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: test-conan1 -on: - push: - -jobs: - conan1: - runs-on: ubuntu-latest - steps: - - run: pip3 install "conan<2" - - run: | - cd recipes/cmaes/all - cp profiles/clang-libc++-release ~/.conan/profiles - conan create --profile clang-libc++-release . 0.10.0@ - diff --git a/recipes/cmaes/all/profiles/clang-libc++-release b/recipes/cmaes/all/profiles/clang-libc++-release deleted file mode 100644 index 8f6b4cde8d821..0000000000000 --- a/recipes/cmaes/all/profiles/clang-libc++-release +++ /dev/null @@ -1,13 +0,0 @@ -[settings] -arch=x86_64 -build_type=Release -compiler=clang -compiler.libcxx=libc++ -compiler.version=13 -os=Linux -[options] -cmaes:shared=False -[build_requires] -[env] -CC=clang-13 -CXX=clang++-13 \ No newline at end of file From ebc0e0b2f36bf47b85d8d1901072e6223f01bc05 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 15 Jul 2024 06:42:42 +0200 Subject: [PATCH 27/38] Add patch for eigen and for windows compile options --- recipes/cmaes/all/conandata.yml | 3 + recipes/cmaes/all/conanfile.py | 4 +- .../all/patches/CompilerOptionsEigen.patch | 142 ++++++++++++++++++ recipes/cmaes/all/test_package/conanfile.py | 83 ++++++++-- 4 files changed, 218 insertions(+), 14 deletions(-) create mode 100644 recipes/cmaes/all/patches/CompilerOptionsEigen.patch diff --git a/recipes/cmaes/all/conandata.yml b/recipes/cmaes/all/conandata.yml index 191b7b47616e8..553aca707f508 100644 --- a/recipes/cmaes/all/conandata.yml +++ b/recipes/cmaes/all/conandata.yml @@ -2,3 +2,6 @@ sources: "0.10.0": url: "https://github.com/CMA-ES/libcmaes/archive/refs/tags/v0.10.tar.gz" sha256: "a77fb892654356c5657dd677161b7c67b196dc732cfb77eaca6708abc4f6cffc" +patches: + "0.10.0": + - patch_file: "patches/CompilerOptionsEigen.patch" \ No newline at end of file diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 546ede9daf7a0..2e56da07c604c 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -1,6 +1,6 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout -from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy +from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy, apply_conandata_patches import os class CmaesConan(ConanFile): @@ -68,7 +68,7 @@ def generate(self): tc.generate() def build(self): - #apply_conandata_patches(self) + apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() diff --git a/recipes/cmaes/all/patches/CompilerOptionsEigen.patch b/recipes/cmaes/all/patches/CompilerOptionsEigen.patch new file mode 100644 index 0000000000000..ba728f3d5d253 --- /dev/null +++ b/recipes/cmaes/all/patches/CompilerOptionsEigen.patch @@ -0,0 +1,142 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4a38212..dccfea4 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,12 +6,10 @@ if (NOT DEFINED CMAKE_BUILD_TYPE) + set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") + endif () + +-set(CMAKE_CXX_FLAGS "-Wall -Wextra") +-set(CMAKE_CXX_FLAGS_DEBUG "-g") +-set(CMAKE_CXX_FLAGS_RELEASE "-O3") +- + list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) + ++include(CompilerOptions) ++ + set (LIBCMAES_TOP_LEVEL NO) + if (${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) + set (LIBCMAES_TOP_LEVEL YES) +diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake +new file mode 100644 +index 0000000..af4f716 +--- /dev/null ++++ b/cmake/CompilerOptions.cmake +@@ -0,0 +1,91 @@ ++ ++set(CMAKE_CXX_FLAGS_DEBUG ++ "${CMAKE_CXX_FLAGS_DEBUG} -Wall" ++) ++set(CMAKE_CXX_FLAGS_RELEASE ++ "${CMAKE_CXX_FLAGS_RELEASE} -Wall ") ++ ++if(CMAKE_COMPILER_IS_GNUCXX) ++ set(CMAKE_CXX_FLAGS_DEBUG ++ "${CMAKE_CXX_FLAGS_DEBUG} -Wextra") ++ set(CMAKE_CXX_FLAGS_RELEASE ++ "${CMAKE_CXX_FLAGS_RELEASE} -O3 -Wextra") ++endif(CMAKE_COMPILER_IS_GNUCXX) ++ ++if (MSVC) ++ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_USE_MATH_DEFINES" ) ++ ++ set(CMAKE_CXX_FLAGS_DEBUG ++ "${CMAKE_CXX_FLAGS_DEBUG} /permissive- /bigobj /w44101") ++ ++ set(CMAKE_CXX_FLAGS_RELEASE ++ "${CMAKE_CXX_FLAGS_RELEASE} /permissive- /bigobj /Ox /w44101") ++ ++ set(MSVC_DISABLED_WARNINGS_LIST ++ "C4061" # enumerator 'identifier' in switch of enum 'enumeration' is not ++ # explicitly handled by a case label ++ # Disable this because it flags even when there is a default. ++ "C4068" ++ "C4100" # 'exarg' : unreferenced formal parameter ++ "C4127" # conditional expression is constant ++ "C4200" # nonstandard extension used : zero-sized array in ++ # struct/union. ++ "C4204" # nonstandard extension used: non-constant aggregate initializer ++ "C4221" # nonstandard extension used : 'identifier' : cannot be ++ # initialized using address of automatic variable ++ "C4242" # 'function' : conversion from 'int' to 'uint8_t', ++ # possible loss of data ++ "C4244" # 'function' : conversion from 'int' to 'uint8_t', ++ # possible loss of data ++ "C4245" # 'initializing' : conversion from 'long' to ++ # 'unsigned long', signed/unsigned mismatch ++ "C4251" ++ "C4267" # conversion from 'size_t' to 'int', possible loss of data ++ "C4275" ++ "C4355" ++ "C4371" # layout of class may have changed from a previous version of the ++ # compiler due to better packing of member '...' ++ "C4388" # signed/unsigned mismatch ++ "C4296" # '>=' : expression is always true ++ "C4350" # behavior change: 'std::_Wrap_alloc...' ++ "C4365" # '=' : conversion from 'size_t' to 'int', ++ # signed/unsigned mismatch ++ "C4389" # '!=' : signed/unsigned mismatch ++ "C4464" # relative include path contains '..' ++ "C4510" # 'argument' : default constructor could not be generated ++ "C4571" ++ "C4512" # 'argument' : assignment operator could not be generated ++ "C4514" # 'function': unreferenced inline function has been removed ++ "C4548" # expression before comma has no effect; expected expression with ++ # side-effect" caused by FD_* macros. ++ "C4610" # struct 'argument' can never be instantiated - user defined ++ # constructor required. ++ "C4619" ++ "C4623" # default constructor was implicitly defined as deleted ++ "C4625" # copy constructor could not be generated because a base class ++ # copy constructor is inaccessible or deleted ++ "C4626" # assignment operator could not be generated because a base class ++ # assignment operator is inaccessible or deleted ++ "C4643" ++ "C4668" # 'symbol' is not defined as a preprocessor macro, replacing with ++ # '0' for 'directives' ++ # Disable this because GTest uses it everywhere. ++ "C4706" # assignment within conditional expression ++ "C4710" # 'function': function not inlined ++ "C4711" # function 'function' selected for inline expansion ++ "C4800" # 'int' : forcing value to bool 'true' or 'false' ++ # (performance warning) ++ "C4820" # 'bytes' bytes padding added after construct 'member_name' ++ "C4868" ++ "C4996" ++ "C5026" # move constructor was implicitly defined as deleted ++ "C5027" # move assignment operator was implicitly defined as deleted ++ "C5031" ++ "C5039" ++ "C5045" ++ ) ++ string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR ++ ${MSVC_DISABLED_WARNINGS_LIST}) ++ ++ set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} ${MSVC_DISABLED_WARNINGS_STR}") ++ endif() +diff --git a/include/libcmaes/eigenmvn.h b/include/libcmaes/eigenmvn.h +index fb8b11d..6a6943b 100644 +--- a/include/libcmaes/eigenmvn.h ++++ b/include/libcmaes/eigenmvn.h +@@ -58,7 +58,20 @@ public: + static std::mt19937 rng; // The uniform pseudo-random algorithm + mutable std::normal_distribution norm; // gaussian combinator + +- EIGEN_EMPTY_STRUCT_CTOR(scalar_normal_dist_op) ++ scalar_normal_dist_op() = default; ++ scalar_normal_dist_op(const scalar_normal_dist_op& other) ++ : norm{other.norm} ++ { ++ rng = other.rng; ++ }; ++ scalar_normal_dist_op &operator=(const scalar_normal_dist_op &other) { ++ if(this != &other) ++ { ++ scalar_normal_dist_op temp(other); ++ swap(temp); ++ } ++ return *this; ++ }; + + scalar_normal_dist_op &operator=(scalar_normal_dist_op &&other) + { diff --git a/recipes/cmaes/all/test_package/conanfile.py b/recipes/cmaes/all/test_package/conanfile.py index 2037d777edea2..546ede9daf7a0 100644 --- a/recipes/cmaes/all/test_package/conanfile.py +++ b/recipes/cmaes/all/test_package/conanfile.py @@ -1,27 +1,86 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout +from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy import os -from conan import ConanFile -from conan.tools.cmake import CMake, cmake_layout -from conan.tools.build import can_run +class CmaesConan(ConanFile): + name = "cmaes" + generators = "CMakeDeps" -class helloTestConan(ConanFile): + # Optional metadata + license = "LGPLv3" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/CMA-ES/libcmaes" + description = "libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy" + topics = ("cmaes", "minimization") + + # Binary configuration settings = "os", "compiler", "build_type", "arch" - generators = "CMakeDeps", "CMakeToolchain" + options = { + "shared": [True, False], + "fPIC": [True, False], + "openmp": [True, False], + "surrog": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "openmp": True, + "surrog": True, + } + + short_paths = True + + def export_sources(self): + export_conandata_patches(self) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def build_requirements(self): + pass def requirements(self): - self.requires(self.tested_reference_str) + self.requires("eigen/3.4.0", transitive_headers=True) + if self.options.openmp: + self.requires("llvm-openmp/17.0.6", transitive_headers=True) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self,src_folder="src") + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["LIBCMAES_BUILD_EXAMPLES"] = False + tc.variables["LIBCMAES_BUILD_SHARED_LIBS"] = self.options.shared + tc.variables["LIBCMAES_USE_OPENMP"] = self.options.openmp + tc.variables["LIBCMAES_ENABLE_SURROG"] = self.options.surrog + tc.variables["LIBCMAES_BUILD_PYTHON"] = False + tc.variables["LIBCMAES_BUILD_TESTS"] = False + tc.generate() def build(self): + #apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() - def layout(self): - cmake_layout(self) + def package(self): + cmake = CMake(self) + cmake.install() - def test(self): - if can_run(self): - cmd = os.path.join(self.cpp.build.bindir, "example") - self.run(cmd, env="conanrun") + rmdir(self, os.path.join(self.package_folder, "lib","pkgconfig")) + rm(self, "*.cmake", os.path.join(self.package_folder, "lib", "cmake", "libcmaes")) + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + def package_info(self): + self.cpp_info.libs = ["cmaes"] + self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") From 743b8bba9a4c3e43d74c6cab8e85acd977e3c082 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 15 Jul 2024 06:44:23 +0200 Subject: [PATCH 28/38] Revert "Add patch for eigen and for windows compile options" This reverts commit ebc0e0b2f36bf47b85d8d1901072e6223f01bc05. --- recipes/cmaes/all/conandata.yml | 3 - recipes/cmaes/all/conanfile.py | 4 +- .../all/patches/CompilerOptionsEigen.patch | 142 ------------------ recipes/cmaes/all/test_package/conanfile.py | 83 ++-------- 4 files changed, 14 insertions(+), 218 deletions(-) delete mode 100644 recipes/cmaes/all/patches/CompilerOptionsEigen.patch diff --git a/recipes/cmaes/all/conandata.yml b/recipes/cmaes/all/conandata.yml index 553aca707f508..191b7b47616e8 100644 --- a/recipes/cmaes/all/conandata.yml +++ b/recipes/cmaes/all/conandata.yml @@ -2,6 +2,3 @@ sources: "0.10.0": url: "https://github.com/CMA-ES/libcmaes/archive/refs/tags/v0.10.tar.gz" sha256: "a77fb892654356c5657dd677161b7c67b196dc732cfb77eaca6708abc4f6cffc" -patches: - "0.10.0": - - patch_file: "patches/CompilerOptionsEigen.patch" \ No newline at end of file diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 2e56da07c604c..546ede9daf7a0 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -1,6 +1,6 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout -from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy, apply_conandata_patches +from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy import os class CmaesConan(ConanFile): @@ -68,7 +68,7 @@ def generate(self): tc.generate() def build(self): - apply_conandata_patches(self) + #apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() diff --git a/recipes/cmaes/all/patches/CompilerOptionsEigen.patch b/recipes/cmaes/all/patches/CompilerOptionsEigen.patch deleted file mode 100644 index ba728f3d5d253..0000000000000 --- a/recipes/cmaes/all/patches/CompilerOptionsEigen.patch +++ /dev/null @@ -1,142 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 4a38212..dccfea4 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -6,12 +6,10 @@ if (NOT DEFINED CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") - endif () - --set(CMAKE_CXX_FLAGS "-Wall -Wextra") --set(CMAKE_CXX_FLAGS_DEBUG "-g") --set(CMAKE_CXX_FLAGS_RELEASE "-O3") -- - list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) - -+include(CompilerOptions) -+ - set (LIBCMAES_TOP_LEVEL NO) - if (${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) - set (LIBCMAES_TOP_LEVEL YES) -diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake -new file mode 100644 -index 0000000..af4f716 ---- /dev/null -+++ b/cmake/CompilerOptions.cmake -@@ -0,0 +1,91 @@ -+ -+set(CMAKE_CXX_FLAGS_DEBUG -+ "${CMAKE_CXX_FLAGS_DEBUG} -Wall" -+) -+set(CMAKE_CXX_FLAGS_RELEASE -+ "${CMAKE_CXX_FLAGS_RELEASE} -Wall ") -+ -+if(CMAKE_COMPILER_IS_GNUCXX) -+ set(CMAKE_CXX_FLAGS_DEBUG -+ "${CMAKE_CXX_FLAGS_DEBUG} -Wextra") -+ set(CMAKE_CXX_FLAGS_RELEASE -+ "${CMAKE_CXX_FLAGS_RELEASE} -O3 -Wextra") -+endif(CMAKE_COMPILER_IS_GNUCXX) -+ -+if (MSVC) -+ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_USE_MATH_DEFINES" ) -+ -+ set(CMAKE_CXX_FLAGS_DEBUG -+ "${CMAKE_CXX_FLAGS_DEBUG} /permissive- /bigobj /w44101") -+ -+ set(CMAKE_CXX_FLAGS_RELEASE -+ "${CMAKE_CXX_FLAGS_RELEASE} /permissive- /bigobj /Ox /w44101") -+ -+ set(MSVC_DISABLED_WARNINGS_LIST -+ "C4061" # enumerator 'identifier' in switch of enum 'enumeration' is not -+ # explicitly handled by a case label -+ # Disable this because it flags even when there is a default. -+ "C4068" -+ "C4100" # 'exarg' : unreferenced formal parameter -+ "C4127" # conditional expression is constant -+ "C4200" # nonstandard extension used : zero-sized array in -+ # struct/union. -+ "C4204" # nonstandard extension used: non-constant aggregate initializer -+ "C4221" # nonstandard extension used : 'identifier' : cannot be -+ # initialized using address of automatic variable -+ "C4242" # 'function' : conversion from 'int' to 'uint8_t', -+ # possible loss of data -+ "C4244" # 'function' : conversion from 'int' to 'uint8_t', -+ # possible loss of data -+ "C4245" # 'initializing' : conversion from 'long' to -+ # 'unsigned long', signed/unsigned mismatch -+ "C4251" -+ "C4267" # conversion from 'size_t' to 'int', possible loss of data -+ "C4275" -+ "C4355" -+ "C4371" # layout of class may have changed from a previous version of the -+ # compiler due to better packing of member '...' -+ "C4388" # signed/unsigned mismatch -+ "C4296" # '>=' : expression is always true -+ "C4350" # behavior change: 'std::_Wrap_alloc...' -+ "C4365" # '=' : conversion from 'size_t' to 'int', -+ # signed/unsigned mismatch -+ "C4389" # '!=' : signed/unsigned mismatch -+ "C4464" # relative include path contains '..' -+ "C4510" # 'argument' : default constructor could not be generated -+ "C4571" -+ "C4512" # 'argument' : assignment operator could not be generated -+ "C4514" # 'function': unreferenced inline function has been removed -+ "C4548" # expression before comma has no effect; expected expression with -+ # side-effect" caused by FD_* macros. -+ "C4610" # struct 'argument' can never be instantiated - user defined -+ # constructor required. -+ "C4619" -+ "C4623" # default constructor was implicitly defined as deleted -+ "C4625" # copy constructor could not be generated because a base class -+ # copy constructor is inaccessible or deleted -+ "C4626" # assignment operator could not be generated because a base class -+ # assignment operator is inaccessible or deleted -+ "C4643" -+ "C4668" # 'symbol' is not defined as a preprocessor macro, replacing with -+ # '0' for 'directives' -+ # Disable this because GTest uses it everywhere. -+ "C4706" # assignment within conditional expression -+ "C4710" # 'function': function not inlined -+ "C4711" # function 'function' selected for inline expansion -+ "C4800" # 'int' : forcing value to bool 'true' or 'false' -+ # (performance warning) -+ "C4820" # 'bytes' bytes padding added after construct 'member_name' -+ "C4868" -+ "C4996" -+ "C5026" # move constructor was implicitly defined as deleted -+ "C5027" # move assignment operator was implicitly defined as deleted -+ "C5031" -+ "C5039" -+ "C5045" -+ ) -+ string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR -+ ${MSVC_DISABLED_WARNINGS_LIST}) -+ -+ set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} ${MSVC_DISABLED_WARNINGS_STR}") -+ endif() -diff --git a/include/libcmaes/eigenmvn.h b/include/libcmaes/eigenmvn.h -index fb8b11d..6a6943b 100644 ---- a/include/libcmaes/eigenmvn.h -+++ b/include/libcmaes/eigenmvn.h -@@ -58,7 +58,20 @@ public: - static std::mt19937 rng; // The uniform pseudo-random algorithm - mutable std::normal_distribution norm; // gaussian combinator - -- EIGEN_EMPTY_STRUCT_CTOR(scalar_normal_dist_op) -+ scalar_normal_dist_op() = default; -+ scalar_normal_dist_op(const scalar_normal_dist_op& other) -+ : norm{other.norm} -+ { -+ rng = other.rng; -+ }; -+ scalar_normal_dist_op &operator=(const scalar_normal_dist_op &other) { -+ if(this != &other) -+ { -+ scalar_normal_dist_op temp(other); -+ swap(temp); -+ } -+ return *this; -+ }; - - scalar_normal_dist_op &operator=(scalar_normal_dist_op &&other) - { diff --git a/recipes/cmaes/all/test_package/conanfile.py b/recipes/cmaes/all/test_package/conanfile.py index 546ede9daf7a0..2037d777edea2 100644 --- a/recipes/cmaes/all/test_package/conanfile.py +++ b/recipes/cmaes/all/test_package/conanfile.py @@ -1,86 +1,27 @@ -from conan import ConanFile -from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout -from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy import os -class CmaesConan(ConanFile): - name = "cmaes" - - generators = "CMakeDeps" +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run - # Optional metadata - license = "LGPLv3" - url = "https://github.com/conan-io/conan-center-index" - homepage = "https://github.com/CMA-ES/libcmaes" - description = "libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy" - topics = ("cmaes", "minimization") - # Binary configuration +class helloTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - options = { - "shared": [True, False], - "fPIC": [True, False], - "openmp": [True, False], - "surrog": [True, False], - } - default_options = { - "shared": False, - "fPIC": True, - "openmp": True, - "surrog": True, - } - - short_paths = True - - def export_sources(self): - export_conandata_patches(self) - - def source(self): - get(self, **self.conan_data["sources"][self.version], strip_root=True) - - def build_requirements(self): - pass + generators = "CMakeDeps", "CMakeToolchain" def requirements(self): - self.requires("eigen/3.4.0", transitive_headers=True) - if self.options.openmp: - self.requires("llvm-openmp/17.0.6", transitive_headers=True) - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - def configure(self): - if self.options.shared: - self.options.rm_safe("fPIC") - - def layout(self): - cmake_layout(self,src_folder="src") - - def generate(self): - tc = CMakeToolchain(self) - tc.variables["LIBCMAES_BUILD_EXAMPLES"] = False - tc.variables["LIBCMAES_BUILD_SHARED_LIBS"] = self.options.shared - tc.variables["LIBCMAES_USE_OPENMP"] = self.options.openmp - tc.variables["LIBCMAES_ENABLE_SURROG"] = self.options.surrog - tc.variables["LIBCMAES_BUILD_PYTHON"] = False - tc.variables["LIBCMAES_BUILD_TESTS"] = False - tc.generate() + self.requires(self.tested_reference_str) def build(self): - #apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() - def package(self): - cmake = CMake(self) - cmake.install() + def layout(self): + cmake_layout(self) - rmdir(self, os.path.join(self.package_folder, "lib","pkgconfig")) - rm(self, "*.cmake", os.path.join(self.package_folder, "lib", "cmake", "libcmaes")) - copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + def test(self): + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "example") + self.run(cmd, env="conanrun") - def package_info(self): - self.cpp_info.libs = ["cmaes"] - self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") From a0ba9f07bea15a068ec15ecda106712f250efdac Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 15 Jul 2024 06:46:14 +0200 Subject: [PATCH 29/38] Apply patch to fix windows build --- recipes/cmaes/all/conandata.yml | 3 + recipes/cmaes/all/conanfile.py | 4 +- .../all/patches/CompilerOptionsEigen.patch | 142 ++++++++++++++++++ 3 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 recipes/cmaes/all/patches/CompilerOptionsEigen.patch diff --git a/recipes/cmaes/all/conandata.yml b/recipes/cmaes/all/conandata.yml index 191b7b47616e8..553aca707f508 100644 --- a/recipes/cmaes/all/conandata.yml +++ b/recipes/cmaes/all/conandata.yml @@ -2,3 +2,6 @@ sources: "0.10.0": url: "https://github.com/CMA-ES/libcmaes/archive/refs/tags/v0.10.tar.gz" sha256: "a77fb892654356c5657dd677161b7c67b196dc732cfb77eaca6708abc4f6cffc" +patches: + "0.10.0": + - patch_file: "patches/CompilerOptionsEigen.patch" \ No newline at end of file diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 546ede9daf7a0..2e56da07c604c 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -1,6 +1,6 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout -from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy +from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy, apply_conandata_patches import os class CmaesConan(ConanFile): @@ -68,7 +68,7 @@ def generate(self): tc.generate() def build(self): - #apply_conandata_patches(self) + apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() diff --git a/recipes/cmaes/all/patches/CompilerOptionsEigen.patch b/recipes/cmaes/all/patches/CompilerOptionsEigen.patch new file mode 100644 index 0000000000000..ba728f3d5d253 --- /dev/null +++ b/recipes/cmaes/all/patches/CompilerOptionsEigen.patch @@ -0,0 +1,142 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4a38212..dccfea4 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -6,12 +6,10 @@ if (NOT DEFINED CMAKE_BUILD_TYPE) + set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") + endif () + +-set(CMAKE_CXX_FLAGS "-Wall -Wextra") +-set(CMAKE_CXX_FLAGS_DEBUG "-g") +-set(CMAKE_CXX_FLAGS_RELEASE "-O3") +- + list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) + ++include(CompilerOptions) ++ + set (LIBCMAES_TOP_LEVEL NO) + if (${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) + set (LIBCMAES_TOP_LEVEL YES) +diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake +new file mode 100644 +index 0000000..af4f716 +--- /dev/null ++++ b/cmake/CompilerOptions.cmake +@@ -0,0 +1,91 @@ ++ ++set(CMAKE_CXX_FLAGS_DEBUG ++ "${CMAKE_CXX_FLAGS_DEBUG} -Wall" ++) ++set(CMAKE_CXX_FLAGS_RELEASE ++ "${CMAKE_CXX_FLAGS_RELEASE} -Wall ") ++ ++if(CMAKE_COMPILER_IS_GNUCXX) ++ set(CMAKE_CXX_FLAGS_DEBUG ++ "${CMAKE_CXX_FLAGS_DEBUG} -Wextra") ++ set(CMAKE_CXX_FLAGS_RELEASE ++ "${CMAKE_CXX_FLAGS_RELEASE} -O3 -Wextra") ++endif(CMAKE_COMPILER_IS_GNUCXX) ++ ++if (MSVC) ++ #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_USE_MATH_DEFINES" ) ++ ++ set(CMAKE_CXX_FLAGS_DEBUG ++ "${CMAKE_CXX_FLAGS_DEBUG} /permissive- /bigobj /w44101") ++ ++ set(CMAKE_CXX_FLAGS_RELEASE ++ "${CMAKE_CXX_FLAGS_RELEASE} /permissive- /bigobj /Ox /w44101") ++ ++ set(MSVC_DISABLED_WARNINGS_LIST ++ "C4061" # enumerator 'identifier' in switch of enum 'enumeration' is not ++ # explicitly handled by a case label ++ # Disable this because it flags even when there is a default. ++ "C4068" ++ "C4100" # 'exarg' : unreferenced formal parameter ++ "C4127" # conditional expression is constant ++ "C4200" # nonstandard extension used : zero-sized array in ++ # struct/union. ++ "C4204" # nonstandard extension used: non-constant aggregate initializer ++ "C4221" # nonstandard extension used : 'identifier' : cannot be ++ # initialized using address of automatic variable ++ "C4242" # 'function' : conversion from 'int' to 'uint8_t', ++ # possible loss of data ++ "C4244" # 'function' : conversion from 'int' to 'uint8_t', ++ # possible loss of data ++ "C4245" # 'initializing' : conversion from 'long' to ++ # 'unsigned long', signed/unsigned mismatch ++ "C4251" ++ "C4267" # conversion from 'size_t' to 'int', possible loss of data ++ "C4275" ++ "C4355" ++ "C4371" # layout of class may have changed from a previous version of the ++ # compiler due to better packing of member '...' ++ "C4388" # signed/unsigned mismatch ++ "C4296" # '>=' : expression is always true ++ "C4350" # behavior change: 'std::_Wrap_alloc...' ++ "C4365" # '=' : conversion from 'size_t' to 'int', ++ # signed/unsigned mismatch ++ "C4389" # '!=' : signed/unsigned mismatch ++ "C4464" # relative include path contains '..' ++ "C4510" # 'argument' : default constructor could not be generated ++ "C4571" ++ "C4512" # 'argument' : assignment operator could not be generated ++ "C4514" # 'function': unreferenced inline function has been removed ++ "C4548" # expression before comma has no effect; expected expression with ++ # side-effect" caused by FD_* macros. ++ "C4610" # struct 'argument' can never be instantiated - user defined ++ # constructor required. ++ "C4619" ++ "C4623" # default constructor was implicitly defined as deleted ++ "C4625" # copy constructor could not be generated because a base class ++ # copy constructor is inaccessible or deleted ++ "C4626" # assignment operator could not be generated because a base class ++ # assignment operator is inaccessible or deleted ++ "C4643" ++ "C4668" # 'symbol' is not defined as a preprocessor macro, replacing with ++ # '0' for 'directives' ++ # Disable this because GTest uses it everywhere. ++ "C4706" # assignment within conditional expression ++ "C4710" # 'function': function not inlined ++ "C4711" # function 'function' selected for inline expansion ++ "C4800" # 'int' : forcing value to bool 'true' or 'false' ++ # (performance warning) ++ "C4820" # 'bytes' bytes padding added after construct 'member_name' ++ "C4868" ++ "C4996" ++ "C5026" # move constructor was implicitly defined as deleted ++ "C5027" # move assignment operator was implicitly defined as deleted ++ "C5031" ++ "C5039" ++ "C5045" ++ ) ++ string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR ++ ${MSVC_DISABLED_WARNINGS_LIST}) ++ ++ set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} ${MSVC_DISABLED_WARNINGS_STR}") ++ endif() +diff --git a/include/libcmaes/eigenmvn.h b/include/libcmaes/eigenmvn.h +index fb8b11d..6a6943b 100644 +--- a/include/libcmaes/eigenmvn.h ++++ b/include/libcmaes/eigenmvn.h +@@ -58,7 +58,20 @@ public: + static std::mt19937 rng; // The uniform pseudo-random algorithm + mutable std::normal_distribution norm; // gaussian combinator + +- EIGEN_EMPTY_STRUCT_CTOR(scalar_normal_dist_op) ++ scalar_normal_dist_op() = default; ++ scalar_normal_dist_op(const scalar_normal_dist_op& other) ++ : norm{other.norm} ++ { ++ rng = other.rng; ++ }; ++ scalar_normal_dist_op &operator=(const scalar_normal_dist_op &other) { ++ if(this != &other) ++ { ++ scalar_normal_dist_op temp(other); ++ swap(temp); ++ } ++ return *this; ++ }; + + scalar_normal_dist_op &operator=(scalar_normal_dist_op &&other) + { From d18682c87c578ce9693a9658df58945f200cafe1 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 15 Jul 2024 07:04:03 +0200 Subject: [PATCH 30/38] Add empty new line at the end --- recipes/cmaes/all/conandata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cmaes/all/conandata.yml b/recipes/cmaes/all/conandata.yml index 553aca707f508..f63570f08f9fe 100644 --- a/recipes/cmaes/all/conandata.yml +++ b/recipes/cmaes/all/conandata.yml @@ -4,4 +4,4 @@ sources: sha256: "a77fb892654356c5657dd677161b7c67b196dc732cfb77eaca6708abc4f6cffc" patches: "0.10.0": - - patch_file: "patches/CompilerOptionsEigen.patch" \ No newline at end of file + - patch_file: "patches/CompilerOptionsEigen.patch" From ef722e32ce33b0c20d5b945ede106723d965fec5 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 15 Jul 2024 08:43:39 +0200 Subject: [PATCH 31/38] Set c++ standard to 11 in test_package --- recipes/cmaes/all/test_package/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/cmaes/all/test_package/CMakeLists.txt b/recipes/cmaes/all/test_package/CMakeLists.txt index 6927b26e2dc88..a2f973d357026 100644 --- a/recipes/cmaes/all/test_package/CMakeLists.txt +++ b/recipes/cmaes/all/test_package/CMakeLists.txt @@ -5,3 +5,4 @@ find_package(cmaes CONFIG REQUIRED) add_executable(example src/example.cpp) target_link_libraries(example libcmaes::cmaes) +target_compile_features(example PUBLIC cxx_std_11) From 9583a7d6f2a63beba02ed2620ad1bf0dabe0a97b Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Wed, 17 Jul 2024 07:22:54 +0200 Subject: [PATCH 32/38] Add second example and validate profile to have at least c++11 --- recipes/cmaes/all/conanfile.py | 14 +++++-- .../cmaes/all/test_package/src/example.cpp | 37 ++++++++++++++++++- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 2e56da07c604c..2c5097a7e203e 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -1,6 +1,7 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy, apply_conandata_patches +from conan.tools.build import check_min_cppstd import os class CmaesConan(ConanFile): @@ -8,14 +9,13 @@ class CmaesConan(ConanFile): generators = "CMakeDeps" - # Optional metadata - license = "LGPLv3" + license = "LGPL-3.0-or-later" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/CMA-ES/libcmaes" description = "libcmaes is a multithreaded C++11 library with Python bindings for high performance blackbox stochastic optimization using the CMA-ES algorithm for Covariance Matrix Adaptation Evolution Strategy" topics = ("cmaes", "minimization") + package_type = "library" - # Binary configuration settings = "os", "compiler", "build_type", "arch" options = { "shared": [True, False], @@ -32,6 +32,10 @@ class CmaesConan(ConanFile): short_paths = True + @property + def _min_cppstd(self): + return 11 + def export_sources(self): export_conandata_patches(self) @@ -84,3 +88,7 @@ def package(self): def package_info(self): self.cpp_info.libs = ["cmaes"] self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) \ No newline at end of file diff --git a/recipes/cmaes/all/test_package/src/example.cpp b/recipes/cmaes/all/test_package/src/example.cpp index 1835813f2705d..e42d6b2f0684b 100644 --- a/recipes/cmaes/all/test_package/src/example.cpp +++ b/recipes/cmaes/all/test_package/src/example.cpp @@ -11,7 +11,7 @@ FitFunc fsphere = [](const double *x, const int N) return val; }; -int main() +int test1() { int dim = 10; // problem dimensions. std::vector x0(dim,10.0); @@ -22,5 +22,40 @@ int main() CMASolutions cmasols = cmaes<>(fsphere,cmaparams); std::cout << "best solution: " << cmasols << std::endl; std::cout << "optimization took " << cmasols.elapsed_time() / 1000.0 << " seconds\n"; + + Candidate bcand = cmasols.best_candidate(); + + std::vector xsol = bcand.get_x(); + return EXIT_SUCCESS; +} + +int test2() +{ + int dim = 10; // problem dimensions. + std::vector x0(dim,10.0); + double sigma = 0.1; + double ftol = 1e-5; + + CMAParameters<> cmaparams(x0, sigma); + // cmaparams.set_mt_feval(true); + cmaparams.set_algo(aCMAES); + // cmaparams.set_elitism(1); + // cmaparams.set_noisy(); + cmaparams.set_ftolerance(ftol); + CMASolutions cmasols = cmaes<>(fsphere, cmaparams); + + Candidate bcand = cmasols.best_candidate(); + + std::vector xsol = bcand.get_x(); + + std::cout << "best solution: " << cmasols << std::endl; + std::cout << "optimization took " << cmasols.elapsed_time() / 1000.0 << " seconds\n"; + return EXIT_SUCCESS; +} + +int main() +{ + test1(); + test2(); return EXIT_SUCCESS; } From f323bcb5b49c446c65f8e283bb852414d7098375 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Mon, 22 Jul 2024 22:51:44 +0200 Subject: [PATCH 33/38] Apply openmp settings from https://github.com/conan-io/conan-center-index/issues/24577 --- recipes/cmaes/all/conanfile.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 2c5097a7e203e..af61caefcadc5 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -36,6 +36,22 @@ class CmaesConan(ConanFile): def _min_cppstd(self): return 11 + @property + def _openmp_flags(self): + if self.settings.compiler == "clang": + return ["-fopenmp=libomp"] + elif self.settings.compiler == "apple-clang": + return ["-Xclang", "-fopenmp"] + elif self.settings.compiler == "gcc": + return ["-fopenmp"] + elif self.settings.compiler == "intel-cc": + return ["-Qopenmp"] + elif self.settings.compiler == "sun-cc": + return ["-xopenmp"] + elif is_msvc(self): + return ["-openmp"] + return None + def export_sources(self): export_conandata_patches(self) @@ -47,8 +63,8 @@ def build_requirements(self): def requirements(self): self.requires("eigen/3.4.0", transitive_headers=True) - if self.options.openmp: - self.requires("llvm-openmp/17.0.6", transitive_headers=True) + if self.options.openmp and self.settings.compiler in ["clang", "apple-clang"]: + self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True) def config_options(self): if self.settings.os == "Windows": @@ -89,6 +105,15 @@ def package_info(self): self.cpp_info.libs = ["cmaes"] self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") + if self.options.openmp: + if self.settings.compiler in ["clang", "apple-clang"]: + self.cpp_info.requires.append("llvm-openmp::llvm-openmp") + openmp_flags = self._openmp_flags + self.cpp_info.cflags = openmp_flags + self.cpp_info.cxxflags = openmp_flags + self.cpp_info.sharedlinkflags = openmp_flags + self.cpp_info.exelinkflags = openmp_flags + def validate(self): if self.settings.compiler.cppstd: check_min_cppstd(self, self._min_cppstd) \ No newline at end of file From 025c68da64d5131d01d533cfa8957464304f131d Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Thu, 25 Jul 2024 06:50:39 +0200 Subject: [PATCH 34/38] Add eigen to requires array --- recipes/cmaes/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index af61caefcadc5..2cb40cde9d69e 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -104,6 +104,7 @@ def package(self): def package_info(self): self.cpp_info.libs = ["cmaes"] self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") + self.cpp_info.requires.append("eigen::eigen") if self.options.openmp: if self.settings.compiler in ["clang", "apple-clang"]: @@ -116,4 +117,4 @@ def package_info(self): def validate(self): if self.settings.compiler.cppstd: - check_min_cppstd(self, self._min_cppstd) \ No newline at end of file + check_min_cppstd(self, self._min_cppstd) From 499f8fb3c0706553018b983fb721ef4cee069c22 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Thu, 25 Jul 2024 08:22:10 +0200 Subject: [PATCH 35/38] Add is_msvc to imports --- recipes/cmaes/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 2cb40cde9d69e..b70a7cfb5dbe4 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -2,6 +2,7 @@ from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy, apply_conandata_patches from conan.tools.build import check_min_cppstd +from conan.tools.microsoft import is_msvc import os class CmaesConan(ConanFile): From 1434ba5995303bf9f13c109c6553277451cc2830 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Fri, 26 Jul 2024 06:55:08 +0200 Subject: [PATCH 36/38] Undo openmp suggestions --- recipes/cmaes/all/conanfile.py | 60 +++++++++++++++------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index b70a7cfb5dbe4..9ac0cfc9e2e9e 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -1,10 +1,17 @@ from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout -from conan.tools.files import export_conandata_patches, get, rmdir, rm, copy, apply_conandata_patches +from conan.tools.files import ( + export_conandata_patches, + get, + rmdir, + rm, + copy, + apply_conandata_patches, +) from conan.tools.build import check_min_cppstd -from conan.tools.microsoft import is_msvc import os + class CmaesConan(ConanFile): name = "cmaes" @@ -37,22 +44,6 @@ class CmaesConan(ConanFile): def _min_cppstd(self): return 11 - @property - def _openmp_flags(self): - if self.settings.compiler == "clang": - return ["-fopenmp=libomp"] - elif self.settings.compiler == "apple-clang": - return ["-Xclang", "-fopenmp"] - elif self.settings.compiler == "gcc": - return ["-fopenmp"] - elif self.settings.compiler == "intel-cc": - return ["-Qopenmp"] - elif self.settings.compiler == "sun-cc": - return ["-xopenmp"] - elif is_msvc(self): - return ["-openmp"] - return None - def export_sources(self): export_conandata_patches(self) @@ -64,8 +55,10 @@ def build_requirements(self): def requirements(self): self.requires("eigen/3.4.0", transitive_headers=True) - if self.options.openmp and self.settings.compiler in ["clang", "apple-clang"]: - self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True) + if self.options.openmp: + self.requires( + "llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True + ) def config_options(self): if self.settings.os == "Windows": @@ -76,7 +69,7 @@ def configure(self): self.options.rm_safe("fPIC") def layout(self): - cmake_layout(self,src_folder="src") + cmake_layout(self, src_folder="src") def generate(self): tc = CMakeToolchain(self) @@ -98,23 +91,22 @@ def package(self): cmake = CMake(self) cmake.install() - rmdir(self, os.path.join(self.package_folder, "lib","pkgconfig")) - rm(self, "*.cmake", os.path.join(self.package_folder, "lib", "cmake", "libcmaes")) - copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm( + self, + "*.cmake", + os.path.join(self.package_folder, "lib", "cmake", "libcmaes"), + ) + copy( + self, + "COPYING", + self.source_folder, + os.path.join(self.package_folder, "licenses"), + ) def package_info(self): self.cpp_info.libs = ["cmaes"] self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") - self.cpp_info.requires.append("eigen::eigen") - - if self.options.openmp: - if self.settings.compiler in ["clang", "apple-clang"]: - self.cpp_info.requires.append("llvm-openmp::llvm-openmp") - openmp_flags = self._openmp_flags - self.cpp_info.cflags = openmp_flags - self.cpp_info.cxxflags = openmp_flags - self.cpp_info.sharedlinkflags = openmp_flags - self.cpp_info.exelinkflags = openmp_flags def validate(self): if self.settings.compiler.cppstd: From b3bee092c44d9e7fd9667dd3916b8e439d5cf91c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abril=20Rinc=C3=B3n=20Blanco?= Date: Fri, 22 Nov 2024 12:50:30 +0100 Subject: [PATCH 37/38] Cleanup --- recipes/cmaes/all/conanfile.py | 36 ++++++++++++---------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/recipes/cmaes/all/conanfile.py b/recipes/cmaes/all/conanfile.py index 9ac0cfc9e2e9e..b38afa1737d5b 100644 --- a/recipes/cmaes/all/conanfile.py +++ b/recipes/cmaes/all/conanfile.py @@ -28,13 +28,11 @@ class CmaesConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], - "openmp": [True, False], "surrog": [True, False], } default_options = { "shared": False, "fPIC": True, - "openmp": True, "surrog": True, } @@ -44,29 +42,26 @@ class CmaesConan(ConanFile): def _min_cppstd(self): return 11 + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + def export_sources(self): export_conandata_patches(self) + def validate(self): + check_min_cppstd(self, self._min_cppstd) + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) - - def build_requirements(self): - pass + apply_conandata_patches(self) def requirements(self): self.requires("eigen/3.4.0", transitive_headers=True) - if self.options.openmp: - self.requires( - "llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True - ) - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - def configure(self): - if self.options.shared: - self.options.rm_safe("fPIC") def layout(self): cmake_layout(self, src_folder="src") @@ -75,14 +70,13 @@ def generate(self): tc = CMakeToolchain(self) tc.variables["LIBCMAES_BUILD_EXAMPLES"] = False tc.variables["LIBCMAES_BUILD_SHARED_LIBS"] = self.options.shared - tc.variables["LIBCMAES_USE_OPENMP"] = self.options.openmp + tc.variables["LIBCMAES_USE_OPENMP"] = False tc.variables["LIBCMAES_ENABLE_SURROG"] = self.options.surrog tc.variables["LIBCMAES_BUILD_PYTHON"] = False tc.variables["LIBCMAES_BUILD_TESTS"] = False tc.generate() def build(self): - apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() @@ -107,7 +101,3 @@ def package(self): def package_info(self): self.cpp_info.libs = ["cmaes"] self.cpp_info.set_property("cmake_target_name", "libcmaes::cmaes") - - def validate(self): - if self.settings.compiler.cppstd: - check_min_cppstd(self, self._min_cppstd) From ea4493f6b5fe87ac3f3db768dc2b9723d024bc95 Mon Sep 17 00:00:00 2001 From: Philipp Basler <28863303+phbasler@users.noreply.github.com> Date: Tue, 3 Dec 2024 22:09:47 +0100 Subject: [PATCH 38/38] Simplify test_package --- .../cmaes/all/test_package/src/example.cpp | 34 +++---------------- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/recipes/cmaes/all/test_package/src/example.cpp b/recipes/cmaes/all/test_package/src/example.cpp index e42d6b2f0684b..c905026356241 100644 --- a/recipes/cmaes/all/test_package/src/example.cpp +++ b/recipes/cmaes/all/test_package/src/example.cpp @@ -7,40 +7,21 @@ FitFunc fsphere = [](const double *x, const int N) { double val = 0.0; for (int i=0;i x0(dim,10.0); - double sigma = 0.1; - //int lambda = 100; // offsprings at each generation. - CMAParameters<> cmaparams(x0,sigma); - //cmaparams._algo = BIPOP_CMAES; - CMASolutions cmasols = cmaes<>(fsphere,cmaparams); - std::cout << "best solution: " << cmasols << std::endl; - std::cout << "optimization took " << cmasols.elapsed_time() / 1000.0 << " seconds\n"; - - Candidate bcand = cmasols.best_candidate(); - - std::vector xsol = bcand.get_x(); - return EXIT_SUCCESS; -} - -int test2() +int main() { - int dim = 10; // problem dimensions. + int dim = 10; std::vector x0(dim,10.0); double sigma = 0.1; double ftol = 1e-5; CMAParameters<> cmaparams(x0, sigma); - // cmaparams.set_mt_feval(true); cmaparams.set_algo(aCMAES); - // cmaparams.set_elitism(1); - // cmaparams.set_noisy(); cmaparams.set_ftolerance(ftol); CMASolutions cmasols = cmaes<>(fsphere, cmaparams); @@ -52,10 +33,3 @@ int test2() std::cout << "optimization took " << cmasols.elapsed_time() / 1000.0 << " seconds\n"; return EXIT_SUCCESS; } - -int main() -{ - test1(); - test2(); - return EXIT_SUCCESS; -}