find_package(Iconv) fails when external iconv implementations is provided as CFLAGS/LDFLAGS #429

Closed
opened 2022-06-13 04:05:39 -05:00 by Youw · 5 comments
Youw commented 2022-06-13 04:05:39 -05:00 (Migrated from github.com)
Reported at: https://github.com/libusb/hidapi/pull/426 Failed sample: https://github.com/openwrt/packages/actions/runs/2477509891
Youw commented 2022-06-13 05:41:20 -05:00 (Migrated from github.com)

https://github.com/openwrt/packages/runs/6838046113?check_suite_focus=true

@neheb would it be possible to see the content of:

"/home/build/openwrt/build_dir/target-x86_64_musl/hidapi-hidapi-0.12.0/CMakeFiles/CMakeOutput.log".
"/home/build/openwrt/build_dir/target-x86_64_musl/hidapi-hidapi-0.12.0/CMakeFiles/CMakeError.log".

Maybe you can run the build locally or so.


And the content of:

"/home/build/openwrt/staging_dir/target-x86_64_musl/usr/lib/libiconv-stub/lib"

I wounder what CMake tries (and fails) to find there.

> https://github.com/openwrt/packages/runs/6838046113?check_suite_focus=true @neheb would it be possible to see the content of: > "/home/build/openwrt/build_dir/target-x86_64_musl/hidapi-hidapi-0.12.0/CMakeFiles/CMakeOutput.log". > "/home/build/openwrt/build_dir/target-x86_64_musl/hidapi-hidapi-0.12.0/CMakeFiles/CMakeError.log". Maybe you can run the build locally or so. --- And the content of: > "/home/build/openwrt/staging_dir/target-x86_64_musl/usr/lib/libiconv-stub/lib" I wounder what CMake tries (and fails) to find there.
Youw commented 2022-06-13 06:23:57 -05:00 (Migrated from github.com)

Looks like this is a very specific case, during the cross-compilation, and when iconv is cross-compiled as well, and passed to CMake build externally.
This might be an issue specific to openwrt build infrastructure.

Looks like this is a very specific case, during the cross-compilation, and when iconv is cross-compiled as well, and passed to CMake build externally. This might be an issue specific to openwrt build infrastructure.
neheb commented 2022-06-13 16:25:06 -05:00 (Migrated from github.com)

@Youw https://gist.github.com/neheb/6f4ff891702e36f003136d1d448d78e9

First paste is Error, then Output.

@Youw https://gist.github.com/neheb/6f4ff891702e36f003136d1d448d78e9 First paste is Error, then Output.
Youw commented 2022-06-14 06:10:18 -05:00 (Migrated from github.com)

Problem analysis:

From the logs I can tell that openwrt doesn't follow minimal guidelines for CMake cross-compilation - no propper toolchain or specifying paths/environment to the libraries, the way CMake can recognize it.

One way of fixing it on the environment side is to set the CMAKE_PREFIX_PATH to:
/home/mangix/devstuff/openwrt/staging_dir/target-mips_24kc_musl/usr;/home/mangix/devstuff/openwrt/staging_dir/target-mips_24kc_musl/usr/lib/libiconv-full;/home/mangix/devstuff/openwrt/staging_dir/target-mips_24kc_musl/usr/lib/libintl-full.

But that way, obviously, requres changes to cmake.mk (maybe even more), which I don't expect to be done any time soon.
Making a library-specific (Iconv) fix for HIDAPI only at hidapi/Makefile globally doesn't make much sense, because it is not the first cmake build/package that is broken that way as far as I can tell.


On the bright side:

I can make a workaround on the HIDAPI side, so the Iconv will be found by HIDAPI/CMake even if CMake fails to do so by default (at least in the environment I see in openwrt).

Problem analysis: From the logs I can tell that openwrt doesn't follow minimal guidelines for CMake [cross-compilation](https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html) - no propper toolchain or specifying paths/[environment](https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html#variable:CMAKE_PREFIX_PATH) to the libraries, the way CMake can recognize it. One way of fixing it on the environment side is to set the `CMAKE_PREFIX_PATH` to: `/home/mangix/devstuff/openwrt/staging_dir/target-mips_24kc_musl/usr;/home/mangix/devstuff/openwrt/staging_dir/target-mips_24kc_musl/usr/lib/libiconv-full;/home/mangix/devstuff/openwrt/staging_dir/target-mips_24kc_musl/usr/lib/libintl-full`. But that way, obviously, requres changes to `cmake.mk` (maybe even more), which I don't expect to be done any time soon. Making a library-specific (Iconv) fix for HIDAPI only at `hidapi/Makefile` globally doesn't make much sense, because it is not the first cmake build/package that is broken that way [as far as I can tell](https://github.com/openwrt/packages/pull/18738#issuecomment-1152741609). --- On the bright side: I can make a workaround on the HIDAPI side, so the Iconv will be found by HIDAPI/CMake even if CMake fails to do so by default (at least in the environment I see in openwrt).
neheb commented 2022-06-15 13:40:42 -05:00 (Migrated from github.com)

That'd be great.

That'd be great.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi#429
No description provided.