-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add libftdi versions 1.2-1.5. #3957
Conversation
To avoid conflict with libftdi 0.x releases
recipes/libftdi/1.x/conanfile.py
Outdated
self.cpp_info.includedirs.append( | ||
os.path.join(self.package_folder, "include", "libftdi1") | ||
) | ||
self.cpp_info.libs = ["ftdipp1", "ftdi1"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You combine both libraries.
Does the cmake config file, installed by libftdi's cmake config (and removed by us), create separate targets for the c and c++ library?
Maybe this requires conan components?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These batch of errors (the .pc related errors) show that you need to use components,
and set the pkg_config
names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's possible to exactly mimic LibFTDI's CMake configuration with conan (Libftdi uses LibFTDI1
as the package name but LIBFTDI
and LIBFTDIPP
as the package variable names), but I've attempted to get as close as I can with conan components using the targets LibFTDI1::ftdi
and LibFTDI1::ftdipp
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conan has 3 settings
Filenames (sets the cmake package name, is find_package)
Names (the cmake namespace of the targets)
Components names (each unique target)
I am sure we have an example I just can't recall one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The find_package
name is LibFTDI1
, as used in examples/cmake_example
. The built-in find package then generates the variables $LIBFTDI_LIBRARIES
and $LIBFTDIPP_LIBRARIES
,
However the variables generated by the conan-generated find package when using components are ${LibFTDI1_component_LIBRARIES}
etc. I'm not sure it's possible to create multiple top-level variable names with conan, with a different name from the find_package
(I did try various combinations as you suggested).
The targets created by LibFTDI are not namespaced, which I know conan doesn't support. See also conan-io/conan#7615
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes since the variables fashion is outdated its unlikely that conan will add support for that. So yes it seems this can not be done.
recipes/libftdi/1.x/conanfile.py
Outdated
self.cpp_info.includedirs.append( | ||
os.path.join(self.package_folder, "include", "libftdi1") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for absolute paths.
.includedirs
can contain relative paths.
self.deps_cpp_info[xxx].include_paths
automatically converts these to absolute paths.
self.cpp_info.includedirs.append( | |
os.path.join(self.package_folder, "include", "libftdi1") | |
) | |
self.cpp_info.includedirs.append(os.path.join("include", "libftdi1")) |
I detected other pull requests that are modifying libftdi/1.x recipe: This message is automatically generated by https://github.com/ericLemanissier/conan-center-conflicting-prs so don't hesitate to report issues/improvements there. |
This comment has been minimized.
This comment has been minimized.
ec5aa11
to
efab530
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the license
I would allow appreciate if you could try the patch but it's not required to merge
recipes/libftdi/1.x/conanfile.py
Outdated
class LibFtdiConan(ConanFile): | ||
name = "libftdi" | ||
description = "A library to talk to FTDI chips" | ||
license = ["GNU LGPL v2.1"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.intra2net.com/en/developer/libftdi/
https://spdx.org/licenses/LGPL-2.1.html
license = ["GNU LGPL v2.1"] | |
license = "LGPL-2.1" |
recipes/libftdi/1.x/conanfile.py
Outdated
def _patch_cmakelists(self, subfolder): | ||
cmakelists_path = os.path.join(self._source_subfolder, subfolder, "CMakeLists.txt") | ||
tools.replace_in_file(cmakelists_path, "CMAKE_SOURCE_DIR", "PROJECT_SOURCE_DIR", strict=False) | ||
tools.replace_in_file(cmakelists_path, "CMAKE_BINARY_DIR", "PROJECT_BINARY_DIR", strict=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking over the project. I think we can do sometime much less aggressive.
Can you please try to add the following? This way we can contribute it back to upstream 🤞
recipes/libftdi/1.x/conanfile.py
Outdated
tools.rmdir(os.path.join(lib_folder, "pkgconfig")) | ||
# STATIC config creates both static and shared libraries | ||
if not self.options.shared: | ||
tools.remove_files_by_mask(lib_folder, "*.so*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@planetmarshall |
This comment has been minimized.
This comment has been minimized.
Missing MacOS framework symbols? ocornut/imgui#2546 (comment) |
All green in build 13 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try aim to keep the patches to a minimum. These modification make them less portable to newer versions and the recipe harder to maintain...
#3903 and the related PR have a lot of discussion on the topic
I feel this patch is far larger than is required and there's a lot of non trivial changes. I stopped marking but I scanned over the file.
➡️ Please reduce this patch to only the essential changes
-# Project | ||
project(libftdi1 C) | ||
+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra
-# CMake | ||
if("${CMAKE_BUILD_TYPE}" STREQUAL "") | ||
set(CMAKE_BUILD_TYPE RelWithDebInfo) | ||
endif("${CMAKE_BUILD_TYPE}" STREQUAL "") | ||
set(CMAKE_COLOR_MAKEFILE ON) | ||
-cmake_minimum_required(VERSION 2.6 FATAL_ERROR) | ||
+ | ||
+cmake_minimum_required(VERSION 3.0 FATAL_ERROR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra
+if(POLICY CMP0057) | ||
+ cmake_policy(SET CMP0057 NEW) | ||
+endif() | ||
+if(POLICY CMP0011) | ||
+ cmake_policy(SET CMP0011 NEW) | ||
+endif() | ||
+if(POLICY CMP0099) | ||
+ cmake_policy(SET CMP0099 NEW) | ||
+endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain why you are adjusting the policies, these do not seem required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the policies are not set, there are warnings in the CMake log for recent versions.
-message("-- Build type: ${CMAKE_BUILD_TYPE}") | ||
+message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra
include(CMakeOptions.txt) | ||
|
||
+set(as_subproject LibFTDI) | ||
+macro(find_package) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overriding the cmake function? 😕 Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows the library to be consumed by examples and applications in the build tree as if it were an external project, and is considered CMake best practice. See Effective CMake by Daniel Pfeiffer (CPPNow 2017) Slide 31
if ( BUILD_TESTS ) | ||
+ project(libftdi1 C CXX) | ||
+ find_package(Boost COMPONENTS unit_test_framework REQUIRED) | ||
+ enable_testing() | ||
add_subdirectory(test) | ||
endif () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CCI should not be building tests!
extra
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't. BUILD_TESTS
is not defined by the cmake configuration in the conanfile.
-if(CMAKE_VERSION VERSION_LESS 2.8.8) | ||
- configure_file ( cmake/LibFTDI1Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake @ONLY ) | ||
- configure_file ( cmake/LibFTDI1ConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1ConfigVersion.cmake @ONLY ) | ||
-else () | ||
- include(CMakePackageConfigHelpers) | ||
- | ||
- configure_package_config_file ( | ||
- cmake/LibFTDI1Config.cmake.in | ||
- ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake | ||
- INSTALL_DESTINATION ${LIBFTDI_CMAKE_CONFIG_DIR} | ||
- PATH_VARS | ||
- LIBFTDI_USE_FILE | ||
- LIBFTDI_ROOT_DIR | ||
- LIBFTDI_INCLUDE_DIR | ||
- LIBFTDI_INCLUDE_DIRS | ||
- LIBFTDI_LIBRARY_DIRS | ||
- NO_CHECK_REQUIRED_COMPONENTS_MACRO | ||
- ) | ||
- write_basic_package_version_file ( | ||
- LibFTDI1ConfigVersion.cmake | ||
- VERSION ${LIBFTDI_VERSION_STRING} | ||
- COMPATIBILITY AnyNewerVersion | ||
- ) | ||
-endif () | ||
+include(CMakePackageConfigHelpers) | ||
+ | ||
+configure_package_config_file ( | ||
+cmake/LibFTDI1Config.cmake.in | ||
+${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake | ||
+INSTALL_DESTINATION ${LIBFTDI_CMAKE_CONFIG_DIR} | ||
+PATH_VARS | ||
+ LIBFTDI_USE_FILE | ||
+ LIBFTDI_ROOT_DIR | ||
+ LIBFTDI_INCLUDE_DIR | ||
+ LIBFTDI_INCLUDE_DIRS | ||
+ LIBFTDI_LIBRARY_DIRS | ||
+NO_CHECK_REQUIRED_COMPONENTS_MACRO | ||
+) | ||
+write_basic_package_version_file ( | ||
+LibFTDI1ConfigVersion.cmake | ||
+VERSION ${LIBFTDI_VERSION_STRING} | ||
+COMPATIBILITY AnyNewerVersion | ||
+) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like an overkill. The if
is always true in CCI and should not need to be changed
Is this really required?
I took a quick look at the discussion but it seemed to be pretty personal and argumentative. In short though I think the patch meets danimtb's criteria in that it only modifies the build system.
While a smaller patch would work for CCI, it would not be sufficient to build the tests and examples which would be necessary for the patch to be accepted upstream, which was mentioned above as a goal for using patch files. |
All green in build 14 (
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@planetmarshall Is it an official patch provided by upstream? Or did you create it and pushed to upstream? If it's official, no problem accepting. Otherwise, let's reduce it, testing and examples anre not used on CCI |
Sure, will take a look over the weekend. I've submitted the patch upstream but could be a while before seeing any feedback. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @prince-chrismc that the patch should be simplified. Here the aim should be to modify the build-system the minimum just to make it buildable using Conan... OTH I agree it is better to merge the recipe and improve it in the following iterations.
50/50, wdyt, @prince-chrismc ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's too many changes in the patch which likely change the output so I do feel comfortable approving... but that's why we have lots of reviewers!
Given the age there's a few conventions that have changed too if we move this forwarded
for subdivisors 0, 0.5, 0.25, 0.125 | ||
*/ | ||
-static int ftdi_to_clkbits(int baudrate, unsigned int clk, int clk_div, unsigned long *encoded_divisor) | ||
+static int ftdi_to_clkbits(int baudrate, int clk, int clk_div, unsigned long *encoded_divisor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually digging in the patch I found code changes which I was not expect ... this is beyond "fixing cmake"... 700+ lines of diff and lots of meaningless changes
Specify library name and version: lib/1.0
conan-center hook activated.