Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wineditline: address post-merge review comments #8867

Merged
merged 5 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions recipes/wineditline/all/CMakeLists.txt

This file was deleted.

4 changes: 4 additions & 0 deletions recipes/wineditline/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
34 changes: 8 additions & 26 deletions recipes/wineditline/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,15 @@ 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":
message = "wineditline is supported only on Windows."
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
Expand All @@ -53,24 +46,13 @@ def _configure_cmake(self):
return cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()
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)
cmake = self._configure_cmake()
cmake.install()
self.copy("COPYING", "licenses")
self._configure_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"]
46 changes: 46 additions & 0 deletions recipes/wineditline/all/patches/0001-fix-cmakelists.patch
Original file line number Diff line number Diff line change
@@ -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)
+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would isolate this part in the usual CMakeLists wrapper.

+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}")
4 changes: 1 addition & 3 deletions recipes/wineditline/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion recipes/wineditline/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down