From 534bd78e1e03422b70baf836c10c148737f406de Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Wed, 12 Jan 2022 15:01:26 +0100 Subject: [PATCH 1/5] Nuke CMake info not present upstream --- recipes/wineditline/all/CMakeLists.txt | 25 ------------------- recipes/wineditline/all/conanfile.py | 13 +--------- .../all/test_package/CMakeLists.txt | 4 +-- .../wineditline/all/test_package/conanfile.py | 2 +- 4 files changed, 3 insertions(+), 41 deletions(-) delete mode 100644 recipes/wineditline/all/CMakeLists.txt diff --git a/recipes/wineditline/all/CMakeLists.txt b/recipes/wineditline/all/CMakeLists.txt deleted file mode 100644 index a173239c53c44..0000000000000 --- a/recipes/wineditline/all/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required(VERSION 3.1) - -project(wineditline_wrapper C) - -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() - -set(src source_subfolder/src) - -add_library(edit "${src}/editline.c" "${src}/fn_complete.c" "${src}/history.c") -if(BUILD_SHARED_LIBS) - target_sources(edit PRIVATE "${src}/libedit.def") -endif() - -target_include_directories(edit PRIVATE "${src}") - -include(GNUInstallDirs) - -install( - TARGETS edit - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) - -install(DIRECTORY "${src}/editline" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") diff --git a/recipes/wineditline/all/conanfile.py b/recipes/wineditline/all/conanfile.py index bc220150a44d9..80fcaf3b88ce9 100644 --- a/recipes/wineditline/all/conanfile.py +++ b/recipes/wineditline/all/conanfile.py @@ -62,15 +62,4 @@ def package(self): cmake.install() def package_info(self): - name = self.name - info = self.cpp_info - - info.set_property("cmake_file_name", name) - info.set_property("cmake_target_name", f"{name}::{name}") - - info.names.update({ - "cmake_find_package": name, - "cmake_find_package_multi": name, - }) - - info.libs = ["edit"] + self.cpp_info.libs = ["edit"] diff --git a/recipes/wineditline/all/test_package/CMakeLists.txt b/recipes/wineditline/all/test_package/CMakeLists.txt index 7a1892d6fe492..90965bde8a849 100644 --- a/recipes/wineditline/all/test_package/CMakeLists.txt +++ b/recipes/wineditline/all/test_package/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) -find_package(wineditline REQUIRED CONFIG) - include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup(TARGETS) add_executable(test_package test_package.c) -target_link_libraries(test_package PRIVATE wineditline::wineditline) +target_link_libraries(test_package PRIVATE CONAN_PKG::wineditline) diff --git a/recipes/wineditline/all/test_package/conanfile.py b/recipes/wineditline/all/test_package/conanfile.py index ec80e0c5cc134..bb2570719d770 100644 --- a/recipes/wineditline/all/test_package/conanfile.py +++ b/recipes/wineditline/all/test_package/conanfile.py @@ -5,7 +5,7 @@ class TestPackageConan(ConanFile): settings = ("os", "compiler", "build_type", "arch") - generators = ("cmake", "cmake_find_package_multi") + generators = ("cmake",) def build(self): cmake = CMake(self) From 0178e513806e776a0c57f376e0cd79b15c79bdc1 Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Wed, 12 Jan 2022 15:01:57 +0100 Subject: [PATCH 2/5] Simplify calls to CMake helper --- recipes/wineditline/all/conanfile.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/recipes/wineditline/all/conanfile.py b/recipes/wineditline/all/conanfile.py index 80fcaf3b88ce9..c13b6a326f150 100644 --- a/recipes/wineditline/all/conanfile.py +++ b/recipes/wineditline/all/conanfile.py @@ -53,13 +53,11 @@ def _configure_cmake(self): return cmake def build(self): - cmake = self._configure_cmake() - cmake.build() + self._configure_cmake().build() def package(self): self.copy("COPYING", "licenses", self._source_subfolder) - cmake = self._configure_cmake() - cmake.install() + self._configure_cmake().install() def package_info(self): self.cpp_info.libs = ["edit"] From 0199b40859aee9445b9d6e959db66498cf47748a Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Wed, 12 Jan 2022 16:42:24 +0100 Subject: [PATCH 3/5] Patch the CMakeLists.txt instead of providing one --- recipes/wineditline/all/conandata.yml | 4 ++ recipes/wineditline/all/conanfile.py | 15 ++---- .../all/patches/0001-fix-cmakelists.patch | 46 +++++++++++++++++++ 3 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 recipes/wineditline/all/patches/0001-fix-cmakelists.patch diff --git a/recipes/wineditline/all/conandata.yml b/recipes/wineditline/all/conandata.yml index 60b4632ebe2ba..181ea7efb3566 100644 --- a/recipes/wineditline/all/conandata.yml +++ b/recipes/wineditline/all/conandata.yml @@ -2,3 +2,7 @@ sources: "2.206": sha256: "2d255c417244e963261dc6171684265f405df030e90ba6e6690a99284d645161" url: https://sourceforge.net/projects/mingweditline/files/wineditline-2.206.zip/download +patches: + "2.206": + - patch_file: patches/0001-fix-cmakelists.patch + base_path: "" diff --git a/recipes/wineditline/all/conanfile.py b/recipes/wineditline/all/conanfile.py index c13b6a326f150..314d2255a901c 100644 --- a/recipes/wineditline/all/conanfile.py +++ b/recipes/wineditline/all/conanfile.py @@ -25,12 +25,7 @@ class WineditlineConan(ConanFile): default_options = { "shared": False, } - - exports_sources = ("CMakeLists.txt",) - - @property - def _source_subfolder(self): - return "source_subfolder" + exports_sources = ("patches/*",) def validate(self): if self.settings.os != "Windows": @@ -38,9 +33,7 @@ def validate(self): raise ConanInvalidConfiguration(message) def source(self): - root = self._source_subfolder - get_args = self.conan_data["sources"][self.version] - tools.get(**get_args, destination=root, strip_root=True) + tools.get(**self.conan_data["sources"][self.version], strip_root=True) def configure(self): del self.settings.compiler.libcxx @@ -53,10 +46,12 @@ def _configure_cmake(self): return cmake def build(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) self._configure_cmake().build() def package(self): - self.copy("COPYING", "licenses", self._source_subfolder) + self.copy("COPYING", "licenses") self._configure_cmake().install() def package_info(self): diff --git a/recipes/wineditline/all/patches/0001-fix-cmakelists.patch b/recipes/wineditline/all/patches/0001-fix-cmakelists.patch new file mode 100644 index 0000000000000..16934ecd9fa57 --- /dev/null +++ b/recipes/wineditline/all/patches/0001-fix-cmakelists.patch @@ -0,0 +1,46 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -1,25 +1,19 @@ +-cmake_minimum_required (VERSION 2.6) +-project (WinEditLine) +-set (WinEditLine_VERSION_MAJOR 2) +-set (WinEditLine_VERSION_MINOR 2) +-if (MSVC AND MSVC_USE_STATIC_RUNTIME) +-foreach(flag_var +- CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE +- CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) +- if(${flag_var} MATCHES "/MD") +- string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") +- endif(${flag_var} MATCHES "/MD") +-endforeach(flag_var) +-endif() +-if(NOT DEFINED LIB_SUFFIX) +- if(CMAKE_SIZEOF_VOID_P MATCHES 4) +- set(LIB_SUFFIX "32") +- else() +- set(LIB_SUFFIX "64") +- endif() +-endif() +-configure_file ( +- "${PROJECT_SOURCE_DIR}/src/config.h.in" +- "${PROJECT_BINARY_DIR}/config.h" ++cmake_minimum_required(VERSION 3.1) ++ ++project(WinEditLine C) ++ ++include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") ++conan_basic_setup(TARGETS) ++ ++add_library(edit src/editline.c src/fn_complete.c src/history.c src/libedit.def) ++target_include_directories(edit PRIVATE src) ++ ++include(GNUInstallDirs) ++ ++install( ++ TARGETS edit ++ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +-add_subdirectory (src) ++ ++install(DIRECTORY src/editline DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") From 5d7ca01f301c9a739e0848889584f8a20cbcde6f Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Mon, 31 Jan 2022 01:55:22 +0100 Subject: [PATCH 4/5] Move Conan stuff from patches to a wrapper CML --- recipes/wineditline/all/CMakeLists.txt | 8 ++++++++ recipes/wineditline/all/conandata.yml | 2 +- recipes/wineditline/all/conanfile.py | 12 +++++++++--- .../all/patches/0001-fix-cmakelists.patch | 5 +---- 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 recipes/wineditline/all/CMakeLists.txt diff --git a/recipes/wineditline/all/CMakeLists.txt b/recipes/wineditline/all/CMakeLists.txt new file mode 100644 index 0000000000000..1fedb144d2f6c --- /dev/null +++ b/recipes/wineditline/all/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) + +project(WinEditLineWrapper C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +add_subdirectory(source_subfolder) diff --git a/recipes/wineditline/all/conandata.yml b/recipes/wineditline/all/conandata.yml index 181ea7efb3566..789f36bc66156 100644 --- a/recipes/wineditline/all/conandata.yml +++ b/recipes/wineditline/all/conandata.yml @@ -5,4 +5,4 @@ sources: patches: "2.206": - patch_file: patches/0001-fix-cmakelists.patch - base_path: "" + base_path: source_subfolder diff --git a/recipes/wineditline/all/conanfile.py b/recipes/wineditline/all/conanfile.py index 314d2255a901c..3888bf2a8557f 100644 --- a/recipes/wineditline/all/conanfile.py +++ b/recipes/wineditline/all/conanfile.py @@ -25,15 +25,21 @@ class WineditlineConan(ConanFile): default_options = { "shared": False, } - exports_sources = ("patches/*",) + exports_sources = ("patches/*", "CMakeLists.txt") def validate(self): if self.settings.os != "Windows": message = "wineditline is supported only on Windows." raise ConanInvalidConfiguration(message) + @property + def _source_subfolder(self): + return "source_subfolder" + def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True) + root = self._source_subfolder + get_args = self.conan_data["sources"][self.version] + tools.get(**get_args, destination=root, strip_root=True) def configure(self): del self.settings.compiler.libcxx @@ -51,7 +57,7 @@ def build(self): self._configure_cmake().build() def package(self): - self.copy("COPYING", "licenses") + self.copy("COPYING", "licenses", self._source_subfolder) self._configure_cmake().install() def package_info(self): diff --git a/recipes/wineditline/all/patches/0001-fix-cmakelists.patch b/recipes/wineditline/all/patches/0001-fix-cmakelists.patch index 16934ecd9fa57..ef01b0ca0616b 100644 --- a/recipes/wineditline/all/patches/0001-fix-cmakelists.patch +++ b/recipes/wineditline/all/patches/0001-fix-cmakelists.patch @@ -1,6 +1,6 @@ --- CMakeLists.txt +++ CMakeLists.txt -@@ -1,25 +1,19 @@ +@@ -1,25 +1,16 @@ -cmake_minimum_required (VERSION 2.6) -project (WinEditLine) -set (WinEditLine_VERSION_MAJOR 2) @@ -28,9 +28,6 @@ + +project(WinEditLine C) + -+include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -+conan_basic_setup(TARGETS) -+ +add_library(edit src/editline.c src/fn_complete.c src/history.c src/libedit.def) +target_include_directories(edit PRIVATE src) + From 30643b2c98594f32ed6c52893f0bca960af70a9f Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Mon, 31 Jan 2022 12:41:17 +0100 Subject: [PATCH 5/5] Use target from CMake config with Conan defaults --- recipes/wineditline/all/test_package/CMakeLists.txt | 4 +++- recipes/wineditline/all/test_package/conanfile.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/recipes/wineditline/all/test_package/CMakeLists.txt b/recipes/wineditline/all/test_package/CMakeLists.txt index 90965bde8a849..84a38c545c793 100644 --- a/recipes/wineditline/all/test_package/CMakeLists.txt +++ b/recipes/wineditline/all/test_package/CMakeLists.txt @@ -4,5 +4,7 @@ project(test_package C) include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup(TARGETS) +find_package(wineditline REQUIRED CONFIG) + add_executable(test_package test_package.c) -target_link_libraries(test_package PRIVATE CONAN_PKG::wineditline) +target_link_libraries(test_package PRIVATE wineditline::wineditline) diff --git a/recipes/wineditline/all/test_package/conanfile.py b/recipes/wineditline/all/test_package/conanfile.py index bb2570719d770..ec80e0c5cc134 100644 --- a/recipes/wineditline/all/test_package/conanfile.py +++ b/recipes/wineditline/all/test_package/conanfile.py @@ -5,7 +5,7 @@ class TestPackageConan(ConanFile): settings = ("os", "compiler", "build_type", "arch") - generators = ("cmake",) + generators = ("cmake", "cmake_find_package_multi") def build(self): cmake = CMake(self)