-
Notifications
You must be signed in to change notification settings - Fork 149
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
FreeBSD/CMake include location fixes ftdi1 build problem. #925
FreeBSD/CMake include location fixes ftdi1 build problem. #925
Conversation
This commit appends `/usr/local/include` include location on FreeBSD. This fixes missing `libftdi1/ftdi.h` build error. Fixed build problem: ``` % rm -rf build; cmake -B build; cmake --build build -- The C compiler identification is Clang 11.0.1 -- The CXX compiler identification is Clang 11.0.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found Git: /usr/local/bin/git (found version "2.35.1") -- Found FLEX: /usr/bin/flex (found version "2.6.4") -- Found BISON: /usr/local/bin/bison (found version "3.8.2") -- Looking for libelf.h -- Looking for libelf.h - found -- Looking for libelf/libelf.h -- Looking for libelf/libelf.h - not found -- Looking for usb.h -- Looking for usb.h - found -- Looking for lusb0_usb.h -- Looking for lusb0_usb.h - not found -- Looking for libusb.h -- Looking for libusb.h - found -- Looking for libusb-1.0/libusb.h -- Looking for libusb-1.0/libusb.h - not found -- Looking for hidapi/hidapi.h -- Looking for hidapi/hidapi.h - not found -- Looking for ftdi_tcioflush -- Looking for ftdi_tcioflush - not found -- Configuration summary: -- ---------------------- -- DO HAVE libelf -- DO HAVE libusb -- DO HAVE libusb_1_0 -- DO HAVE libhidapi -- DO HAVE libftdi (but prefer to use libftdi1) -- DO HAVE libftdi1 -- DISABLED doc -- DISABLED parport -- DISABLED linuxgpio -- DISABLED linuxspi -- ---------------------- -- Configuring done -- Generating done -- Build files have been written to: /XXX/avrdude.git/build [ 1%] [FLEX][Parser] Building scanner with flex 2.6.4 [ 3%] [BISON][Parser] Building parser with bison 3.8.2 [ 4%] Building C object src/CMakeFiles/libavrdude.dir/arduino.c.o [ 6%] Building C object src/CMakeFiles/libavrdude.dir/avr.c.o [ 8%] Building C object src/CMakeFiles/libavrdude.dir/avr910.c.o [ 9%] Building C object src/CMakeFiles/libavrdude.dir/avrftdi.c.o In file included from /XXX/avrdude.git/src/avrftdi.c:41: /XXX/avrdude.git/src/avrftdi_private.h:12:11: fatal error: 'libftdi1/ftdi.h' file not found ^~~~~~~~~~~~~~~~~ 1 error generated. gmake[2]: *** [src/CMakeFiles/libavrdude.dir/build.make:129: src/CMakeFiles/libavrdude.dir/avrftdi.c.o] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:100: src/CMakeFiles/libavrdude.dir/all] Error 2 gmake: *** [Makefile:136: all] Error 2 ``` Signed-off-by: Tomasz 'CeDeROM' CEDRO <tomek@cedro.info>
Well, I'n not sure it's a good idea to put various possible system-dependant locations straight into the CMake infrastructure. |
Negative @dl8dtl. We should stick to generic build. Because generic build does not work out-of-the-box, the FreeBSD Port needs to add local patches in order to build. I saw your script, it modifies the If anyone knows better way to add This location can be safely added in a non-system-dependant way. I am not sure why |
Another generic non-os specific way could be:
Update: Above check should be done for all libraries. Adding |
But the most proper way would be including for instance |
@hselasky could you please take a look and advise how cmake could add |
I still don't think it's a good idea to fill up AVRDUDE's CMake files with OS-specific stuff. |
You know this is the CMAKE task to setup build enviroment so user just type Using library specific cmake packages would be the most elegant way but that would require big rewrite. My proposition is the least invasive way. The same can be done for Darwin. The goal of using cmake is to run cmake then make and have result ready. |
Well, it's FreeBSD that has decided to go to |
Again, if current cmake configuratrion had included the library packages as they should there would be no problem. We need to tell cmake what packages are used and what are their parameters. This is not the OS task but the author of the cmake file specific to a program that it builds. User is just supposed to run Simply adding the includes path solves the problem quickly, efficiently, and does not need rewrite of current cmake files.. also it does not force users to set up any environment variables, run additional scripts, or any other voodoo that is Linux mindset approach. This is FreeBSD "specific" solution because location is for sure existing here, it may not exist on other OS and that could cause problems. Please also note that cmake contains FreeBSD specific LibUSB 0.1 / 1.0 related detection because we have our own implementation here that is compatible with both LibUSB 0.1 and 1.0 but have different file locations. cmake configuration is the correct place to perform this kind of build setup. Take a look at
|
@cederom : Could you run a dummy target, "env", to see what environments are already set, or get the full enviroment for cmake. I'm pretty sure FreeBSD's /usr/ports/Mk/cmake is passing on /usr/local/include, but maybe it is lost somehow. |
Well, I just wanted to have it built out of the box on a local git clone outside the ports tree, just as any other cmake based software.. but I can also use provided shell script no problem :-) |
@hselasky Just wondering how to do that? I can help here with my FreeBSD VM. |
@cederom I do not think this patch is needed at all. It is similar to the macOS M1 case as mentioned here. You just need to carry out minor modification to build.sh for FreeBSD.
|
Okay, there is a script to build on FreeBSD. I wanted build with cmake to work out of the box. If this is not the part of this project design then we can just close that PR :-) Thank you for your time everyone :-) |
@cederom FreeBSD build instruction is documented in the Wiki. But yes it may be good to debug the CMake system as suggested by HPS to see why it is not as easy as Linux (by right /usr/local should be picked up just like /usr). |
|
Probably cmake can use pkg-config (FreeBSD: pkgconf) to detect the packages. It should work for Linux, macOS and FreeBSD, and also Windows MSYS2. I am not so familiar with CMake though. |
Some help here: I think FreeBSD only needs "libusb" and not "libusb-1.0", but maybe both will work. --HPS |
@hselasky The issue here is not libusb or libusb-1.0 (where FreeBSD has a different implemtnation from other OS, but still under /usr), rather the issue is libftdi1 (under /usr/local). pkg-config will work for both libusb-1.0 and libftdi1, and for libusb-0.1 and libftdi (old 0.x version) as well.
|
I see :-) |
We need plain Windows too, so I would rather stick to built-in cross-platform functions such as |
Is it possible to use pkg-config first and then fall-back to "find_library"? From what I see, many problem related to CMake seems to be related to the in-ability of "find_library". Usually the fall_back is for the user to specify the location of the header file and the library. Maybe arvdude can help a bit so that CMake can work out of the box for non-MSVC users. |
This commit appends
/usr/local/include
include location on FreeBSD.This fixes missing
libftdi1/ftdi.h
build error.Fixed build problem:
Signed-off-by: Tomasz 'CeDeROM' CEDRO tomek@cedro.info